optimize get url and get filename functions for agenda and protocol

This commit is contained in:
2024-01-24 01:15:11 +00:00
parent f58006f6c6
commit 803610ea5e

View File

@@ -197,28 +197,68 @@ class Post(models.Model):
) )
return value return value
@property _agenda_filename = None
def agenda_url(self): _agenda_url = "#"
if self.has_agenda:
return ep_get_url(self.agenda_key)
return "#"
@property @property
def protocol_url(self): def agenda_url(self):
if self.has_protocol: if self.has_agenda is not True:
return ep_get_url(self.protocol_key) self.a_url = "#"
return "#" self._agenda_filename = None
return self.a_url
if self._agenda_url != "#":
return self._agenda_url
if (url := ep_get_url(self.agenda_key)) != "#":
self._agenda_url = url
self._agenda_filename = self.slug + "-agenda.pdf"
else:
self._agenda_url = "#"
self._agenda_filename = None
return self._agenda_url
@property @property
def agenda_filename(self): def agenda_filename(self):
if self._agenda_filename is not None:
return self._agenda_filename
if self.has_agenda and self.agenda_url != "#": if self.has_agenda and self.agenda_url != "#":
return self.slug + "-agenda.pdf" return self.slug + "-agenda.pdf"
return None return None
_protocol_filename = None
_protocol_url = "#"
@property
def protocol_url(self):
if self.has_protocol is not True:
self._protocol_url = "#"
self._protocol_filename = None
return self._protocol_url
if self._protocol_url != "#":
return self._protocol_url
if (url := ep_get_url(self.protocol_key)) != "#":
self._protocol_url = url
self._protocol_filename = self.slug + "-agenda.pdf"
else:
self._protocol_url = "#"
self._protocol_filename = None
return self._protocol_url
@property @property
def protocol_filename(self): def protocol_filename(self):
if self._protocol_filename is not None:
return self._protocol_filename
if self.has_protocol and self.protocol_url != "#": if self.has_protocol and self.protocol_url != "#":
return self.slug + "-protokoll.pdf" return self.slug + "-protokoll.pdf"
return None return None
def create_agenda_key(self): def create_agenda_key(self):