This commit is contained in:
Valentin Moguérou 2024-04-15 19:02:01 +02:00
parent 6f888390e4
commit 39c52696c2
4 changed files with 259 additions and 41 deletions

View File

@ -93,7 +93,7 @@ class Etudiant(models.Model):
#lv1 = models.ForeignKey(Matiere, on_delete=models.CASCADE)
#lv2 = models.ForeignKey(Matiere, on_delete=models.CASCADE)
def appartient(self, groupe, periode):
def appartient(self, groupe):
return Appartenance.objects.filter(etudiant=self, groupe=groupe).exists()
def groupe_du_critere(self, periode, critere):
@ -129,6 +129,18 @@ class Rotation(models.Model):
groupes = models.ManyToManyField(Groupe)
semaine = models.IntegerField()
def groupe_initial(self):
return Etudiant.objects.filter(id__in=Appartenance.objects.filter(groupe__in=self.groupes.all()))
def groupe_effectif(self):
amendements=Amendement.objects.filter(rotation=self)
return Etudiant.objects.filter(
( Q(id__in=Appartenance.objects.filter(groupe__in=self.groupes.all()))
| Q(id__in=amendements.filter(est_positif=True).values("etudiant_id")) )
& ~Q(id__in=amendements.filter(est_positif=False).values("etudiant_id"))
)
def effectif(self):
n_base = sum(len(groupe.membres()) for groupe in self.groupes.all())
n_plus = len(Amendement.objects.filter(est_positif=True, rotation=self))
@ -138,18 +150,34 @@ class Rotation(models.Model):
def est_pleine(self):
eff = self.effectif()
return eff>=self.creneau.capacite
if eff>self.creneau.capacite:
raise models.IntegrityError
def est_modifiee(self):
return Amendement.objects.filter(rotation=self).exists()
def amender(self, etudiant, est_positif):
# check annulation
if Amendement.objects.filter(rotation=self, etudiant=etudiant, est_positif=est_positif).exists():
raise Exception("Duplication")
elif Amendement.objects.filter(rotation=self, etudiant=etudiant, est_positif=not est_positif).exists():
Amendement.objects.get(rotation=self, etudiant=etudiant, est_positif=not est_positif).delete()
elif est_positif and any(etudiant.appartient(groupe) for groupe in self.groupes.all()):
raise Exception("Vous êtes déjà dans le groupe")
elif not est_positif and all(not etudiant.appartient(groupe) for groupe in self.groupes.all()):
raise Exception("Vous n'êtes pas dans le groupe")
elif est_positif and self.est_pleine():
raise Exception("Capacité dépassée")
else:
return eff==self.creneau.capacite
# on ne peut pas s'ajouter si on est dans le groupe de base
amendement = Amendement(rotation=self, etudiant=etudiant, est_positif=est_positif)
amendement.save()
class Amendement(models.Model):
est_positif = models.BooleanField()
rotation = models.ForeignKey(Rotation, on_delete=models.CASCADE)
etudiant = models.ForeignKey(Etudiant, on_delete=models.CASCADE)
class Utilisateur(models.Model):
username = models.CharField(max_length=100)
password = models.CharField(max_length=300)

199
colloscope/output-15_1.csv Normal file
View File

