Add of some modifications in the weekmail model

This commit is contained in:
lsacienne 2022-09-25 22:55:39 +02:00
parent e868946fd7
commit f6ecbd899d
No known key found for this signature in database
GPG Key ID: CA170736C781D40B

View File

@ -61,6 +61,11 @@ NEWS_TYPES = [
("CALL", _("Call")),
]
WEEKMAIL_TYPE = [
("WEEKMAIL", _("Weekmail")),
("INVITATION", _("Invitation")),
]
class News(models.Model):
"""The news class"""
@ -178,6 +183,9 @@ class Weekmail(models.Model):
protip = models.TextField(_("protip"), blank=True)
conclusion = models.TextField(_("conclusion"), blank=True)
sent = models.BooleanField(_("sent"), default=False)
type = models.CharField(
_("type"), max_length=16, choices=WEEKMAIL_TYPE, default="WEEKMAIL"
)
class Meta:
ordering = ["-id"]
@ -215,6 +223,17 @@ class Weekmail(models.Model):
None, "com/weekmail_renderer_text.jinja", context={"weekmail": self}
).content.decode("utf-8")
def switch_type(self):
"""
Switch the type of weekmail we are sending :
- a simple weekmail
- or an invitation
"""
if self.type == "INVITATION":
self.type = "WEEKMAIL"
else:
self.type = "INVITATION"
def render_html(self):
"""
Renders an HTML version of the mail with images and fancy CSS.
@ -227,9 +246,14 @@ class Weekmail(models.Model):
"""
Return an absolute link to the banner.
"""
if self.type == "INVITATION":
return (
"http://" + settings.SITH_URL + static("com/img/invitation_bannerP22.png")
)
return (
"http://" + settings.SITH_URL + static("com/img/weekmail_bannerV2P22.png")
)
def get_footer(self):
"""