Création controleur d'ajout de tache -- A DEBUG
This commit is contained in:
parent
b3c709a7e9
commit
8bf49e4d15
37
Controllers/TasksController.py
Normal file
37
Controllers/TasksController.py
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
# -*-coding:utf8 -*
|
||||||
|
"""Controleur pour la gestion des tâches"""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
from tkinter import *
|
||||||
|
from datetime import datetime
|
||||||
|
DOSSIER_COURRANT = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
DOSSIER_PARENT = os.path.dirname(DOSSIER_COURRANT)
|
||||||
|
sys.path.append(DOSSIER_PARENT)
|
||||||
|
from Auth.authentication import Auth
|
||||||
|
from Tasks.model import Task
|
||||||
|
|
||||||
|
|
||||||
|
class TasksController:
|
||||||
|
"""Controlleur gérant l'ajout de tâches"""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.task = Task()
|
||||||
|
|
||||||
|
def register(self, heured, heuref, comm, idpro, descr, idty,
|
||||||
|
day=datetime.now().strftime('%Y-%m-%d')):
|
||||||
|
"""Enregistre une tâche en base de données"""
|
||||||
|
#Création de la tâche
|
||||||
|
self.task = Task(heure_debut=heured, heure_fin=heuref, commentaire=comm,
|
||||||
|
id_util=Auth.current_user_id, id_proj=idpro, desc=descr, date=day,
|
||||||
|
id_type=idty)
|
||||||
|
print(day)
|
||||||
|
self.task.register()
|
||||||
|
|
||||||
|
|
||||||
|
def get_list(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
#Pour Test
|
||||||
|
Auth.current_user_id = 1
|
|
@ -1,3 +1,8 @@
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
DOSSIER_COURRANT = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
DOSSIER_PARENT = os.path.dirname(DOSSIER_COURRANT)
|
||||||
|
sys.path.append(DOSSIER_PARENT)
|
||||||
import DB.dbLink as db
|
import DB.dbLink as db
|
||||||
|
|
||||||
class Task:
|
class Task:
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
"""Fenêtre de rapide : Vue"""
|
"""Fenêtre de rapide : Vue"""
|
||||||
#TODO: Rajouter une checkbox pour ajout d'une entrée de temps manuel (sans chrono)
|
#TODO: Rajouter une checkbox pour ajout d'une entrée de temps manuel (sans chrono)
|
||||||
|
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
from tkinter import *
|
from tkinter import *
|
||||||
|
@ -12,6 +10,7 @@ DOSSIER_COURRANT = os.path.dirname(os.path.abspath(__file__))
|
||||||
DOSSIER_PARENT = os.path.dirname(DOSSIER_COURRANT)
|
DOSSIER_PARENT = os.path.dirname(DOSSIER_COURRANT)
|
||||||
sys.path.append(DOSSIER_PARENT)
|
sys.path.append(DOSSIER_PARENT)
|
||||||
from DB.dbLink import DBLink as db
|
from DB.dbLink import DBLink as db
|
||||||
|
from Controllers.TasksController import TasksController as TasksCont
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,33 +34,38 @@ class QuickTask:
|
||||||
Label(QuickTask.fenetre, text="Nom du projet :").pack()
|
Label(QuickTask.fenetre, text="Nom du projet :").pack()
|
||||||
# Create a Tkinter variable
|
# Create a Tkinter variable
|
||||||
QuickTask.project = StringVar(QuickTask.fenetre)
|
QuickTask.project = StringVar(QuickTask.fenetre)
|
||||||
proj_choices = dict()
|
self.proj_choices = dict()
|
||||||
#Récupération des types et insertion comme options
|
#Récupération des types et insertion comme options
|
||||||
projects = link.query("SELECT IDProj, Intitulé FROM projet ", [])
|
projects = link.query("SELECT IDProj, Intitulé FROM projet WHERE IDStat = 1", [])
|
||||||
for pro_id, pro_nom in projects:
|
for pro_id, pro_nom in projects:
|
||||||
proj_choices[pro_nom] = pro_id
|
self.proj_choices[pro_nom] = pro_id
|
||||||
|
|
||||||
QuickTask.project.set(project_name) # set the default option
|
QuickTask.project.set(project_name) # set the default option
|
||||||
OptionMenu(QuickTask.fenetre, QuickTask.project, *proj_choices).pack()
|
OptionMenu(QuickTask.fenetre, QuickTask.project, *self.proj_choices).pack()
|
||||||
|
|
||||||
###Champ de type
|
###Champ de type
|
||||||
# Create a Tkinter variable
|
# Create a Tkinter variable
|
||||||
QuickTask.type_value = StringVar(QuickTask.fenetre)
|
QuickTask.type_value = StringVar(QuickTask.fenetre)
|
||||||
choices = dict()
|
self.ty_choices = dict()
|
||||||
#Récupération des types et insertion comme options
|
#Récupération des types et insertion comme options
|
||||||
types = link.query("SELECT * FROM type ", [])
|
types = link.query("SELECT * FROM type ", [])
|
||||||
for ty_id, ty_nom in types:
|
for ty_id, ty_nom in types:
|
||||||
choices[ty_nom] = ty_id
|
self.ty_choices[ty_nom] = ty_id
|
||||||
|
|
||||||
QuickTask.type_value.set("Sélectionner...") # set the default option
|
QuickTask.type_value.set("Sélectionner...") # set the default option
|
||||||
Label(QuickTask.fenetre, text="Type de tâche :").pack()
|
Label(QuickTask.fenetre, text="Type de tâche :").pack()
|
||||||
OptionMenu(QuickTask.fenetre, QuickTask.type_value, *choices).pack()
|
OptionMenu(QuickTask.fenetre, QuickTask.type_value, *self.ty_choices).pack()
|
||||||
|
|
||||||
###Champ de description
|
###Champ de description
|
||||||
Label(QuickTask.fenetre, text="Description :").pack()
|
Label(QuickTask.fenetre, text="Description :").pack()
|
||||||
QuickTask.input_desc = Entry(QuickTask.fenetre)
|
QuickTask.input_desc = Entry(QuickTask.fenetre)
|
||||||
QuickTask.input_desc.pack()
|
QuickTask.input_desc.pack()
|
||||||
|
|
||||||
|
###Champ de commentaire
|
||||||
|
Label(QuickTask.fenetre, text="Commentaire :").pack()
|
||||||
|
QuickTask.input_comm = Text(QuickTask.fenetre, width=25, height=3)
|
||||||
|
QuickTask.input_comm.pack()
|
||||||
|
|
||||||
###Minutes de décalage pour le bouton démarrer/arrêter
|
###Minutes de décalage pour le bouton démarrer/arrêter
|
||||||
Label(QuickTask.fenetre, text="Décalage : ").pack()
|
Label(QuickTask.fenetre, text="Décalage : ").pack()
|
||||||
self.min_label = Label(QuickTask.fenetre, text="Tâche commencée il y a ")
|
self.min_label = Label(QuickTask.fenetre, text="Tâche commencée il y a ")
|
||||||
|
@ -117,12 +121,19 @@ class QuickTask:
|
||||||
QuickTask.end_time = datetime.now() - timedelta(minutes=decalage)
|
QuickTask.end_time = datetime.now() - timedelta(minutes=decalage)
|
||||||
QuickTask.start_stop['text'] = "Démarrer"
|
QuickTask.start_stop['text'] = "Démarrer"
|
||||||
self.min_label['text'] = "Tâche commencée il y a "
|
self.min_label['text'] = "Tâche commencée il y a "
|
||||||
#TODO: appel à la fonction controleur enregistrant la tâche en BDD
|
# appel à la fonction controleur enregistrant la tâche en BDD
|
||||||
|
controller = TasksCont()
|
||||||
|
controller.register(QuickTask.heure_debut, QuickTask.heure_fin,
|
||||||
|
QuickTask.input_comm.get('1.0', 'end'),
|
||||||
|
self.proj_choices[QuickTask.project.get()],
|
||||||
|
QuickTask.input_desc.get(),
|
||||||
|
self.ty_choices[QuickTask.type_value.get()])
|
||||||
#On change le statut du bouton et on vide les champs
|
#On change le statut du bouton et on vide les champs
|
||||||
QuickTask.activate = not QuickTask.activate
|
QuickTask.activate = not QuickTask.activate
|
||||||
QuickTask.heure_debut['state'] = NORMAL
|
QuickTask.heure_debut['state'] = NORMAL
|
||||||
QuickTask.heure_debut.delete(0, 'end')
|
QuickTask.heure_debut.delete(0, 'end')
|
||||||
QuickTask.heure_debut['state'] = DISABLED
|
QuickTask.heure_debut['state'] = DISABLED
|
||||||
|
QuickTask.input_comm.delete('1.0', 'end')
|
||||||
|
|
||||||
#Désactivation du bouton annuler et vidage de champs
|
#Désactivation du bouton annuler et vidage de champs
|
||||||
QuickTask.cancel['state'] = DISABLED
|
QuickTask.cancel['state'] = DISABLED
|
||||||
|
|
Loading…
Reference in a new issue