@ -0,0 +1,199 @@
hour,day,month,year,length,group,colleur,matiere
12,5,2,2024,1,2,Chevalier,Physique
13,5,2,2024,1,13,Herbaut,Anglais
14,6,2,2024,1,6,Mullaert,Maths
14,6,2,2024,1,4,Chevalier,Physique
14,6,2,2024,1,15,Belaggoune,Anglais
17,6,2,2024,1,10,Colin,Physique
17,6,2,2024,1,14,Chevalier,Physique
18,6,2,2024,1,7,Rapin,Maths
13,7,2,2024,1,10,Carpintero,Maths
14,7,2,2024,1,5,Le_Gouriellec,Anglais
14,7,2,2024,1,12,Carpintero,Maths
14,7,2,2024,1,14,Boully,Maths
14,7,2,2024,1,15,Bouverot,Maths
14,7,2,2024,2,0,none,_
14,7,2,2024,2,0,none,_
14,7,2,2024,2,0,none,_
15,7,2,2024,1,4,Bouverot,Maths
15,7,2,2024,1,7,Le_Gouriellec,Anglais
15,7,2,2024,1,11,Boully,Maths
16,7,2,2024,1,9,Mann,Anglais
16,7,2,2024,2,0,none,_
16,7,2,2024,2,0,none,_
16,7,2,2024,2,0,none,_
17,7,2,2024,1,3,Mann,Anglais
17,7,2,2024,1,6,Poupy,Physique
18,7,2,2024,1,8,Poupy,Physique
14,8,2,2024,1,1,Belaggoune,Anglais
15,8,2,2024,1,11,Belaggoune,Anglais
18,8,2,2024,1,2,Rapin,Maths
18,8,2,2024,1,0,none,_
16,9,2,2024,1,12,Chibani,Physique
17,9,2,2024,1,8,Oubaha,Maths
18,9,2,2024,1,3,Oubaha,Maths
12,12,2,2024,1,1,Chevalier,Physique
13,12,2,2024,1,14,Herbaut,Anglais
14,13,2,2024,1,1,Mullaert,Maths
14,13,2,2024,1,5,Chevalier,Physique
14,13,2,2024,1,0,none,_
17,13,2,2024,1,7,Colin,Physique
17,13,2,2024,1,9,Chevalier,Physique
18,13,2,2024,1,4,Rapin,Maths
13,14,2,2024,1,7,Carpintero,Maths
14,14,2,2024,1,2,Le_Gouriellec,Anglais
14,14,2,2024,1,13,Carpintero,Maths
14,14,2,2024,1,3,Bouverot,Maths
14,14,2,2024,1,5,Boully,Maths
14,14,2,2024,2,0,none,_
14,14,2,2024,2,0,none,_
14,14,2,2024,2,0,none,_
15,14,2,2024,1,4,Le_Gouriellec,Anglais
15,14,2,2024,1,9,Bouverot,Maths
15,14,2,2024,1,12,Boully,Maths
16,14,2,2024,1,6,Mann,Anglais
16,14,2,2024,2,0,none,_
16,14,2,2024,2,0,none,_
16,14,2,2024,2,0,none,_
17,14,2,2024,1,8,Mann,Anglais
17,14,2,2024,1,11,Poupy,Physique
18,14,2,2024,1,13,Poupy,Physique
14,15,2,2024,1,10,Belaggoune,Anglais
15,15,2,2024,1,12,Belaggoune,Anglais
18,15,2,2024,1,0,none,_
18,15,2,2024,1,8,Rapin,Maths
16,16,2,2024,1,3,Chibani,Physique
17,16,2,2024,1,11,Oubaha,Maths
18,16,2,2024,1,15,Oubaha,Maths
12,19,2,2024,1,2,Chevalier,Physique
13,19,2,2024,1,11,Herbaut,Anglais
14,20,2,2024,1,2,Mullaert,Maths
14,20,2,2024,1,10,Chevalier,Physique
14,20,2,2024,1,13,Belaggoune,Anglais
17,20,2,2024,1,12,Chevalier,Physique
17,20,2,2024,1,14,Colin,Physique
18,20,2,2024,1,1,Rapin,Maths
13,21,2,2024,1,8,Carpintero,Maths
14,21,2,2024,1,3,Le_Gouriellec,Anglais
14,21,2,2024,1,12,Carpintero,Maths
14,21,2,2024,1,14,Bouverot,Maths
14,21,2,2024,1,9,Boully,Maths
14,21,2,2024,2,0,none,_
14,21,2,2024,2,0,none,_
14,21,2,2024,2,0,none,_
15,21,2,2024,1,1,Le_Gouriellec,Anglais
15,21,2,2024,1,13,Bouverot,Maths
15,21,2,2024,1,6,Boully,Maths
16,21,2,2024,1,5,Mann,Anglais
16,21,2,2024,2,0,none,_
16,21,2,2024,2,0,none,_
16,21,2,2024,2,0,none,_
17,21,2,2024,1,4,Poupy,Physique
17,21,2,2024,1,7,Mann,Anglais
18,21,2,2024,1,8,Poupy,Physique
14,22,2,2024,1,9,Belaggoune,Anglais
15,22,2,2024,1,15,Belaggoune,Anglais
18,22,2,2024,1,5,Rapin,Maths
18,22,2,2024,1,0,none,_
16,23,2,2024,1,6,Chibani,Physique
17,23,2,2024,1,4,Oubaha,Maths
18,23,2,2024,1,10,Oubaha,Maths
12,26,2,2024,1,9,Chevalier,Physique
13,26,2,2024,1,6,Herbaut,Anglais
14,27,2,2024,1,7,Chevalier,Physique
14,27,2,2024,1,14,Belaggoune,Anglais
14,27,2,2024,1,7,Mullaert,Maths
17,27,2,2024,1,11,Chevalier,Physique
17,27,2,2024,1,13,Colin,Physique
18,27,2,2024,1,3,Rapin,Maths
13,28,2,2024,1,10,Carpintero,Maths
14,28,2,2024,1,2,Le_Gouriellec,Anglais
14,28,2,2024,1,11,Carpintero,Maths
14,28,2,2024,1,13,Bouverot,Maths
14,28,2,2024,1,6,Boully,Maths
14,28,2,2024,2,0,none,_
14,28,2,2024,2,0,none,_
14,28,2,2024,2,0,none,_
15,28,2,2024,1,4,Le_Gouriellec,Anglais
15,28,2,2024,1,5,Boully,Maths
15,28,2,2024,1,14,Bouverot,Maths
16,28,2,2024,1,8,Mann,Anglais
16,28,2,2024,2,0,none,_
16,28,2,2024,2,0,none,_
16,28,2,2024,2,0,none,_
17,28,2,2024,1,1,Poupy,Physique
17,28,2,2024,1,10,Mann,Anglais
18,28,2,2024,1,3,Poupy,Physique
14,29,2,2024,1,12,Belaggoune,Anglais
15,29,2,2024,1,0,none,_
18,29,2,2024,1,1,Rapin,Maths
18,29,2,2024,1,0,none,_
16,1,3,2024,1,5,Chibani,Physique
17,1,3,2024,1,2,Oubaha,Maths
18,1,3,2024,1,9,Oubaha,Maths
12,4,3,2024,1,8,Chevalier,Physique
13,4,3,2024,1,3,Herbaut,Anglais
14,5,3,2024,1,5,Belaggoune,Anglais
14,5,3,2024,1,10,Mullaert,Maths
14,5,3,2024,1,10,Chevalier,Physique
17,5,3,2024,1,12,Colin,Physique
17,5,3,2024,1,14,Chevalier,Physique
18,5,3,2024,1,11,Rapin,Maths
13,6,3,2024,1,14,Carpintero,Maths
14,6,3,2024,1,12,Boully,Maths
14,6,3,2024,1,6,Bouverot,Maths
14,6,3,2024,1,7,Le_Gouriellec,Anglais
14,6,3,2024,1,8,Carpintero,Maths
14,6,3,2024,2,0,none,_
14,6,3,2024,2,0,none,_
14,6,3,2024,2,0,none,_
15,6,3,2024,1,2,Boully,Maths
15,6,3,2024,1,9,Le_Gouriellec,Anglais
15,6,3,2024,1,15,Bouverot,Maths
16,6,3,2024,1,11,Mann,Anglais
16,6,3,2024,2,0,none,_
16,6,3,2024,2,0,none,_
16,6,3,2024,2,0,none,_
17,6,3,2024,1,13,Mann,Anglais
17,6,3,2024,1,4,Poupy,Physique
18,6,3,2024,1,6,Poupy,Physique
14,7,3,2024,1,1,Belaggoune,Anglais
15,7,3,2024,1,15,Belaggoune,Anglais
18,7,3,2024,1,0,none,_
18,7,3,2024,1,3,Rapin,Maths
16,8,3,2024,1,2,Chibani,Physique
17,8,3,2024,1,4,Oubaha,Maths
18,8,3,2024,1,7,Oubaha,Maths
12,11,3,2024,1,7,Chevalier,Physique
13,11,3,2024,1,2,Herbaut,Anglais
14,12,3,2024,1,1,Mullaert,Maths
14,12,3,2024,1,9,Chevalier,Physique
14,12,3,2024,1,4,Belaggoune,Anglais
17,12,3,2024,1,11,Colin,Physique
17,12,3,2024,1,13,Chevalier,Physique
18,12,3,2024,1,7,Rapin,Maths
13,13,3,2024,1,8,Carpintero,Maths
14,13,3,2024,1,6,Le_Gouriellec,Anglais
14,13,3,2024,1,9,Bouverot,Maths
14,13,3,2024,1,13,Carpintero,Maths
14,13,3,2024,1,5,Boully,Maths
14,13,3,2024,2,0,none,_
14,13,3,2024,2,0,none,_
14,13,3,2024,2,0,none,_
15,13,3,2024,1,8,Le_Gouriellec,Anglais
15,13,3,2024,1,11,Bouverot,Maths
15,13,3,2024,1,12,Boully,Maths
16,13,3,2024,1,10,Mann,Anglais
16,13,3,2024,2,0,none,_
16,13,3,2024,2,0,none,_
16,13,3,2024,2,0,none,_
17,13,3,2024,1,1,Poupy,Physique
17,13,3,2024,1,12,Mann,Anglais
18,13,3,2024,1,3,Poupy,Physique
14,14,3,2024,1,0,none,_
15,14,3,2024,1,14,Belaggoune,Anglais
18,14,3,2024,1,15,Rapin,Maths
18,14,3,2024,1,0,none,_
16,15,3,2024,1,5,Chibani,Physique
17,15,3,2024,1,3,Oubaha,Maths
18,15,3,2024,1,4,Oubaha,Maths
1 hour day month year length group colleur matiere
2 12 5 2 2024 1 2 Chevalier Physique
3 13 5 2 2024 1 13 Herbaut Anglais
4 14 6 2 2024 1 6 Mullaert Maths
5 14 6 2 2024 1 4 Chevalier Physique
6 14 6 2 2024 1 15 Belaggoune Anglais
7 17 6 2 2024 1 10 Colin Physique
8 17 6 2 2024 1 14 Chevalier Physique
9 18 6 2 2024 1 7 Rapin Maths
10 13 7 2 2024 1 10 Carpintero Maths
11 14 7 2 2024 1 5 Le_Gouriellec Anglais
12 14 7 2 2024 1 12 Carpintero Maths
13 14 7 2 2024 1 14 Boully Maths
14 14 7 2 2024 1 15 Bouverot Maths
15 14 7 2 2024 2 0 none _
16 14 7 2 2024 2 0 none _
17 14 7 2 2024 2 0 none _
18 15 7 2 2024 1 4 Bouverot Maths
19 15 7 2 2024 1 7 Le_Gouriellec Anglais
20 15 7 2 2024 1 11 Boully Maths
21 16 7 2 2024 1 9 Mann Anglais
22 16 7 2 2024 2 0 none _
23 16 7 2 2024 2 0 none _
24 16 7 2 2024 2 0 none _
25 17 7 2 2024 1 3 Mann Anglais
26 17 7 2 2024 1 6 Poupy Physique
27 18 7 2 2024 1 8 Poupy Physique
28 14 8 2 2024 1 1 Belaggoune Anglais
29 15 8 2 2024 1 11 Belaggoune Anglais
30 18 8 2 2024 1 2 Rapin Maths
31 18 8 2 2024 1 0 none _
32 16 9 2 2024 1 12 Chibani Physique
33 17 9 2 2024 1 8 Oubaha Maths
34 18 9 2 2024 1 3 Oubaha Maths
35 12 12 2 2024 1 1 Chevalier Physique
36 13 12 2 2024 1 14 Herbaut Anglais
37 14 13 2 2024 1 1 Mullaert Maths
38 14 13 2 2024 1 5 Chevalier Physique
39 14 13 2 2024 1 0 none _
40 17 13 2 2024 1 7 Colin Physique
41 17 13 2 2024 1 9 Chevalier Physique
42 18 13 2 2024 1 4 Rapin Maths
43 13 14 2 2024 1 7 Carpintero Maths
44 14 14 2 2024 1 2 Le_Gouriellec Anglais
45 14 14 2 2024 1 13 Carpintero Maths
46 14 14 2 2024 1 3 Bouverot Maths
47 14 14 2 2024 1 5 Boully Maths
48 14 14 2 2024 2 0 none _
49 14 14 2 2024 2 0 none _
50 14 14 2 2024 2 0 none _
51 15 14 2 2024 1 4 Le_Gouriellec Anglais
52 15 14 2 2024 1 9 Bouverot Maths
53 15 14 2 2024 1 12 Boully Maths
54 16 14 2 2024 1 6 Mann Anglais
55 16 14 2 2024 2 0 none _
56 16 14 2 2024 2 0 none _
57 16 14 2 2024 2 0 none _
58 17 14 2 2024 1 8 Mann Anglais
59 17 14 2 2024 1 11 Poupy Physique
60 18 14 2 2024 1 13 Poupy Physique
61 14 15 2 2024 1 10 Belaggoune Anglais
62 15 15 2 2024 1 12 Belaggoune Anglais
63 18 15 2 2024 1 0 none _
64 18 15 2 2024 1 8 Rapin Maths
65 16 16 2 2024 1 3 Chibani Physique
66 17 16 2 2024 1 11 Oubaha Maths
67 18 16 2 2024 1 15 Oubaha Maths
68 12 19 2 2024 1 2 Chevalier Physique
69 13 19 2 2024 1 11 Herbaut Anglais
70 14 20 2 2024 1 2 Mullaert Maths
71 14 20 2 2024 1 10 Chevalier Physique
72 14 20 2 2024 1 13 Belaggoune Anglais
73 17 20 2 2024 1 12 Chevalier Physique
74 17 20 2 2024 1 14 Colin Physique
75 18 20 2 2024 1 1 Rapin Maths
76 13 21 2 2024 1 8 Carpintero Maths
77 14 21 2 2024 1 3 Le_Gouriellec Anglais
78 14 21 2 2024 1 12 Carpintero Maths
79 14 21 2 2024 1 14 Bouverot Maths
80 14 21 2 2024 1 9 Boully Maths
81 14 21 2 2024 2 0 none _
82 14 21 2 2024 2 0 none _
83 14 21 2 2024 2 0 none _
84 15 21 2 2024 1 1 Le_Gouriellec Anglais
85 15 21 2 2024 1 13 Bouverot Maths
86 15 21 2 2024 1 6 Boully Maths
87 16 21 2 2024 1 5 Mann Anglais
88 16 21 2 2024 2 0 none _
89 16 21 2 2024 2 0 none _
90 16 21 2 2024 2 0 none _
91 17 21 2 2024 1 4 Poupy Physique
92 17 21 2 2024 1 7 Mann Anglais
93 18 21 2 2024 1 8 Poupy Physique
94 14 22 2 2024 1 9 Belaggoune Anglais
95 15 22 2 2024 1 15 Belaggoune Anglais
96 18 22 2 2024 1 5 Rapin Maths
97 18 22 2 2024 1 0 none _
98 16 23 2 2024 1 6 Chibani Physique
99 17 23 2 2024 1 4 Oubaha Maths
100 18 23 2 2024 1 10 Oubaha Maths
101 12 26 2 2024 1 9 Chevalier Physique
102 13 26 2 2024 1 6 Herbaut Anglais
103 14 27 2 2024 1 7 Chevalier Physique
104 14 27 2 2024 1 14 Belaggoune Anglais
105 14 27 2 2024 1 7 Mullaert Maths
106 17 27 2 2024 1 11 Chevalier Physique
107 17 27 2 2024 1 13 Colin Physique
108 18 27 2 2024 1 3 Rapin Maths
109 13 28 2 2024 1 10 Carpintero Maths
110 14 28 2 2024 1 2 Le_Gouriellec Anglais
111 14 28 2 2024 1 11 Carpintero Maths
112 14 28 2 2024 1 13 Bouverot Maths
113 14 28 2 2024 1 6 Boully Maths
114 14 28 2 2024 2 0 none _
115 14 28 2 2024 2 0 none _
116 14 28 2 2024 2 0 none _
117 15 28 2 2024 1 4 Le_Gouriellec Anglais
118 15 28 2 2024 1 5 Boully Maths
119 15 28 2 2024 1 14 Bouverot Maths
120 16 28 2 2024 1 8 Mann Anglais
121 16 28 2 2024 2 0 none _
122 16 28 2 2024 2 0 none _
123 16 28 2 2024 2 0 none _
124 17 28 2 2024 1 1 Poupy Physique
125 17 28 2 2024 1 10 Mann Anglais
126 18 28 2 2024 1 3 Poupy Physique
127 14 29 2 2024 1 12 Belaggoune Anglais
128 15 29 2 2024 1 0 none _
129 18 29 2 2024 1 1 Rapin Maths
130 18 29 2 2024 1 0 none _
131 16 1 3 2024 1 5 Chibani Physique
132 17 1 3 2024 1 2 Oubaha Maths
133 18 1 3 2024 1 9 Oubaha Maths
134 12 4 3 2024 1 8 Chevalier Physique
135 13 4 3 2024 1 3 Herbaut Anglais
136 14 5 3 2024 1 5 Belaggoune Anglais
137 14 5 3 2024 1 10 Mullaert Maths
138 14 5 3 2024 1 10 Chevalier Physique
139 17 5 3 2024 1 12 Colin Physique
140 17 5 3 2024 1 14 Chevalier Physique
141 18 5 3 2024 1 11 Rapin Maths
142 13 6 3 2024 1 14 Carpintero Maths
143 14 6 3 2024 1 12 Boully Maths
144 14 6 3 2024 1 6 Bouverot Maths
145 14 6 3 2024 1 7 Le_Gouriellec Anglais
146 14 6 3 2024 1 8 Carpintero Maths
147 14 6 3 2024 2 0 none _
148 14 6 3 2024 2 0 none _
149 14 6 3 2024 2 0 none _
150 15 6 3 2024 1 2 Boully Maths
151 15 6 3 2024 1 9 Le_Gouriellec Anglais
152 15 6 3 2024 1 15 Bouverot Maths
153 16 6 3 2024 1 11 Mann Anglais
154 16 6 3 2024 2 0 none _
155 16 6 3 2024 2 0 none _
156 16 6 3 2024 2 0 none _
157 17 6 3 2024 1 13 Mann Anglais
158 17 6 3 2024 1 4 Poupy Physique
159 18 6 3 2024 1 6 Poupy Physique
160 14 7 3 2024 1 1 Belaggoune Anglais
161 15 7 3 2024 1 15 Belaggoune Anglais
162 18 7 3 2024 1 0 none _
163 18 7 3 2024 1 3 Rapin Maths
164 16 8 3 2024 1 2 Chibani Physique
165 17 8 3 2024 1 4 Oubaha Maths
166 18 8 3 2024 1 7 Oubaha Maths
167 12 11 3 2024 1 7 Chevalier Physique
168 13 11 3 2024 1 2 Herbaut Anglais
169 14 12 3 2024 1 1 Mullaert Maths
170 14 12 3 2024 1 9 Chevalier Physique
171 14 12 3 2024 1 4 Belaggoune Anglais
172 17 12 3 2024 1 11 Colin Physique
173 17 12 3 2024 1 13 Chevalier Physique
174 18 12 3 2024 1 7 Rapin Maths
175 13 13 3 2024 1 8 Carpintero Maths
176 14 13 3 2024 1 6 Le_Gouriellec Anglais
177 14 13 3 2024 1 9 Bouverot Maths
178 14 13 3 2024 1 13 Carpintero Maths
179 14 13 3 2024 1 5 Boully Maths
180 14 13 3 2024 2 0 none _
181 14 13 3 2024 2 0 none _
182 14 13 3 2024 2 0 none _
183 15 13 3 2024 1 8 Le_Gouriellec Anglais
184 15 13 3 2024 1 11 Bouverot Maths
185 15 13 3 2024 1 12 Boully Maths
186 16 13 3 2024 1 10 Mann Anglais
187 16 13 3 2024 2 0 none _
188 16 13 3 2024 2 0 none _
189 16 13 3 2024 2 0 none _
190 17 13 3 2024 1 1 Poupy Physique
191 17 13 3 2024 1 12 Mann Anglais
192 18 13 3 2024 1 3 Poupy Physique
193 14 14 3 2024 1 0 none _
194 15 14 3 2024 1 14 Belaggoune Anglais
195 18 14 3 2024 1 15 Rapin Maths
196 18 14 3 2024 1 0 none _
197 16 15 3 2024 1 5 Chibani Physique
198 17 15 3 2024 1 3 Oubaha Maths
199 18 15 3 2024 1 4 Oubaha Maths

