diff options
author | Alban Gruin | 2017-02-03 10:43:13 +0100 |
---|---|---|
committer | Alban Gruin | 2017-02-03 10:43:13 +0100 |
commit | 8861bddccf458846e12e679704a8514ec2dc2510 (patch) | |
tree | feaf18628e54a71a475fc73f363adf107ffe07f6 /models.py | |
parent | bfa5715f6deaa71ad51811bd2f59cdd330b860d9 (diff) |
Ajout d'un système de renommage de groupe à la volée pour corriger les défauts de nom de la sourcev0.3.0
Diffstat (limited to 'models.py')
-rw-r--r-- | models.py | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -39,6 +39,7 @@ class LastUpdate(models.Model): class Group(models.Model): 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") mention = models.CharField(max_length=32) @@ -69,13 +70,16 @@ class Group(models.Model): except: print("Malformed name: {0}. Ignoring".format(self.name)) finally: + if self.name is None: + self.name = self.celcat_name + self.slug = slugify(self.name) super(Group, self).save() class Meta: index_together = ("mention", "subgroup", "td", "tp",) - unique_together = ("name", "timetable",) + unique_together = (("name", "timetable",), ("celcat_name", "timetable",),) verbose_name = "groupe" verbose_name_plural = "groupes" |