Skip to content
Snippets Groups Projects
Commit 14be2006 authored by Hangzhi Yu's avatar Hangzhi Yu
Browse files

Use enum for lesson event alarm status choices

parent 4ddbc01e
No related branches found
No related tags found
1 merge request!360Resolve "Reimplement notification system on base of new calendar system"
Pipeline #194731 failed
......@@ -509,10 +509,13 @@ def create_alarm_on_teachers_m2m_changed(
class LessonEventAlarm(CalendarAlarm):
"""Alarm model for lesson events."""
STATUS_CHOICES = {"c": _("Created"), "e": _("Edited"), "d": _("Deleted")}
class StatusChoices(models.TextChoices):
CREATED = "C", _("Created")
EDITED = "E", _("Edited")
DELETED = "D", _("Deleted")
status = models.CharField(
verbose_name=_("Status"), max_length=1, choices=STATUS_CHOICES, default="c"
verbose_name=_("Status"), max_length=1, choices=StatusChoices, default=StatusChoices.CREATED
)
def value_description(self, request: HttpRequest | None = None) -> str:
......@@ -542,14 +545,14 @@ class LessonEventAlarm(CalendarAlarm):
{
"event": self.event,
"event_title": LessonEvent.value_title(self.event, request),
"status": self.STATUS_CHOICES[self.status].lower(),
"status": StatusChoices(self.status).label.lower(),
},
)
def value_notification_description(self, request: HttpRequest | None = None) -> str:
return render_to_string(
"chronos/lesson_event_notification_description.txt",
{"event": self.event, "status": self.STATUS_CHOICES[self.status].lower()},
{"event": self.event, "status": StatusChoices(self.status).label.lower()},
)
def value_notification_icon(self, request: HttpRequest | None = None) -> str:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment