aboutsummaryrefslogtreecommitdiff
path: root/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'models.py')
-rw-r--r--models.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/models.py b/models.py
index 876160b..53bcef7 100644
--- a/models.py
+++ b/models.py
@@ -56,7 +56,14 @@ class LastUpdate(models.Model):
verbose_name_plural = "dernières mises à jour"
+class GroupManager(Manager):
+ def get_relevant_groups(self):
+ return self.get_queryset().annotate(children_count=Count("children")).filter(children_count=0)
+
+
class Group(models.Model):
+ objects = GroupManager()
+
name = models.CharField(max_length=255, verbose_name="nom")
celcat_name = models.CharField(max_length=255, verbose_name="nom dans Celcat")
timetable = models.ForeignKey(Timetable, on_delete=models.CASCADE, verbose_name="emploi du temps")
@@ -65,6 +72,7 @@ class Group(models.Model):
subgroup = models.CharField(max_length=1, verbose_name="sous-groupe", null=True)
td = models.IntegerField(verbose_name="groupe de TD", null=True)
tp = models.IntegerField(verbose_name="groupe de TP", null=True)
+ parent_group = models.ForeignKey("self", verbose_name="groupe parent", null=True, default=None, related_name="children")
slug = models.SlugField(max_length=64, default="")