aboutsummaryrefslogtreecommitdiff
path: root/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'models.py')
-rw-r--r--models.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/models.py b/models.py
index a2d4281..536c3b8 100644
--- a/models.py
+++ b/models.py
@@ -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"