defaults moved to save from clean + docstrings
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user