mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-29 12:34:21 +00:00
Add of some modifications in the weekmail model
This commit is contained in:
parent
e868946fd7
commit
f6ecbd899d
@ -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):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user