aboutsummaryrefslogtreecommitdiff
path: root/models.py
diff options
context:
space:
mode:
authorAlban Gruin2017-01-19 14:55:16 +0100
committerAlban Gruin2017-01-19 14:55:16 +0100
commiteea8dd99b859943d441e36b4958ce7bf61a27e8f (patch)
tree3e1a70ecfb6d2a6ba6a1a29d5284a0fdae1d7f21 /models.py
parentffa4f692a6b205de7b677502e1d3f6513bedfa93 (diff)
Gestion des erreurs
Diffstat (limited to 'models.py')
-rw-r--r--models.py27
1 files changed, 15 insertions, 12 deletions
diff --git a/models.py b/models.py
index 6e0774f..106e3f7 100644
--- a/models.py
+++ b/models.py
@@ -28,18 +28,21 @@ class Group(models.Model):
return self.name
def save(self):
- parts = self.name.split("-")[-2:]
- group = parts[1].strip()[2:]
-
- self.mention = parts[0].strip()
- self.subgroup = group[0]
-
- if len(group) > 1:
- self.td = int(group[1])
- if len(group) > 2:
- self.tp = int(group[2])
-
- super(Group, self).save()
+ try:
+ parts = self.name.split("-")[-2:]
+ group = parts[1].strip()[2:]
+
+ self.mention = parts[0].strip()
+ self.subgroup = group[0]
+
+ if len(group) > 1:
+ self.td = int(group[1])
+ if len(group) > 2:
+ self.tp = int(group[2])
+ except:
+ print("Malformed name: {0}. Ignoring".format(self.name))
+ finally:
+ super(Group, self).save()
class Meta: