Skip to content

Commit

Permalink
Improve Organization admin interface
Browse files Browse the repository at this point in the history
  • Loading branch information
tudoramariei committed Oct 21, 2024
1 parent cda9a2d commit d109b49
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 6 deletions.
65 changes: 64 additions & 1 deletion backend/hub/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,79 @@ 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

inlines = (OrganizationUsersInline,)

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

Expand Down
11 changes: 6 additions & 5 deletions backend/hub/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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="")
Expand Down

0 comments on commit d109b49

Please sign in to comment.