aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--models.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/models.py b/models.py
index bc0ec2d..e4fe6d6 100644
--- a/models.py
+++ b/models.py
@@ -60,9 +60,9 @@ 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 "{0} - {1}".format(self.timetable.name, self.name)
+ return self.name
- def save(self):
+ def save(self, *args, **kwargs):
try:
parts = self.celcat_name.split("-")[-2:]
group = parts[1].strip()[2:]
@@ -101,10 +101,10 @@ class Subscription(models.Model):
def __str__(self):
return "{0} - {1}".format(self.email, self.group)
- def save(self):
+ def save(self, *args, **kwargs):
if self.token == "":
self.token = hashlib.sha1(os.urandom(128)).hexdigest()
- super(Subscription, self).save()
+ super(Subscription, self).save(*args, **kwargs)
class Meta:
@@ -160,9 +160,13 @@ class Course(models.Model):
def __str__(self):
return self.name
- def save(self):
- self.type_.replace("COURS", "Cours")
- super(Course, self).save()
+ def save(self, *args, **kwargs):
+ if self.type is not None:
+ self.type = self.type.replace("COURS", "cours")
+ if self.name is not None:
+ self.name = self.name.split("(")[0].strip()
+
+ super(Course, self).save(*args, **kwargs)
class Meta: