From 98abe82b1d592960527893857b141f1872fdf594 Mon Sep 17 00:00:00 2001 From: PCoder Date: Tue, 4 Jan 2022 22:57:56 +0530 Subject: [PATCH 1/2] Use autocomplete fields for looking up organization --- app/admin.py | 9 ++++++--- app/models.py | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/admin.py b/app/admin.py index 25ec099..34589ae 100644 --- a/app/admin.py +++ b/app/admin.py @@ -58,7 +58,8 @@ class PersonAdmin(admin.ModelAdmin): ), }), ) - list_display = ['id', 'full_name' ] + list_display = ['id', 'full_name', 'organization'] + autocomplete_fields = ['organization'] # list_display_links = ['id'] @@ -86,6 +87,7 @@ class ResourceAdmin(admin.ModelAdmin): search_fields = ['title', 'url', 'citation', 'abstract'] readonly_fields = ['id'] list_display = ['title', 'citation', 'type'] + ordering = ['title'] fieldsets = ( (None, { 'fields': ( @@ -162,7 +164,8 @@ class RangeAdmin(admin.ModelAdmin): 'fields': ('comments',), }) ) - list_display = ['range_name', 'countries', 'mother_range'] + list_display = ['range_name', 'mother_range', 'countries'] + ordering = ['range_name'] class PeopleOrganizationInline(admin.TabularInline): @@ -177,7 +180,7 @@ class OrganizationAdmin(admin.ModelAdmin): ] readonly_fields = ('org_num1',) search_fields = ['organisation_search', 'org_alpha_search', 'organisation_2', 'organisation_3', 'subject'] - list_display = ['organisation_english', 'organisation_2'] + list_display = ['organisation_english', 'organisation_2', 'country'] fieldsets = ( (None, { 'fields': ( diff --git a/app/models.py b/app/models.py index fd1458d..4980def 100644 --- a/app/models.py +++ b/app/models.py @@ -428,7 +428,7 @@ class Organisation(models.Model): else: name = f"{self.organisation_english}" else: - name = 'NO NAME DEFINED!!!' + name = '---' return name From 7162dc6c8ce4773194351be74e9e26b018862b02 Mon Sep 17 00:00:00 2001 From: PCoder Date: Tue, 4 Jan 2022 23:02:09 +0530 Subject: [PATCH 2/2] Revert back changes from the other pull request --- app/admin.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/admin.py b/app/admin.py index 34589ae..8aa06f7 100644 --- a/app/admin.py +++ b/app/admin.py @@ -58,7 +58,7 @@ class PersonAdmin(admin.ModelAdmin): ), }), ) - list_display = ['id', 'full_name', 'organization'] + list_display = ['id', 'full_name' ] autocomplete_fields = ['organization'] # list_display_links = ['id'] @@ -87,7 +87,6 @@ class ResourceAdmin(admin.ModelAdmin): search_fields = ['title', 'url', 'citation', 'abstract'] readonly_fields = ['id'] list_display = ['title', 'citation', 'type'] - ordering = ['title'] fieldsets = ( (None, { 'fields': ( @@ -164,8 +163,7 @@ class RangeAdmin(admin.ModelAdmin): 'fields': ('comments',), }) ) - list_display = ['range_name', 'mother_range', 'countries'] - ordering = ['range_name'] + list_display = ['range_name', 'countries', 'mother_range'] class PeopleOrganizationInline(admin.TabularInline): @@ -180,7 +178,7 @@ class OrganizationAdmin(admin.ModelAdmin): ] readonly_fields = ('org_num1',) search_fields = ['organisation_search', 'org_alpha_search', 'organisation_2', 'organisation_3', 'subject'] - list_display = ['organisation_english', 'organisation_2', 'country'] + list_display = ['organisation_english', 'organisation_2'] fieldsets = ( (None, { 'fields': (