From 6f41068d456552cafe8fbd4da7df9323806872ab Mon Sep 17 00:00:00 2001 From: mwallschlaeger Date: Thu, 20 Jun 2024 09:14:43 +0200 Subject: [PATCH 1/2] [Fixes #110] Feature: add metadata license to resource base --- geonode/base/api/serializers.py | 1 + .../0097_resourcebase_metadata_license.py | 19 +++++++++++++++++++ geonode/base/models.py | 11 +++++++++++ .../0039_alter_document_abstract_en.py | 18 ++++++++++++++++++ .../0045_alter_dataset_abstract_en.py | 18 ++++++++++++++++++ .../migrations/0044_alter_map_abstract_en.py | 18 ++++++++++++++++++ 6 files changed, 85 insertions(+) create mode 100644 geonode/base/migrations/0097_resourcebase_metadata_license.py create mode 100644 geonode/documents/migrations/0039_alter_document_abstract_en.py create mode 100644 geonode/layers/migrations/0045_alter_dataset_abstract_en.py create mode 100644 geonode/maps/migrations/0044_alter_map_abstract_en.py diff --git a/geonode/base/api/serializers.py b/geonode/base/api/serializers.py index dd0871597e1..2ea5dae4231 100644 --- a/geonode/base/api/serializers.py +++ b/geonode/base/api/serializers.py @@ -717,6 +717,7 @@ def __init__(self, *args, **kwargs): RestrictionCodeTypeSerializer, embed=True, many=True ) self.fields["license"] = ComplexDynamicRelationField(LicenseSerializer, embed=True, many=False) + self.fields["metadata_license"] = ComplexDynamicRelationField(LicenseSerializer, embed=True, many=False) self.fields["spatial_representation_type"] = ComplexDynamicRelationField( SpatialRepresentationTypeSerializer, embed=True, many=False ) diff --git a/geonode/base/migrations/0097_resourcebase_metadata_license.py b/geonode/base/migrations/0097_resourcebase_metadata_license.py new file mode 100644 index 00000000000..4fac38aacbc --- /dev/null +++ b/geonode/base/migrations/0097_resourcebase_metadata_license.py @@ -0,0 +1,19 @@ +# Generated by Django 3.2.23 on 2024-06-18 14:01 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('base', '0096_merge_0088_auto_20231019_1244_0095_auto_20230331_0923'), + ] + + operations = [ + migrations.AddField( + model_name='resourcebase', + name='metadata_license', + field=models.ForeignKey(blank=True, help_text='license of the metadata', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='metadata_license', to='base.license', verbose_name='Metadata License'), + ), + ] diff --git a/geonode/base/models.py b/geonode/base/models.py index eb2e635cb81..90d666e4251 100644 --- a/geonode/base/models.py +++ b/geonode/base/models.py @@ -781,6 +781,7 @@ class ResourceBase(PolymorphicModel, PermissionLevelMixin, ItemBase): "other restrictions and legal prerequisites for accessing and using the resource or" " metadata" ) license_help_text = _("license of the dataset") + metadata_license_help_text = _("license of the metadata") language_help_text = _("language used within the dataset") category_help_text = _( "high-level geographic data thematic classification to assist in the grouping and search of " @@ -964,6 +965,16 @@ class ResourceBase(PolymorphicModel, PermissionLevelMixin, ItemBase): help_text=license_help_text, on_delete=models.SET_NULL, ) + + metadata_license = models.ForeignKey( + License, + null=True, + blank=True, + related_name="metadata_license", + verbose_name=_("Metadata License"), + help_text=metadata_license_help_text, + on_delete=models.SET_NULL, + ) language = models.CharField( _("language"), max_length=3, choices=enumerations.ALL_LANGUAGES, default="eng", help_text=language_help_text ) diff --git a/geonode/documents/migrations/0039_alter_document_abstract_en.py b/geonode/documents/migrations/0039_alter_document_abstract_en.py new file mode 100644 index 00000000000..18ecd5811d4 --- /dev/null +++ b/geonode/documents/migrations/0039_alter_document_abstract_en.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.23 on 2024-06-18 14:01 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('documents', '0038_alter_document_doc_url'), + ] + + operations = [ + migrations.AlterField( + model_name='document', + name='abstract_en', + field=models.TextField(help_text='brief narrative summary of the content of the resource(s)', max_length=2000, null=True, verbose_name='abstract'), + ), + ] diff --git a/geonode/layers/migrations/0045_alter_dataset_abstract_en.py b/geonode/layers/migrations/0045_alter_dataset_abstract_en.py new file mode 100644 index 00000000000..fbc58ccf624 --- /dev/null +++ b/geonode/layers/migrations/0045_alter_dataset_abstract_en.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.23 on 2024-06-18 14:01 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('layers', '0044_alter_dataset_unique_together'), + ] + + operations = [ + migrations.AlterField( + model_name='dataset', + name='abstract_en', + field=models.TextField(help_text='brief narrative summary of the content of the resource(s)', max_length=2000, null=True, verbose_name='abstract'), + ), + ] diff --git a/geonode/maps/migrations/0044_alter_map_abstract_en.py b/geonode/maps/migrations/0044_alter_map_abstract_en.py new file mode 100644 index 00000000000..55a2dfea478 --- /dev/null +++ b/geonode/maps/migrations/0044_alter_map_abstract_en.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.23 on 2024-06-18 14:01 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('maps', '0043_auto_20230807_1234'), + ] + + operations = [ + migrations.AlterField( + model_name='map', + name='abstract_en', + field=models.TextField(help_text='brief narrative summary of the content of the resource(s)', max_length=2000, null=True, verbose_name='abstract'), + ), + ] From 0feb3313f9a6b4c03141924d4942459ce85e912a Mon Sep 17 00:00:00 2001 From: mwallschlaeger Date: Thu, 20 Jun 2024 09:28:19 +0200 Subject: [PATCH 2/2] [Fixes #110] Feature: add metadata license to resource base --- geonode/base/api/tests.py | 1 + 1 file changed, 1 insertion(+) diff --git a/geonode/base/api/tests.py b/geonode/base/api/tests.py index 4833a955484..644b980bc55 100644 --- a/geonode/base/api/tests.py +++ b/geonode/base/api/tests.py @@ -752,6 +752,7 @@ def test_resource_serializer_validation(self): category=TopicCategory.objects.get(identifier="elevation"), resource_type="dataset", license=License.objects.all().first(), + metadata_license=License.objects.all().first(), restriction_code_type=RestrictionCodeType.objects.all().first(), group=Group.objects.all().first(), ).save()