View File

@ -1,6 +1,6 @@
from datetime import date, timedelta
from colloscope.models import Etudiant, Critere, Classe, Rotation, Periode, Creneau
from colloscope.models import *
from fpdf import FPDF
from fpdf.fonts import FontFace
@ -106,10 +106,10 @@ class PDF(FPDF):
row.cell("??") # LV2
def table_colloscope(self, periode):
def table_colloscope(self, periode, heading=True, est_colle=True):
semaines = periode.range_semaines()
lundis = [ periode.date_debut_sem(n) for n in semaines ]
creneaux = Creneau.objects.filter(periode=periode)
creneaux = Creneau.objects.filter(periode=periode, est_colle=est_colle)
jours = ["dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"]
with self.table(
@ -117,8 +117,10 @@ class PDF(FPDF):
width=190,
line_height=3,
col_widths=(2, 1, 1, 3, 1, *(1,)*len(semaines)),
num_heading_rows=2) as table:
num_heading_rows=2 if heading else 0,
first_row_as_headings=heading) as table:
if heading:
header = table.row()
for th in ("Matière", "Jour", "Heure", "Colleur", "Salle"):
header.cell(th, align="CENTER", rowspan=2)
@ -147,29 +149,15 @@ class PDF(FPDF):
for s in semaines:
if Rotation.objects.filter(creneau=c, semaine=s).exists():
rot = Rotation.objects.get(creneau=c, semaine=s)
groupes = rot.groupes
row.cell(", ".join(g.libelle for g in groupes.all()), align="CENTER")
r = Rotation.objects.get(creneau=c, semaine=s)
groupes = r.groupes
content = ", ".join(g.libelle for g in groupes.all())
with self.local_context(fill_color=(255, 100, 100) if r.est_modifiee() else None):
row.cell(content, align="CENTER")
else:
row.cell()
def table_travaux(self):
with self.table(
align="LEFT",
width=190,
line_height=3,
col_widths=(2, 1, 1, 4, *(1,)*len(semaines)),
first_row_as_headings=False) as table:
row = table.row()
row.cell("TP Physique")
row.cell("lundi")
row.cell("8:30")
row.cell()
for _ in range(len(semaines)):
row.cell("9 à 15", align="CENTER")
def generate(periode):
classe = periode.classe
@ -189,13 +177,16 @@ def generate(periode):
pdf.liste_eleves(periode)
pdf.set_y(base_y)
pdf.table_colloscope(periode)
#pdf.y += 3
#pdf.table_travaux()
pdf.y += 3
pdf.table_colloscope(periode, heading=False, est_colle=False)
pdf.output("test.pdf")
if __name__ == "__main__":
def main():
classe = Classe.objects.get(id=1)
periode = Periode.objects.get(classe=classe, libelle="Semestre 5/2")
generate(periode)
if __name__ == "__main__":
main()

BIN
test.pdf

Binary file not shown.