aboutsummaryrefslogtreecommitdiff
path: root/models.py
diff options
context:
space:
mode:
authorAlban Gruin2017-11-26 13:53:10 +0100
committerAlban Gruin2017-11-26 13:53:10 +0100
commitf8c7775aac4a7eb2a4430d1aabb20b7f29939af7 (patch)
tree60917fed5abffe076748181712734dd76cc28cae /models.py
parent0bdde723ebb571bb6f1a894fee710fae7abc270e (diff)
Ajout d’un nouveau champ de groupe : le semestre
Diffstat (limited to 'models.py')
-rw-r--r--models.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/models.py b/models.py
index b260275..abb00bf 100644
--- a/models.py
+++ b/models.py
@@ -78,7 +78,9 @@ class GroupManager(Manager):
[Q(subgroup=group.subgroup[:i])
for i in range(1, len(group.subgroup) + 1)])
- return self.get_queryset().filter(groups_criteria, mention=group.mention,
+ return self.get_queryset().filter(groups_criteria,
+ Q(semester=None) | Q(semester=group.semester),
+ mention=group.mention,
timetable=group.timetable)
@@ -92,6 +94,7 @@ class Group(models.Model):
verbose_name="emploi du temps")
mention = models.CharField(max_length=128)
+ semester = models.IntegerField(verbose_name="semestre", null=True)
subgroup = models.CharField(max_length=16, verbose_name="sous-groupe", default="")
slug = models.SlugField(max_length=64, default="")
@@ -103,6 +106,7 @@ class Group(models.Model):
if self.subgroup is not None and subgroup is not None:
subgroup_corresponds = self.subgroup.startswith(subgroup)
+ # TODO adapter pour semester
return (self.mention.startswith(mention) or \
mention.startswith(self.mention)) and \
subgroup_corresponds
@@ -119,7 +123,7 @@ class Group(models.Model):
self.name = self.celcat_name
self.slug = slugify(self.name)
- self.mention, self.subgroup = parse_group(self.name)
+ self.mention, self.semester, self.subgroup = parse_group(self.name)
if self.subgroup is None:
self.subgroup = ""
@@ -127,7 +131,7 @@ class Group(models.Model):
class Meta:
- index_together = ("mention", "subgroup",)
+ index_together = ("mention", "semester", "subgroup",)
unique_together = (("name", "timetable",),
("celcat_name", "timetable",),
("slug", "timetable",),)