defaults moved to save from clean + docstrings

This commit is contained in:
2021-01-01 12:22:28 +00:00
parent ac6f566b44
commit dc0997c119

View File

@@ -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")
@@ -356,23 +362,18 @@ class FetMeeting(Event):
#
# 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"
if not self.slug:
self.slug = self.__get_slug()
# TODO
# self.image
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"