From 108adbbafca33d8b02dc4d447f324dd243ff0969 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sun, 9 Feb 2025 10:47:40 +0100 Subject: [PATCH] personal: Move Group class definition before Contact We want to reference Group from Contact in the following commit, so move the class in the source file. --- mpicms/personal/models.py | 55 ++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/mpicms/personal/models.py b/mpicms/personal/models.py index 22cbf63..d43cab3 100644 --- a/mpicms/personal/models.py +++ b/mpicms/personal/models.py @@ -91,6 +91,34 @@ def __str__(self): class Meta: ordering = ["title"] + +@register_snippet +class Group(index.Indexed, ClusterableModel): + slug = models.CharField(_("slug"), max_length=254) + name = models.CharField(_("name"), max_length=254, blank=True) + priority = models.PositiveSmallIntegerField( + _("priority"), blank=True, default=0, validators=[MaxValueValidator(99)], + help_text=_("Priority from 0-99 to determine the sorting order.")) + + panels = [ + FieldPanel('name'), + FieldPanel('priority'), + ] + + search_fields = [ + index.SearchField('name', partial_match=True), + index.SearchField('slug'), + ] + + def __str__(self): + return self.name or self.slug + + class Meta: # noqa + verbose_name = 'Group' + verbose_name_plural = 'Groups' + ordering = ['name'] + + @register_snippet class Contact(index.Indexed, ClusterableModel): """ @@ -168,33 +196,6 @@ class Meta: # noqa ordering = ['last_name'] -@register_snippet -class Group(index.Indexed, ClusterableModel): - slug = models.CharField(_("slug"), max_length=254) - name = models.CharField(_("name"), max_length=254, blank=True) - priority = models.PositiveSmallIntegerField( - _("priority"), blank=True, default=0, validators=[MaxValueValidator(99)], - help_text=_("Priority from 0-99 to determine the sorting order.")) - - panels = [ - FieldPanel('name'), - FieldPanel('priority'), - ] - - search_fields = [ - index.SearchField('name', partial_match=True), - index.SearchField('slug'), - ] - - def __str__(self): - return self.name or self.slug - - class Meta: # noqa - verbose_name = 'Group' - verbose_name_plural = 'Groups' - ordering = ['name'] - - class WrittenConsent(models.Model): ref = models.CharField("ID", max_length=10, unique=True) comment = models.TextField("comment", blank=True)