From e238c5fed3a6ee769dd41cf6f166a02247d45868 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sun, 28 Nov 2021 20:29:44 +0530 Subject: [PATCH] Organisation: Make things as described in #9945 --- app/admin.py | 10 ++- app/migrations/0043_auto_20211128_1458.py | 78 +++++++++++++++++++++++ app/models.py | 54 ++++++++++++---- 3 files changed, 127 insertions(+), 15 deletions(-) create mode 100644 app/migrations/0043_auto_20211128_1458.py diff --git a/app/admin.py b/app/admin.py index 94a1bea..095a4d4 100644 --- a/app/admin.py +++ b/app/admin.py @@ -160,8 +160,15 @@ class RangeAdmin(admin.ModelAdmin): list_display = ['range_name', 'countries', 'mother_range'] +class PeopleOrganizationInline(admin.TabularInline): + model = Person + + class OrganizationAdmin(admin.ModelAdmin): - readonly_fields = ('org_num1', 'org_url') + inlines = [ + PeopleOrganizationInline, + ] + readonly_fields = ('org_num1',) search_fields = ['organisation_search', 'org_alpha_search', 'organisation_2', 'organisation_3', 'subject'] list_display = ['organisation_english', 'country', 'city'] fieldsets = ( @@ -184,7 +191,6 @@ class OrganizationAdmin(admin.ModelAdmin): 'classes': ('collapse',), 'fields': (('tel', 'email'), 'url', - 'org_url', 'tags', ), }) diff --git a/app/migrations/0043_auto_20211128_1458.py b/app/migrations/0043_auto_20211128_1458.py new file mode 100644 index 0000000..ad20f6c --- /dev/null +++ b/app/migrations/0043_auto_20211128_1458.py @@ -0,0 +1,78 @@ +# Generated by Django 3.2.5 on 2021-11-28 14:58 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('app', '0042_rename_organization_organisation'), + ] + + operations = [ + migrations.AlterField( + model_name='organisation', + name='acronym', + field=models.CharField(blank=True, max_length=128, null=True), + ), + migrations.AlterField( + model_name='organisation', + name='city', + field=models.CharField(blank=True, max_length=64, null=True), + ), + migrations.AlterField( + model_name='organisation', + name='email', + field=models.EmailField(blank=True, max_length=254, null=True), + ), + migrations.AlterField( + model_name='organisation', + name='lat_long', + field=models.CharField(blank=True, max_length=128, null=True), + ), + migrations.AlterField( + model_name='organisation', + name='organisation_2', + field=models.CharField(blank=True, max_length=256, null=True), + ), + migrations.AlterField( + model_name='organisation', + name='organisation_3', + field=models.CharField(blank=True, max_length=256, null=True), + ), + migrations.AlterField( + model_name='organisation', + name='organisation_english', + field=models.CharField(blank=True, max_length=256, null=True), + ), + migrations.AlterField( + model_name='organisation', + name='po_box', + field=models.CharField(blank=True, max_length=128, null=True), + ), + migrations.AlterField( + model_name='organisation', + name='postcode', + field=models.CharField(blank=True, max_length=64, null=True), + ), + migrations.AlterField( + model_name='organisation', + name='street', + field=models.CharField(blank=True, max_length=256, null=True), + ), + migrations.AlterField( + model_name='organisation', + name='subject', + field=models.CharField(blank=True, choices=[('Other', 'Other'), ('Environment', 'Environment'), ('Ecology', 'Ecology'), ('Agriculture', 'Agriculture'), ('Botany', 'Botany'), ('Science and technology', 'Science and technology'), ('Biodiversity', 'Biodiversity'), ('Climate / Global Change', 'Climate / Global Change'), ('Mountains', 'Mountains'), ('Biology', 'Biology'), ('Forestry', 'Forestry'), ('Conservation', 'Conservation'), ('Culture / arts', 'Culture / arts'), ('Geography', 'Geography'), ('Zoology', 'Zoology'), ('Development / poverty / human rights', 'Development / poverty / human rights'), ('Social Sciences', 'Social Sciences'), ('Earth Sciences', 'Earth Sciences'), ('Health', 'Health'), ('Hydrology / Water', 'Hydrology / Water'), ('Sustainability', 'Sustainability'), ('Economy / finance', 'Economy / finance'), ('Natural Resources', 'Natural Resources'), ('Education', 'Education'), ('Architecture, planning & design', 'Architecture, planning & design'), ('', '')], max_length=128, null=True), + ), + migrations.AlterField( + model_name='organisation', + name='tel', + field=models.CharField(blank=True, max_length=128, null=True), + ), + migrations.AlterField( + model_name='organisation', + name='url', + field=models.URLField(blank=True, null=True), + ), + ] diff --git a/app/models.py b/app/models.py index a2d82c8..3191852 100644 --- a/app/models.py +++ b/app/models.py @@ -366,31 +366,59 @@ class Organisation(models.Model): ('Education > Graduate', 'Education > Graduate'), ('Collection > Botanical Garden', 'Collection > Botanical Garden'), ('Other', 'Other'),) + SUBJECT_CHOICES = ( + ('Other', 'Other'), + ('Environment', 'Environment'), + ('Ecology', 'Ecology'), + ('Agriculture', 'Agriculture'), + ('Botany', 'Botany'), + ('Science and technology', 'Science and technology'), + ('Biodiversity', 'Biodiversity'), + ('Climate / Global Change', 'Climate / Global Change'), + ('Mountains', 'Mountains'), + ('Biology', 'Biology'), + ('Forestry', 'Forestry'), + ('Conservation', 'Conservation'), + ('Culture / arts', 'Culture / arts'), + ('Geography', 'Geography'), + ('Zoology', 'Zoology'), + ('Development / poverty / human rights', 'Development / poverty / human rights'), + ('Social Sciences', 'Social Sciences'), + ('Earth Sciences', 'Earth Sciences'), + ('Health', 'Health'), + ('Hydrology / Water', 'Hydrology / Water'), + ('Sustainability', 'Sustainability'), + ('Economy / finance', 'Economy / finance'), + ('Natural Resources', 'Natural Resources'), + ('Education', 'Education'), + ('Architecture, planning & design', 'Architecture, planning & design'), + ('', ''), + ) org_num1 = models.AutoField(primary_key=True) organisation_search = models.TextField(blank=True, null=True) org_alpha_search = models.TextField(blank=True, null=True) - organisation_english = models.TextField(blank=True, null=True) - organisation_2 = models.TextField(blank=True, null=True) - organisation_3 = models.TextField(blank=True, null=True) + organisation_english = models.CharField(max_length=256, blank=True, null=True) + organisation_2 = models.CharField(max_length=256, blank=True, null=True) + organisation_3 = models.CharField(max_length=256, blank=True, null=True) organisation_original = models.TextField(blank=True, null=True) - acronym = models.TextField(blank=True, null=True) - street = models.TextField(blank=True, null=True) - po_box = models.TextField(blank=True, null=True) - postcode = models.TextField(blank=True, null=True) - city = models.TextField(blank=True, null=True) + acronym = models.CharField(max_length=128, blank=True, null=True) + street = models.CharField(max_length=256, blank=True, null=True) + po_box = models.CharField(max_length=128, blank=True, null=True) + postcode = models.CharField(max_length=64, blank=True, null=True) + city = models.CharField(max_length=64, blank=True, null=True) region = models.TextField(blank=True, null=True) search_url = models.TextField(blank=True, null=True) - lat_long = models.TextField(blank=True, null=True) - url = models.TextField(blank=True, null=True) - tel = models.TextField(blank=True, null=True) - email = models.TextField(blank=True, null=True) + lat_long = models.CharField(max_length=128, blank=True, null=True) + url = models.URLField(blank=True, null=True) + tel = models.CharField(max_length=128, blank=True, null=True) + email = models.EmailField(blank=True, null=True) country = models.ForeignKey(Country, models.DO_NOTHING, blank=True, null=True, to_field='id') tags = models.TextField(blank=True, null=True) description = models.TextField(blank=True, null=True) northing = models.TextField(blank=True, null=True) easting = models.TextField(blank=True, null=True) category = models.TextField(blank=True, null=True, choices=CATEGORY_CHOICES) - subject = models.TextField(blank=True, null=True) + subject = models.CharField(max_length=128, blank=True, null=True, choices=SUBJECT_CHOICES) def __str__(self): return self.organisation_english