From d109b494e4bf6740361b61503a02c20229bcec73 Mon Sep 17 00:00:00 2001 From: Tudor Amariei Date: Mon, 21 Oct 2024 16:07:32 +0300 Subject: [PATCH] Improve Organization admin interface --- backend/hub/admin.py | 65 ++++++++++++++++++++++++++++++++++++++++++- backend/hub/models.py | 11 ++++---- 2 files changed, 70 insertions(+), 6 deletions(-) diff --git a/backend/hub/admin.py b/backend/hub/admin.py index 7f3b24c8..15cbc3a0 100644 --- a/backend/hub/admin.py +++ b/backend/hub/admin.py @@ -124,9 +124,16 @@ class OrganizationAdmin(admin.ModelAdmin): "status", "created", ) + list_display_links = ( + "name", + "city", + "legal_representative_name", + "status", + "created", + ) list_filter = ("status", ("county", CountyFilter)) search_fields = ("name", "legal_representative_name", "email") - readonly_fields = ["status_changed"] + readonly_fields = ["ngohub_org_id"] + list(Organization.ngohub_fields()) autocomplete_fields = ["city"] list_per_page = 20 @@ -134,6 +141,62 @@ class OrganizationAdmin(admin.ModelAdmin): actions = (update_organizations,) + fieldsets = ( + ( + _("Identification"), + { + "fields": ( + "status", + "ngohub_org_id", + "voting_domain", + ) + }, + ), + ( + _("Contact Information"), + { + "fields": ( + "email", + "phone", + "description", + "name", + "county", + "city", + "address", + "registration_number", + "board_council", + "logo", + ) + }, + ), + ( + _("Legal representative"), + { + "fields": ( + "legal_representative_name", + "legal_representative_email", + "legal_representative_phone", + ) + }, + ), + ( + _("Platform documents"), + { + "fields": ( + "last_balance_sheet", + "statute", + "statement_political", + "statement_discrimination", + "fiscal_certificate_anaf", + "fiscal_certificate_local", + "report_2023", + "report_2022", + "report_2021", + ) + }, + ), + ) + def has_add_permission(self, request): return False diff --git a/backend/hub/models.py b/backend/hub/models.py index 0be687b5..3c609bbe 100644 --- a/backend/hub/models.py +++ b/backend/hub/models.py @@ -227,11 +227,6 @@ class Organization(StatusModel, TimeStampedModel): ngohub_org_id = models.PositiveBigIntegerField(_("NGO Hub linked organization ID"), default=0, db_index=True) - name = models.CharField(_("NGO Name"), max_length=254, blank=True, default="") - county = models.CharField(_("County"), choices=COUNTY_CHOICES, max_length=50, blank=True, default="") - city = models.ForeignKey("City", verbose_name=_("City"), on_delete=models.PROTECT, null=True, blank=True) - address = models.CharField(_("Address"), max_length=254, blank=True, default="") - registration_number = models.CharField(_("Registration number"), max_length=20, blank=True, default="") voting_domain = models.ForeignKey( Domain, verbose_name=_("Voting domain"), @@ -245,6 +240,12 @@ class Organization(StatusModel, TimeStampedModel): ), ) + name = models.CharField(_("NGO Name"), max_length=254, blank=True, default="") + county = models.CharField(_("County"), choices=COUNTY_CHOICES, max_length=50, blank=True, default="") + city = models.ForeignKey("City", verbose_name=_("City"), on_delete=models.PROTECT, null=True, blank=True) + address = models.CharField(_("Address"), max_length=254, blank=True, default="") + registration_number = models.CharField(_("Registration number"), max_length=20, blank=True, default="") + email = models.EmailField(_("Organization Email"), blank=True, default="") phone = models.CharField(_("Organization Phone"), max_length=30, blank=True, default="") description = models.TextField(_("Short Description"), blank=True, default="")