From dc0997c1197a2678011e39f0ffd6dbf8e2ecccf4 Mon Sep 17 00:00:00 2001 From: andis Date: Fri, 1 Jan 2021 12:22:28 +0000 Subject: [PATCH] defaults moved to save from clean + docstrings --- fet2020/posts/models.py | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/fet2020/posts/models.py b/fet2020/posts/models.py index 3acf3c31..6961f033 100644 --- a/fet2020/posts/models.py +++ b/fet2020/posts/models.py @@ -25,6 +25,8 @@ request_logger = logging.getLogger("django.request") def create_pad_for_post(slug, typ="agenda"): + "Creates a Etherpad Pad and returns EtherpadKey" + print("creatingpadforpost") try: agenda_key = createPadifNotExists(slug + "-" + typ) except URLError as error: @@ -117,6 +119,7 @@ class Post(models.Model): @property def agenda_html(self): + "Agenda HTML from Etherpad Pad" if not self.agenda_key: return None @@ -132,6 +135,7 @@ class Post(models.Model): return html @property def protocol_html(self): + "Protocol HTML from Etherpad Pad" if not self.protocol_key: return None @@ -191,13 +195,15 @@ class Post(models.Model): return value def get_agenda_key(self): - "Create a Etherpad Id for the Pad associated to this post. Creates the pad if it doesn't exist" + """Create a Etherpad Id for the Pad associated to this post. + Creates the pad if it doesn't exist""" if not self.slug: return None return create_pad_for_post(self.slug, typ="agenda") def get_protocol_key(self): - "Create a Etherpad Id for the Pad associated to this post. Creates the pad if it doesn't exist" + """Create a Etherpad Id for the Pad associated to this post. + Creates the pad if it doesn't exist""" if not self.slug: return None return create_pad_for_post(self.slug, typ="protocol") @@ -355,24 +361,19 @@ class FetMeeting(Event): # ) from error# # # return protocol_key - - def clean(self): - super().clean() - - if not self.slug: - self.slug = self.__get_slug() - - if self.has_agenda: - self.agenda_key = self.get_agenda_key() - - if self.has_protocol: - self.protocol_key = self.get_protocol_key() + + def save(self, *args, **kwargs): self.title = "Fachschaftssitzung" - - # TODO - # self.image + if not self.slug: + self.slug = self.__get_slug() + + self.has_agenda = True + self.has_protocol = True + + self.agenda_key = self.get_agenda_key() + self.protocol_key = self.get_protocol_key() if not self.post_type: self.post_type = "F"