From 1fd2062ca3fe15bf3442114ca45127e26d9566b7 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Thu, 9 Feb 2017 10:50:51 +0100 Subject: Amélioration des modèles --- models.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/models.py b/models.py index af136af..bc0ec2d 100644 --- a/models.py +++ b/models.py @@ -34,6 +34,9 @@ class LastUpdate(models.Model): year = models.IntegerField(verbose_name="année") date = models.DateTimeField(verbose_name="date de mise à jour") + def __str__(self): + return "{0}, semaine {1} de {2}".format(self.timetable.name, self.week, self.year) + class Meta: unique_together = ("timetable", "week", "year",) @@ -57,7 +60,7 @@ class Group(models.Model): return self.timetable.id == timetable_id and self.mention == mention and self.subgroup == subgroup and (self.td == td or self.td is None or td is None) and (self.tp == tp or self.tp is None or tp is None) def __str__(self): - return self.name + return "{0} - {1}".format(self.timetable.name, self.name) def save(self): try: @@ -95,6 +98,9 @@ class Subscription(models.Model): active = models.BooleanField(verbose_name="activé", default=False, db_index=True) token = models.CharField(max_length=64, unique=True, default="") + def __str__(self): + return "{0} - {1}".format(self.email, self.group) + def save(self): if self.token == "": self.token = hashlib.sha1(os.urandom(128)).hexdigest() @@ -154,6 +160,10 @@ class Course(models.Model): def __str__(self): return self.name + def save(self): + self.type_.replace("COURS", "Cours") + super(Course, self).save() + class Meta: verbose_name = "cours" -- cgit v1.2.1