From 0e2b904ff25915b9696cbfc64faab1d566362097 Mon Sep 17 00:00:00 2001 From: Carissa Knipe Date: Thu, 8 Aug 2024 11:50:22 -0700 Subject: [PATCH 1/2] feat: Add project names to membership list displays in django admin panel --- terraso_backend/apps/collaboration/admin.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/terraso_backend/apps/collaboration/admin.py b/terraso_backend/apps/collaboration/admin.py index 1086cc3a1..f5aec99d5 100644 --- a/terraso_backend/apps/collaboration/admin.py +++ b/terraso_backend/apps/collaboration/admin.py @@ -24,10 +24,21 @@ class MembershipInline(admin.TabularInline): @admin.register(MembershipList) class MembershipListAdmin(admin.ModelAdmin): - list_display = ("id", "created_at") + list_display = ("project", "id", "created_at") inlines = [MembershipInline] @admin.register(Membership) class MembershipAdmin(admin.ModelAdmin): - list_display = ("user", "membership_list", "user_role", "membership_status", "created_at") + @admin.display(ordering="membership_list__project") + def project(self, obj): + return obj.membership_list.project + + list_display = ( + "user", + "project", + "user_role", + "membership_status", + "membership_list", + "created_at", + ) From 7557974bb70dd443acff62c669d2317908050053 Mon Sep 17 00:00:00 2001 From: Carissa Knipe Date: Thu, 8 Aug 2024 12:51:40 -0700 Subject: [PATCH 2/2] feat: Add search functionality to soil id site list --- terraso_backend/apps/collaboration/admin.py | 6 ++++-- terraso_backend/apps/soil_id/admin.py | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/terraso_backend/apps/collaboration/admin.py b/terraso_backend/apps/collaboration/admin.py index f5aec99d5..8446fb8c2 100644 --- a/terraso_backend/apps/collaboration/admin.py +++ b/terraso_backend/apps/collaboration/admin.py @@ -26,6 +26,7 @@ class MembershipInline(admin.TabularInline): class MembershipListAdmin(admin.ModelAdmin): list_display = ("project", "id", "created_at") inlines = [MembershipInline] + search_fields = ["project__name"] @admin.register(Membership) @@ -34,11 +35,12 @@ class MembershipAdmin(admin.ModelAdmin): def project(self, obj): return obj.membership_list.project - list_display = ( + list_display = [ "user", "project", "user_role", "membership_status", "membership_list", "created_at", - ) + ] + search_fields = ["user__email", "membership_list__project__name"] diff --git a/terraso_backend/apps/soil_id/admin.py b/terraso_backend/apps/soil_id/admin.py index bda1492c5..f4b520e49 100644 --- a/terraso_backend/apps/soil_id/admin.py +++ b/terraso_backend/apps/soil_id/admin.py @@ -42,6 +42,7 @@ class ProjectSoilSettingsAdmin(admin.ModelAdmin): inlines = [ ProjectDepthIntervalInline, ] + search_fields = ["project__name"] @admin.register(SoilData) @@ -58,7 +59,8 @@ def site_owner(self, obj): def project(self, obj): return obj.site.project.name if obj.site.project is not None else None - list_display = ("site_name", "project", "site_owner", "depth_interval_preset") + list_display = ["site_name", "project", "site_owner", "depth_interval_preset"] + search_fields = ["site__name", "site__project__name"] inlines = [ DepthDependentSoilDataInline, SoilDataDepthIntervalInline,