From ae5d57666c82f086acea1cf251847e80dce3629a Mon Sep 17 00:00:00 2001 From: Mattia Giupponi Date: Wed, 7 Apr 2021 09:35:42 +0200 Subject: [PATCH 1/2] [Resolves #6995] Increase UI block coverage in geonode --- geonode/context_processors.py | 1 + .../templates/layouts/doc_panels.html | 61 ++++++++++++++++++- .../layers/layer_metadata_advanced.html | 2 +- geonode/layers/templates/layouts/panels.html | 44 +++++++++++-- .../maps/templates/layouts/map_panels.html | 52 ++++++++++++++-- geonode/templates/metadata_form_js.html | 7 ++- 6 files changed, 151 insertions(+), 16 deletions(-) diff --git a/geonode/context_processors.py b/geonode/context_processors.py index 2c529bc7db2..72b95ae1b94 100644 --- a/geonode/context_processors.py +++ b/geonode/context_processors.py @@ -199,5 +199,6 @@ def resource_urls(request): for x in Thesaurus.objects.all() if (x.card_max == -1 and x.card_min == 1) or (x.card_max == 1 and x.card_min == 1) ], + ADVANCED_EDIT_EXCLUDE_FIELD=getattr(settings, "ADVANCED_EDIT_EXCLUDE_FIELD", []), ) return defaults diff --git a/geonode/documents/templates/layouts/doc_panels.html b/geonode/documents/templates/layouts/doc_panels.html index bcb4fc7d7de..a813ae9b104 100644 --- a/geonode/documents/templates/layouts/doc_panels.html +++ b/geonode/documents/templates/layouts/doc_panels.html @@ -252,6 +252,7 @@ {% trans "Optional Metadata" %} + {% block mandatory %}
@@ -268,6 +269,7 @@
+ {% block doc_thumbnail %}
+ {% endblock doc_thumbnail %}
+ {% block doc_title %}
{{ document_form.title }}
+ {% endblock doc_title %} + {% block doc_links %}
{{ document_form.links }}
+ {% endblock doc_links %} + {% block doc_abstract %}
{{ document_form.abstract }}
+ {% endblock doc_abstract %}
+ {% block doc_date_type %}
{{ document_form.date_type }}
+ {% endblock doc_date_type %} + + {% block doc_date %}
{{ document_form.date }}
+ {% endblock doc_date %} + {% block doc_category %}
+ {% endblock doc_group %} + {% block doc_keywords %}
{{ document_form.keywords }}
+ {% endblock doc_keywords %} {% if THESAURI_FILTERS %}
- {{ tkeywords_form }} + {{ tkeywords_form.as_p }}
{% endif %}
@@ -370,6 +390,8 @@
+ {% endblock mandatory %} + {% block advanced %}
@@ -378,51 +400,66 @@
+ {% block doc_language %}
{{ document_form.language }}
+ {% endblock doc_language %} + {% block doc_license %}
{{ document_form.license }}
+ {% endblock doc_license %} + {% block doc_doi %}
{{ document_form.doi }}
+ {% endblock doc_doi %} + {% block doc_attribution %}
{{ document_form.attribution }}
+ {% endblock doc_attribution %}
+ {% block doc_regions %}
{{ document_form.regions }}
+ {% endblock doc_regions %} + {% block doc_data_quality_statement %}
{{ document_form.data_quality_statement }}
+ {% endblock doc_data_quality_statement %}
+ {% block doc_restriction_code_type %}
{{ document_form.restriction_code_type }}
+ {% endblock doc_restriction_code_type %} + {% block doc_constraints_other %}
{{ document_form.constraints_other }} -
+
+ {% endblock doc_constraints_other %}
-
@@ -430,53 +467,69 @@
+ {% endblock advanced %} + {% block ownership %}

{% trans "Other, Optional, Metadata" %}

+ {% block doc_edition %}
{{ document_form.edition }}
+ {% endblock doc_edition %} + {% block doc_purpose %}
{{ document_form.purpose }}
+ {% endblock doc_purpose %} + {% block doc_supplemental_information %}
{{ document_form.supplemental_information }}
+ {% endblock doc_supplemental_information %}
+ {% block doc_temporal_extent_start %}
{{ document_form.temporal_extent_start }}
+ {% endblock doc_temporal_extent_start %}
+ {% block doc_temporal_extent_end %}
{{ document_form.temporal_extent_end }}
+ {% endblock doc_temporal_extent_end %}
+ {% block doc_maintenance_frequency %}
{{ document_form.maintenance_frequency }}
+ {% endblock doc_maintenance_frequency %} + {% block doc_spatial_representation_type %}
{{ document_form.spatial_representation_type }}
+ {% endblock doc_spatial_representation_type %}
@@ -507,6 +560,8 @@
+ {% endblock ownership %} +
diff --git a/geonode/layers/templates/layers/layer_metadata_advanced.html b/geonode/layers/templates/layers/layer_metadata_advanced.html index 828595bba5e..65c4121a2a2 100644 --- a/geonode/layers/templates/layers/layer_metadata_advanced.html +++ b/geonode/layers/templates/layers/layer_metadata_advanced.html @@ -96,7 +96,7 @@

{% trans "Edit Metadata" %}

{% block layer_fields %} {% for field in layer_form %} - {% if field.name != 'use_featureinfo_custom_template' and field.name != 'featureinfo_custom_template' %} + {% if field.name != 'use_featureinfo_custom_template' and field.name != 'featureinfo_custom_template' and field.name not in ADVANCED_EDIT_EXCLUDE_FIELD %}
{{ field }} diff --git a/geonode/layers/templates/layouts/panels.html b/geonode/layers/templates/layouts/panels.html index 854d76ac388..3c37dda1908 100644 --- a/geonode/layers/templates/layouts/panels.html +++ b/geonode/layers/templates/layouts/panels.html @@ -293,6 +293,7 @@
+ {% block thumbnail %}
@@ -314,29 +315,39 @@
+ {% endblock thumbnail %}
+ {% block layer_title %}
{{ layer_form.title }}
+ {% endblock layer_title %} + {% block layer_abstract %}
{{ layer_form.abstract }}
+ {% endblock layer_abstract %}
+ {% block layer_date_type %}
{{ layer_form.date_type }}
+ {% endblock layer_date_type %} + {% block layer_date %}
{{ layer_form.date }}
+ {% endblock layer_date %} + {% block layer_category %}
+ {% endblock layer_group %} + {% block layer_free_keyword %}
{{ layer_form.keywords }}
+ {% endblock layer_free_keyword %} {% if THESAURI_FILTERS %}
{{tkeywords_form.as_p}} @@ -470,23 +486,30 @@

{% trans "Other, Optional, Metadata" %}

+ {% block layer_edition %}
{{ layer_form.edition }}
+ {% endblock layer_edition %} + {% block layer_purpose %}
{{ layer_form.purpose }}
+ {% endblock layer_purpose %} + {% block layer_supplemental_information %}
{{ layer_form.supplemental_information }}
+ {% endblock layer_supplemental_information %}
+ {% block layer_temporal_extent_start %}
@@ -494,6 +517,8 @@ {{ layer_form.temporal_extent_start }}
+ {% endblock layer_temporal_extent_start %} + {% block layer_temporal_extent_end %}
@@ -501,40 +526,51 @@ {{ layer_form.temporal_extent_end }}
+ {% endblock layer_temporal_extent_end %}
+ {% block layer_maintenance_frequency %}
{{ layer_form.maintenance_frequency }}
+ {% endblock layer_maintenance_frequency %} + {% block layer_spatial_representation_type %}
{{ layer_form.spatial_representation_type }}
+ {% endblock layer_spatial_representation_type %}
{% trans "Responsible Parties" %}
-
- - {{ layer_form.poc }} -
+ {% block layer_poc %} +
+ + {{ layer_form.poc }} +
+ {% endblock layer_poc %}
{% trans "Responsible and Permissions" %}
+ {% block layer_owner %}
{{ layer_form.owner }}
+ {% endblock layer_owner %} + {% block layer_metadata_author %}
{{ layer_form.metadata_author }}
+ {% endblock layer_metadata_author %}
diff --git a/geonode/maps/templates/layouts/map_panels.html b/geonode/maps/templates/layouts/map_panels.html index 4806ecae87a..e337f1741da 100644 --- a/geonode/maps/templates/layouts/map_panels.html +++ b/geonode/maps/templates/layouts/map_panels.html @@ -270,6 +270,7 @@
+ {% block map_thumbnail %}
@@ -290,29 +291,39 @@
+ {% endblock map_thumbnail %}
+ {% block map_title %}
{{ map_form.title }}
+ {% endblock map_title %} + {% block map_abstract %}
{{ map_form.abstract }}
+ {% endblock map_abstract %}
+ {% block map_date_type %}
{{ map_form.date_type }}
+ {% endblock map_date_type %} + {% block map_date %}
{{ map_form.date }}
+ {% endblock map_date %} + {% block map_category %}
+ {% endblock map_group %} + {% block map_keywords %}
{{ map_form.keywords }}
+ {% endblock map_keywords %} {% if THESAURI_FILTERS %}
{{tkeywords_form.as_p}} @@ -379,47 +395,63 @@
+ {% block map_language %}
{{ map_form.language }}
+ {% endblock map_language %} + {% block map_license %}
{{ map_form.license }}
+ {% endblock map_license %} + {% block map_doi %}
{{ map_form.doi }}
+ {% endblock map_doi %} + {% block map_attribution %}
{{ map_form.attribution }}
+ {% endblock map_attribution %}
+ {% block map_regions %}
- - {{ map_form.regions }} + + {{ map_form.regions }}
+ {% endblock map_regions %} + {% block map_data_quality_statement %}
- - - {{ map_form.data_quality_statement }} + + + {{ map_form.data_quality_statement }}
+ {% endblock map_data_quality_statement %}
+ {% block map_restriction_code_type %}
{{ map_form.restriction_code_type }}
+ {% endblock map_restriction_code_type %} + {% block map_constraints_other %}
{{ map_form.constraints_other }} -
+
+ {% endblock map_constraints_other %}
@@ -436,21 +468,27 @@

{% trans "Other, Optional, Metadata" %}

+ {% block map_edition %}
{{ map_form.edition }}
+ {% endblock map_edition %} + {% block map_purpose %}
{{ map_form.purpose }}
+ {% endblock map_purpose %} + {% block map_supplemental_information %}
{{ map_form.supplemental_information }}
+ {% endblock map_supplemental_information %}
@@ -461,11 +499,13 @@
+ {% block map_temporal_extent_end %}
{{ map_form.temporal_extent_end }}
+ {% endblock map_temporal_extent_end %}
diff --git a/geonode/templates/metadata_form_js.html b/geonode/templates/metadata_form_js.html index dbef215a2f8..0becc509ea0 100644 --- a/geonode/templates/metadata_form_js.html +++ b/geonode/templates/metadata_form_js.html @@ -400,8 +400,11 @@ {{REQ_THESAURI}}.forEach(element => document.querySelector('select[name="'+ element + '"]').onchange=onInputChange); - document.querySelector('select[name="resource-keywords"]').onchange=onInputChange - + var selection = document.querySelector('select[name="resource-keywords"]'); + if (selection !== null) { + selection.onchange=onInputChange + } + $('#id_resource-regions').change(onInputChange).change(); $('#id_resource-temporal_extent_end').on('blur', function() {$(this).change(onInputChange).change();}) $('#id_resource-temporal_extent_start').on('blur', function() {$(this).change(onInputChange).change();}) From b9f701ae4a8160e3feb2a91370a2f961c4739a3b Mon Sep 17 00:00:00 2001 From: Mattia Giupponi Date: Wed, 7 Apr 2021 09:45:46 +0200 Subject: [PATCH 2/2] [Resolves #6995] ADVANCED_EDIT_EXCLUDE_FIELD available also in maps and documents --- .../documents/document_metadata_advanced.html | 14 +++++++++++++- .../maps/templates/maps/map_metadata_advanced.html | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/geonode/documents/templates/documents/document_metadata_advanced.html b/geonode/documents/templates/documents/document_metadata_advanced.html index 6f1b5f4bf30..f471d439169 100644 --- a/geonode/documents/templates/documents/document_metadata_advanced.html +++ b/geonode/documents/templates/documents/document_metadata_advanced.html @@ -66,7 +66,19 @@

{% trans "Edit Metadata" %}

Unfortunately this needs to appear at the top (or the bottom) of the form since tkeywords_form is a complete other django form. There might be a better way to solve this.-->
- {{ document_form|as_bootstrap }} + {% block document_fields %} + {% for field in document_form %} + {% if field.name != 'use_featureinfo_custom_template' and field.name != 'featureinfo_custom_template' and field.name not in ADVANCED_EDIT_EXCLUDE_FIELD %} +
+
+ + {{ field }} +
+
+ {% endif %} + {% endfor %} + {% endblock document_fields %} + {% if THESAURI_FILTERS %} {{ tkeywords_form }} {% endif %} diff --git a/geonode/maps/templates/maps/map_metadata_advanced.html b/geonode/maps/templates/maps/map_metadata_advanced.html index 7ef921bce1a..4fb36a5343e 100644 --- a/geonode/maps/templates/maps/map_metadata_advanced.html +++ b/geonode/maps/templates/maps/map_metadata_advanced.html @@ -67,7 +67,19 @@

{% trans "Edit Metadata" %}

Unfortunately this needs to appear at the top (or the bottom) of the form since tkeywords_form is a complete other django form. There might be a better way to solve this. -->
- {{ map_form|as_bootstrap }} + {% block map_fields %} + {% for field in map_form %} + {% if field.name != 'use_featureinfo_custom_template' and field.name != 'featureinfo_custom_template' and field.name not in ADVANCED_EDIT_EXCLUDE_FIELD %} +
+
+ + {{ field }} +
+
+ {% endif %} + {% endfor %} + {% endblock map_fields %} + {% if THESAURI_FILTERS %} {{ tkeywords_form }} {% endif %}