from django.shortcuts import render from django.template import loader from django.urls import reverse from django.utils import timezone from django.http import HttpResponse, HttpResponseRedirect from django.contrib import messages from django.db.models import Q from django.contrib.auth import authenticate, login, logout from django.contrib.auth.forms import AuthenticationForm, UserCreationForm from django.contrib.auth.models import User from core.views import gen_page_base, gen_page_sys, get_get_value from .forms import * from .models import * def text_to_icon(text): icon = "Error" if text == "0": icon = "" elif text == "1": icon = "" elif text == "2": icon = "" elif text == "3": icon = "" elif text == "NOUVELLE": icon = "" elif text == "PROGRAMEE": icon = "" elif text == "ENCOUR": icon = "" elif text == "FINI": icon = "" return icon def taches_get_list(request): template = loader.get_template('parc_info_api_taches_get_list.html') data_query = Taches.objects.exclude(Tache_Statut = 'FINI').order_by('-Tache_Priorite','-Tache_Date_Cree') for item in data_query: item.Tache_Priorite = text_to_icon(item.Tache_Priorite) item.Tache_Statut = text_to_icon(item.Tache_Statut) html = template.render({ 'data_query': data_query, }, request) return HttpResponse(html) def taches_get_info(request, id_tache): template = loader.get_template('parc_info_api_taches_get.html') item = Taches.objects.get(id = id_tache) item.Tache_Priorite = text_to_icon(item.Tache_Priorite) item.Tache_Statut = text_to_icon(item.Tache_Statut) html = template.render({ 'item': item, }, request) return HttpResponse(html) def taches_edit_info(request, id_tache): template = loader.get_template('parc_info_api_taches_edit.html') if id_tache == None or id_tache == '0': item = Taches() item.Tache_Date_Programee = timezone.now() item.id = 0 else : item = Taches.objects.get(id = id_tache) form = Edit_Tache_form(instance=item) html = template.render({ 'form': form, 'item': item, }, request) return HttpResponse(html)