|
|
@ -17,7 +17,7 @@ class CalendarOccasions(models.Model): |
|
|
international = 'international', _('International') |
|
|
international = 'international', _('International') |
|
|
religious = 'religious', _('Religious') |
|
|
religious = 'religious', _('Religious') |
|
|
|
|
|
|
|
|
title = models.CharField(_("title"), max_length=255) |
|
|
|
|
|
|
|
|
title = models.JSONField(verbose_name=_("title"), default=list, blank=True) |
|
|
is_global = models.BooleanField( |
|
|
is_global = models.BooleanField( |
|
|
verbose_name=_('is global'), default=False, |
|
|
verbose_name=_('is global'), default=False, |
|
|
help_text=_('check this field if event is global'), |
|
|
help_text=_('check this field if event is global'), |
|
|
@ -43,6 +43,13 @@ class CalendarOccasions(models.Model): |
|
|
ordering = ('-updated_at',) |
|
|
ordering = ('-updated_at',) |
|
|
|
|
|
|
|
|
def __str__(self) -> str: |
|
|
def __str__(self) -> str: |
|
|
return self.title |
|
|
|
|
|
|
|
|
if isinstance(self.title, list) and len(self.title) > 0: |
|
|
|
|
|
for item in self.title: |
|
|
|
|
|
if isinstance(item, dict) and item.get("language_code") == "en": |
|
|
|
|
|
return item.get("title", "") |
|
|
|
|
|
return self.title[0].get("title", "") if isinstance(self.title[0], dict) else str(self.title[0]) |
|
|
|
|
|
elif isinstance(self.title, dict): |
|
|
|
|
|
return self.title.get("en", self.title.get("en", str(self.title))) |
|
|
|
|
|
return str(self.title) |
|
|
|
|
|
|
|
|
|
|
|
|