aboutsummaryrefslogtreecommitdiff
path: root/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'models.py')
-rw-r--r--models.py22
1 files changed, 5 insertions, 17 deletions
diff --git a/models.py b/models.py
index 1e96a88..478b48f 100644
--- a/models.py
+++ b/models.py
@@ -20,6 +20,8 @@ from django.db.models.expressions import RawSQL
from django.db.models.functions import Extract, ExtractYear
from django.utils.text import slugify
+from .utils import parse_group
+
import hashlib
import os
@@ -81,23 +83,9 @@ class Group(models.Model):
return self.name
def save(self, *args, **kwargs):
- try:
- parts = self.celcat_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.celcat_name))
- finally:
- if self.name == "":
- self.name = self.celcat_name
-
+ self.mention, self.subgroup, self.td, self.tp = parse_group(self.celcat_name)
+ if self.name == "":
+ self.name = self.celcat_name
self.slug = slugify(self.name)
super(Group, self).save()