aboutsummaryrefslogtreecommitdiff
path: root/models.py
diff options
context:
space:
mode:
authorAlban Gruin2017-02-28 13:30:03 +0100
committerAlban Gruin2017-02-28 13:30:03 +0100
commitce0ed9347adde9ca80c11efe79766c966d5749ba (patch)
treee371a2d06374efbad1c1c8a4558d92ee0a07c025 /models.py
parenta543aaa14957f390d2b640a264113b639c7d3194 (diff)
parent66be6f2e7a3c642fb3c69e7c2a70cc3f898d77ea (diff)
Merge branch 'stable/0.y.z' into prod/pa1ch/0.y.zv0.7.0-pa1ch
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()