From a81740f453f80a34a4602b9d0e334a9d5a26a59e Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 13 Jan 2022 09:38:36 +0530 Subject: [PATCH 01/13] Make select_300 boolean field --- .../0052_alter_mountainrange_select_300.py | 18 ++++++++++++++++++ app/models.py | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 app/migrations/0052_alter_mountainrange_select_300.py diff --git a/app/migrations/0052_alter_mountainrange_select_300.py b/app/migrations/0052_alter_mountainrange_select_300.py new file mode 100644 index 0000000..b6d0365 --- /dev/null +++ b/app/migrations/0052_alter_mountainrange_select_300.py @@ -0,0 +1,18 @@ +# Generated by Django 4.0.1 on 2022-01-13 04:08 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('app', '0051_auto_20220104_1608'), + ] + + operations = [ + migrations.AlterField( + model_name='mountainrange', + name='select_300', + field=models.BooleanField(blank=True, max_length=12, null=True), + ), + ] diff --git a/app/models.py b/app/models.py index 4980def..ebbd17f 100644 --- a/app/models.py +++ b/app/models.py @@ -119,7 +119,7 @@ class MountainRange(models.Model): gmba_v2_id_str = models.TextField(blank=True, null=True) wiki_data_id = models.CharField(blank=True, null=True, max_length=25) wiki_data_url = models.TextField(blank=True, null=True) - select_300 = models.CharField(blank=True, null=True, max_length=12) + select_300 = models.BooleanField(blank=True, null=True, max_length=12) gmba_narrow = models.CharField(blank=True, null=True, max_length=12) name_fr = models.CharField(blank=True, null=True, max_length=128) name_de = models.CharField(blank=True, null=True, max_length=128) -- 2.40.1 From 4c328052dac73765c46a4c2c39e2e71c7ba663a9 Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 13 Jan 2022 09:45:40 +0530 Subject: [PATCH 02/13] Make select_300 boolean field --- .../0053_alter_mountainrange_select_300.py | 18 ++++++++++++++++++ app/models.py | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 app/migrations/0053_alter_mountainrange_select_300.py diff --git a/app/migrations/0053_alter_mountainrange_select_300.py b/app/migrations/0053_alter_mountainrange_select_300.py new file mode 100644 index 0000000..2052337 --- /dev/null +++ b/app/migrations/0053_alter_mountainrange_select_300.py @@ -0,0 +1,18 @@ +# Generated by Django 4.0.1 on 2022-01-13 04:15 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('app', '0052_alter_mountainrange_select_300'), + ] + + operations = [ + migrations.AlterField( + model_name='mountainrange', + name='select_300', + field=models.BooleanField(default=False), + ), + ] diff --git a/app/models.py b/app/models.py index ebbd17f..ea6b2c3 100644 --- a/app/models.py +++ b/app/models.py @@ -119,7 +119,7 @@ class MountainRange(models.Model): gmba_v2_id_str = models.TextField(blank=True, null=True) wiki_data_id = models.CharField(blank=True, null=True, max_length=25) wiki_data_url = models.TextField(blank=True, null=True) - select_300 = models.BooleanField(blank=True, null=True, max_length=12) + select_300 = models.BooleanField(default=False) gmba_narrow = models.CharField(blank=True, null=True, max_length=12) name_fr = models.CharField(blank=True, null=True, max_length=128) name_de = models.CharField(blank=True, null=True, max_length=128) -- 2.40.1 From 55ec614dd6d7e25e07db0dc6a1b3b174181f0f4e Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 13 Jan 2022 09:46:04 +0530 Subject: [PATCH 03/13] Load boolean data from select_300 field while import --- app/management/commands/import.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/management/commands/import.py b/app/management/commands/import.py index a70ad2e..5d3952e 100644 --- a/app/management/commands/import.py +++ b/app/management/commands/import.py @@ -452,6 +452,9 @@ def handle_object_dict(object_dict, model_name, debug=False): for i in ['checked']: if i in object_dict: object_dict[i] = True if object_dict[i].lower().strip() == 'true' else False + for i in ['select_300']: + if i in object_dict: + object_dict[i] = True if object_dict[i].lower().strip() == 'x' else False # area field can't be empty if 'area' in object_dict: if object_dict['area'] == '': -- 2.40.1 From 9d022c6d3ead545bcfd2bf8a390dc8407d0de906 Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 13 Jan 2022 10:06:33 +0530 Subject: [PATCH 04/13] Make GMBA Standard close to select_300 --- app/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/admin.py b/app/admin.py index 041acd9..9c0caf5 100644 --- a/app/admin.py +++ b/app/admin.py @@ -158,7 +158,7 @@ class RangeAdmin(admin.ModelAdmin): (None, { 'fields': ( ('gmba_v2_id', 'range_name', 'range_name_language', 'map_unit'), - ('range_name_map', 'select_300', 'checked'), + ('range_name_map', 'select_300', 'gmba_narrow', 'checked'), ('range_name_ascii', 'GMBA_v1_id'), ('latitude', 'longitude'), ('mother_range', 'wiki_data_id', 'area'), -- 2.40.1 From 1c78f6d8e324b7e1c78bfe94c00af4f9416bc1f5 Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 13 Jan 2022 10:07:06 +0530 Subject: [PATCH 05/13] Make GMBA narrow boolean field --- app/admin.py | 2 +- app/management/commands/import.py | 3 +++ app/models.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/admin.py b/app/admin.py index 9c0caf5..6050a74 100644 --- a/app/admin.py +++ b/app/admin.py @@ -162,7 +162,7 @@ class RangeAdmin(admin.ModelAdmin): ('range_name_ascii', 'GMBA_v1_id'), ('latitude', 'longitude'), ('mother_range', 'wiki_data_id', 'area'), - ('feature', 'range_alternate_id', 'gmba_narrow'), + ('feature', 'range_alternate_id'), 'source', 'id', ) diff --git a/app/management/commands/import.py b/app/management/commands/import.py index 5d3952e..e7d83cb 100644 --- a/app/management/commands/import.py +++ b/app/management/commands/import.py @@ -455,6 +455,9 @@ def handle_object_dict(object_dict, model_name, debug=False): for i in ['select_300']: if i in object_dict: object_dict[i] = True if object_dict[i].lower().strip() == 'x' else False + for i in ['gmba_narrow']: + if i in object_dict: + object_dict[i] = True if object_dict[i].lower().strip() == 'x' else False # area field can't be empty if 'area' in object_dict: if object_dict['area'] == '': diff --git a/app/models.py b/app/models.py index ea6b2c3..0f88bb4 100644 --- a/app/models.py +++ b/app/models.py @@ -120,7 +120,7 @@ class MountainRange(models.Model): wiki_data_id = models.CharField(blank=True, null=True, max_length=25) wiki_data_url = models.TextField(blank=True, null=True) select_300 = models.BooleanField(default=False) - gmba_narrow = models.CharField(blank=True, null=True, max_length=12) + gmba_narrow = models.BooleanField(default=False, verbose_name="GMBA Standard") name_fr = models.CharField(blank=True, null=True, max_length=128) name_de = models.CharField(blank=True, null=True, max_length=128) name_es = models.CharField(blank=True, null=True, max_length=128) -- 2.40.1 From f02ea9e2ea1e90fb0c2f3d46ba76418d2d9ccc40 Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 13 Jan 2022 10:07:26 +0530 Subject: [PATCH 06/13] Add migration --- .../0054_alter_mountainrange_gmba_narrow.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 app/migrations/0054_alter_mountainrange_gmba_narrow.py diff --git a/app/migrations/0054_alter_mountainrange_gmba_narrow.py b/app/migrations/0054_alter_mountainrange_gmba_narrow.py new file mode 100644 index 0000000..099ce81 --- /dev/null +++ b/app/migrations/0054_alter_mountainrange_gmba_narrow.py @@ -0,0 +1,18 @@ +# Generated by Django 4.0.1 on 2022-01-13 04:37 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('app', '0053_alter_mountainrange_select_300'), + ] + + operations = [ + migrations.AlterField( + model_name='mountainrange', + name='gmba_narrow', + field=models.BooleanField(default=False, verbose_name='GMBA Standard'), + ), + ] -- 2.40.1 From 90b4f3e53edea0e2394dacf0b6d884e6d4e6e55f Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 13 Jan 2022 10:14:43 +0530 Subject: [PATCH 07/13] Make wiki_data_url urlfield + make it closer to wiki_data_id --- app/admin.py | 2 +- .../0055_alter_mountainrange_wiki_data_url.py | 18 ++++++++++++++++++ app/models.py | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 app/migrations/0055_alter_mountainrange_wiki_data_url.py diff --git a/app/admin.py b/app/admin.py index 6050a74..809767d 100644 --- a/app/admin.py +++ b/app/admin.py @@ -161,7 +161,7 @@ class RangeAdmin(admin.ModelAdmin): ('range_name_map', 'select_300', 'gmba_narrow', 'checked'), ('range_name_ascii', 'GMBA_v1_id'), ('latitude', 'longitude'), - ('mother_range', 'wiki_data_id', 'area'), + ('mother_range', 'wiki_data_id', 'wiki_data_url', 'area'), ('feature', 'range_alternate_id'), 'source', 'id', diff --git a/app/migrations/0055_alter_mountainrange_wiki_data_url.py b/app/migrations/0055_alter_mountainrange_wiki_data_url.py new file mode 100644 index 0000000..7cbb7ff --- /dev/null +++ b/app/migrations/0055_alter_mountainrange_wiki_data_url.py @@ -0,0 +1,18 @@ +# Generated by Django 4.0.1 on 2022-01-13 04:44 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('app', '0054_alter_mountainrange_gmba_narrow'), + ] + + operations = [ + migrations.AlterField( + model_name='mountainrange', + name='wiki_data_url', + field=models.URLField(blank=True, null=True), + ), + ] diff --git a/app/models.py b/app/models.py index 0f88bb4..9f82dc3 100644 --- a/app/models.py +++ b/app/models.py @@ -118,7 +118,7 @@ class MountainRange(models.Model): gmba_v2_id = models.PositiveIntegerField(blank=True, null=True) gmba_v2_id_str = models.TextField(blank=True, null=True) wiki_data_id = models.CharField(blank=True, null=True, max_length=25) - wiki_data_url = models.TextField(blank=True, null=True) + wiki_data_url = models.URLField(blank=True, null=True) select_300 = models.BooleanField(default=False) gmba_narrow = models.BooleanField(default=False, verbose_name="GMBA Standard") name_fr = models.CharField(blank=True, null=True, max_length=128) -- 2.40.1 From 5de6645d4f26dacd6ff45a777e3c574b02644777 Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 13 Jan 2022 10:24:07 +0530 Subject: [PATCH 08/13] Do not show checked --- app/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/admin.py b/app/admin.py index 809767d..3dedfa9 100644 --- a/app/admin.py +++ b/app/admin.py @@ -158,7 +158,7 @@ class RangeAdmin(admin.ModelAdmin): (None, { 'fields': ( ('gmba_v2_id', 'range_name', 'range_name_language', 'map_unit'), - ('range_name_map', 'select_300', 'gmba_narrow', 'checked'), + ('range_name_map', 'select_300', 'gmba_narrow'), ('range_name_ascii', 'GMBA_v1_id'), ('latitude', 'longitude'), ('mother_range', 'wiki_data_id', 'wiki_data_url', 'area'), -- 2.40.1 From d012a2e3847074c023041fbc0f11f70cb2a39dc2 Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 13 Jan 2022 10:35:42 +0530 Subject: [PATCH 09/13] Make range_alternate_id charfield and position it at the bottom --- app/admin.py | 5 ++++- app/models.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/admin.py b/app/admin.py index 3dedfa9..a090c5b 100644 --- a/app/admin.py +++ b/app/admin.py @@ -162,7 +162,7 @@ class RangeAdmin(admin.ModelAdmin): ('range_name_ascii', 'GMBA_v1_id'), ('latitude', 'longitude'), ('mother_range', 'wiki_data_id', 'wiki_data_url', 'area'), - ('feature', 'range_alternate_id'), + 'feature', 'source', 'id', ) @@ -181,6 +181,9 @@ class RangeAdmin(admin.ModelAdmin): ('Comments', { 'classes': ('collapse',), 'fields': ('comments',), + }), + ('Others', { + 'fields': ('range_alternate_id', ) }) ) list_display = ['range_name', 'mother_range', 'countries'] diff --git a/app/models.py b/app/models.py index 9f82dc3..466d4fb 100644 --- a/app/models.py +++ b/app/models.py @@ -113,7 +113,7 @@ class MountainRange(models.Model): comments = models.TextField(blank=True, null=True) checked = models.BooleanField(default=False) source = models.TextField(blank=True, null=True) - range_alternate_id = models.TextField(blank=True, null=True) + range_alternate_id = models.CharField(blank=True, null=True, max_length=128) geologic_region = models.TextField(blank=True, null=True) gmba_v2_id = models.PositiveIntegerField(blank=True, null=True) gmba_v2_id_str = models.TextField(blank=True, null=True) -- 2.40.1 From 0a3b185c52c516476fa0924f29816bd52acf8d57 Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 13 Jan 2022 10:36:11 +0530 Subject: [PATCH 10/13] Add migration --- ...6_alter_mountainrange_range_alternate_id.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 app/migrations/0056_alter_mountainrange_range_alternate_id.py diff --git a/app/migrations/0056_alter_mountainrange_range_alternate_id.py b/app/migrations/0056_alter_mountainrange_range_alternate_id.py new file mode 100644 index 0000000..fa9e25f --- /dev/null +++ b/app/migrations/0056_alter_mountainrange_range_alternate_id.py @@ -0,0 +1,18 @@ +# Generated by Django 4.0.1 on 2022-01-13 05:05 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('app', '0055_alter_mountainrange_wiki_data_url'), + ] + + operations = [ + migrations.AlterField( + model_name='mountainrange', + name='range_alternate_id', + field=models.CharField(blank=True, max_length=128, null=True), + ), + ] -- 2.40.1 From 5974c7530a12f63a70f916f46e2f0c3f5b12faa6 Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 13 Jan 2022 10:43:02 +0530 Subject: [PATCH 11/13] Move countries after mother range --- app/admin.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/admin.py b/app/admin.py index a090c5b..a587be8 100644 --- a/app/admin.py +++ b/app/admin.py @@ -161,7 +161,7 @@ class RangeAdmin(admin.ModelAdmin): ('range_name_map', 'select_300', 'gmba_narrow'), ('range_name_ascii', 'GMBA_v1_id'), ('latitude', 'longitude'), - ('mother_range', 'wiki_data_id', 'wiki_data_url', 'area'), + ('mother_range', 'countries', 'wiki_data_id', 'wiki_data_url', 'area'), 'feature', 'source', 'id', @@ -174,10 +174,6 @@ class RangeAdmin(admin.ModelAdmin): ('name_ru', 'name_tr', 'name_cn') ) }), - ('Range Countries', { - 'classes': ('collapse',), - 'fields': ('countries',), - }), ('Comments', { 'classes': ('collapse',), 'fields': ('comments',), -- 2.40.1 From 7c7ae45ff0a2666a7748d640226b53f9208a7d7e Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 13 Jan 2022 10:45:47 +0530 Subject: [PATCH 12/13] Comment out inlines for MountainRange --- app/admin.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/admin.py b/app/admin.py index a587be8..c2917a5 100644 --- a/app/admin.py +++ b/app/admin.py @@ -146,10 +146,10 @@ class RangeCountryInline(admin.TabularInline): class RangeAdmin(admin.ModelAdmin): autocomplete_fields = ['mother_range'] - inlines = [ - RangeNameTranslationInline, - RangeCountryInline - ] + # inlines = [ + # RangeNameTranslationInline, + # RangeCountryInline + # ] readonly_fields = ('id', 'gmba_v2_id') search_fields = ['name', 'range_name', 'range_name_ascii', 'level', 'level', 'level_1', 'level_2', 'level_3', 'peak_name', 'comments', 'source', -- 2.40.1 From 068e38fb91abad6bdf66bb052d5700a537fb1f31 Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 13 Jan 2022 10:54:03 +0530 Subject: [PATCH 13/13] Rearrange fields --- app/admin.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/admin.py b/app/admin.py index c2917a5..76faff0 100644 --- a/app/admin.py +++ b/app/admin.py @@ -157,12 +157,11 @@ class RangeAdmin(admin.ModelAdmin): fieldsets = ( (None, { 'fields': ( - ('gmba_v2_id', 'range_name', 'range_name_language', 'map_unit'), - ('range_name_map', 'select_300', 'gmba_narrow'), - ('range_name_ascii', 'GMBA_v1_id'), - ('latitude', 'longitude'), - ('mother_range', 'countries', 'wiki_data_id', 'wiki_data_url', 'area'), - 'feature', + ('gmba_v2_id', 'range_name', 'range_name_language'), + ('map_unit', 'feature', 'gmba_narrow', 'select_300'), + ('range_name_map', 'range_name_ascii', 'GMBA_v1_id'), + ('latitude', 'longitude', 'area'), + ('mother_range', 'countries', 'wiki_data_id', 'wiki_data_url'), 'source', 'id', ) -- 2.40.1