aboutsummaryrefslogtreecommitdiff
path: root/models.py
diff options
context:
space:
mode:
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: