From 1c0eac6dbff878d85b6a4eaa2fb0819dc7c268a3 Mon Sep 17 00:00:00 2001 From: Marcel Wallschlaeger Date: Tue, 5 Nov 2024 22:37:20 +0100 Subject: [PATCH 1/3] [Fixes #195] Feature: dataset attribute requiring a unit entry --- geonode/layers/admin.py | 5 ++-- geonode/layers/forms.py | 1 + .../0049_attribute_attribute_unit.py | 24 +++++++++++++++++ geonode/layers/models.py | 9 +++++++ ...oadparallelismlimit_max_number_and_more.py | 27 +++++++++++++++++++ 5 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 geonode/layers/migrations/0049_attribute_attribute_unit.py create mode 100644 geonode/upload/migrations/0040_alter_uploadparallelismlimit_max_number_and_more.py diff --git a/geonode/layers/admin.py b/geonode/layers/admin.py index 901e6862dea..6ce4261f62e 100644 --- a/geonode/layers/admin.py +++ b/geonode/layers/admin.py @@ -106,11 +106,12 @@ def delete_queryset(self, request, queryset): class AttributeAdmin(admin.ModelAdmin): model = Attribute list_display_links = ("id",) - list_display = ("id", "dataset", "attribute", "description", "attribute_label", "attribute_type", "display_order") - list_filter = ("dataset", "attribute_type") + list_display = ("id", "dataset", "attribute", "description", "attribute_label", "attribute_type", "attribute_unit", "display_order") + list_filter = ("dataset", "attribute_type", "attribute_unit") search_fields = ( "attribute", "attribute_label", + "attribute_unit" ) diff --git a/geonode/layers/forms.py b/geonode/layers/forms.py index 38db3c7956c..4b3fa6dc7a8 100644 --- a/geonode/layers/forms.py +++ b/geonode/layers/forms.py @@ -99,6 +99,7 @@ class Meta: model = Attribute exclude = ( "attribute_type", + "attribute_unit" "count", "min", "max", diff --git a/geonode/layers/migrations/0049_attribute_attribute_unit.py b/geonode/layers/migrations/0049_attribute_attribute_unit.py new file mode 100644 index 00000000000..17efb0472bc --- /dev/null +++ b/geonode/layers/migrations/0049_attribute_attribute_unit.py @@ -0,0 +1,24 @@ +# Generated by Django 4.2.9 on 2024-11-05 21:12 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("layers", "0048_merge_20240927_1323"), + ] + + operations = [ + migrations.AddField( + model_name="attribute", + name="attribute_unit", + field=models.CharField( + blank=True, + help_text="the unit of the attribute (kg, °C, mm etc)", + max_length=50, + null=True, + verbose_name="attribute unit", + ), + ), + ] diff --git a/geonode/layers/models.py b/geonode/layers/models.py index a15eec68c8c..feec341fc8d 100644 --- a/geonode/layers/models.py +++ b/geonode/layers/models.py @@ -423,6 +423,15 @@ class Attribute(models.Model): default="xsd:string", unique=False, ) + attribute_unit = models.CharField( + _("attribute unit"), + help_text=_("the unit of the attribute (kg, °C, mm etc)"), + max_length=50, + blank=True, + null=True, + unique=False, + ) + visible = models.BooleanField( _("visible?"), help_text=_("specifies if the attribute should be displayed in identify results"), default=True ) diff --git a/geonode/upload/migrations/0040_alter_uploadparallelismlimit_max_number_and_more.py b/geonode/upload/migrations/0040_alter_uploadparallelismlimit_max_number_and_more.py new file mode 100644 index 00000000000..70bde07b72e --- /dev/null +++ b/geonode/upload/migrations/0040_alter_uploadparallelismlimit_max_number_and_more.py @@ -0,0 +1,27 @@ +# Generated by Django 4.2.9 on 2024-11-05 21:12 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("upload", "0039_auto_20220506_0833"), + ] + + operations = [ + migrations.AlterField( + model_name="uploadparallelismlimit", + name="max_number", + field=models.PositiveSmallIntegerField( + default=5, help_text="The maximum number of parallel uploads (0 to 32767)." + ), + ), + migrations.AlterField( + model_name="uploadsizelimit", + name="max_size", + field=models.PositiveBigIntegerField( + default=104857600, help_text="The maximum file size allowed for upload (bytes)." + ), + ), + ] From 92ad833c1cf79385ac0e6103403940f6aa933cb1 Mon Sep 17 00:00:00 2001 From: Marcel Wallschlaeger Date: Wed, 6 Nov 2024 21:33:59 +0100 Subject: [PATCH 2/3] [Fixes #195] Feature dataset attribute requiring a unit entry --- geonode/layers/forms.py | 1 - .../layers/templates/datasets/dataset_metadata_advanced.html | 2 ++ geonode/layers/views.py | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/geonode/layers/forms.py b/geonode/layers/forms.py index 4b3fa6dc7a8..38db3c7956c 100644 --- a/geonode/layers/forms.py +++ b/geonode/layers/forms.py @@ -99,7 +99,6 @@ class Meta: model = Attribute exclude = ( "attribute_type", - "attribute_unit" "count", "min", "max", diff --git a/geonode/layers/templates/datasets/dataset_metadata_advanced.html b/geonode/layers/templates/datasets/dataset_metadata_advanced.html index 9f8d7427079..c82a2475cbc 100644 --- a/geonode/layers/templates/datasets/dataset_metadata_advanced.html +++ b/geonode/layers/templates/datasets/dataset_metadata_advanced.html @@ -411,6 +411,7 @@
{% trans "Attributes" %}
{% trans "Attribute" %} {% trans "Label" %} {% trans "Description" %} + {% trans "Unit" %} {% trans "Display Order" %} {% trans "Display Type" %} {% trans "Visible" %} @@ -421,6 +422,7 @@
{% trans "Attributes" %}
{{form.id}}
{{form.attribute}} {{form.attribute_label}} {{form.description}} + {{form.attribute_unit}} {{form.display_order}} {{form.featureinfo_type}} {{form.visible}} diff --git a/geonode/layers/views.py b/geonode/layers/views.py index ad16658d588..9d254df854e 100644 --- a/geonode/layers/views.py +++ b/geonode/layers/views.py @@ -492,6 +492,7 @@ def dataset_metadata( la = Attribute.objects.get(id=int(form["id"].id)) la.description = form["description"] la.attribute_label = form["attribute_label"] + la.attribute_unit = form["attribute_unit"] la.visible = form["visible"] la.display_order = form["display_order"] la.featureinfo_type = form["featureinfo_type"] From 30846f41477474c137146dab906fa14fde6613d3 Mon Sep 17 00:00:00 2001 From: Marcel Wallschlaeger Date: Wed, 6 Nov 2024 21:41:45 +0100 Subject: [PATCH 3/3] [Fixes #195] Feature dataset attribute requiring a unit entry --- geonode/layers/models.py | 2 +- geonode/locale/de/LC_MESSAGES/django.po | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/geonode/layers/models.py b/geonode/layers/models.py index feec341fc8d..a10d910b030 100644 --- a/geonode/layers/models.py +++ b/geonode/layers/models.py @@ -425,7 +425,7 @@ class Attribute(models.Model): ) attribute_unit = models.CharField( _("attribute unit"), - help_text=_("the unit of the attribute (kg, °C, mm etc)"), + help_text=_("the used unit for the attribute"), max_length=50, blank=True, null=True, diff --git a/geonode/locale/de/LC_MESSAGES/django.po b/geonode/locale/de/LC_MESSAGES/django.po index 46a75a31620..d165edcaf02 100644 --- a/geonode/locale/de/LC_MESSAGES/django.po +++ b/geonode/locale/de/LC_MESSAGES/django.po @@ -3417,10 +3417,19 @@ msgstr "Titel der Attribute wie in GeoNode dargestellt" msgid "attribute type" msgstr "Attributtyp" +#: geonode/layers/models.py:427 +msgid "attribute type" +msgstr "Attributeinheit" + #: geonode/layers/models.py:420 msgid "the data type of the attribute (integer, string, geometry, etc)" msgstr "der Datenyp des Attributes (Integer, Zeichenkette, Geometrie , etc)" +#: geonode/layers/models.py:428 +msgid ""the used unit for the attribute"" +msgstr "die verwendete Einheit des Attributes" + + #: geonode/layers/models.py:428 msgid "visible?" msgstr "sichtbar?"