From 6034c57d1ed0e469fc7d59dd7d78ad4f50ff74bb Mon Sep 17 00:00:00 2001 From: silvadealmeida Date: Wed, 21 Aug 2024 11:01:11 +0200 Subject: [PATCH] update use constrains to use constraints and solve bug in related idenfiers --- geonode/api/resourcebase_api.py | 2 +- geonode/base/api/serializers.py | 4 ++-- geonode/base/forms.py | 2 +- geonode/base/models.py | 13 +++++++------ 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/geonode/api/resourcebase_api.py b/geonode/api/resourcebase_api.py index 92ebbf870f8..23bb9135539 100644 --- a/geonode/api/resourcebase_api.py +++ b/geonode/api/resourcebase_api.py @@ -114,7 +114,7 @@ class CommonModelApi(ModelResource): "purpose", "maintenance_frequency", "use_constraint_restrictions", - "use_constrains", + "use_constraints", "restriction_other", "constraints_other", "license", diff --git a/geonode/base/api/serializers.py b/geonode/base/api/serializers.py index c00940f7331..993491c067c 100644 --- a/geonode/base/api/serializers.py +++ b/geonode/base/api/serializers.py @@ -714,7 +714,7 @@ def __init__(self, *args, **kwargs): self.fields["use_constraint_restrictions"] = ComplexDynamicRelationField( RestrictionCodeTypeSerializer, embed=True, many=True ) - self.fields["use_constrains"] = serializers.CharField(read_only=True) + self.fields["use_constraints"] = serializers.CharField(read_only=True) self.fields["restriction_other"] = ComplexDynamicRelationField( RestrictionCodeTypeSerializer, embed=True, many=True ) @@ -795,7 +795,7 @@ class Meta: "purpose", "maintenance_frequency", "use_constraint_restrictions", - "use_constrains", + "use_constraints", "constraints_other", "restriction_other", "license", diff --git a/geonode/base/forms.py b/geonode/base/forms.py index 08dc901297b..700fcf25bcc 100644 --- a/geonode/base/forms.py +++ b/geonode/base/forms.py @@ -524,7 +524,7 @@ class ResourceBaseForm(TranslationModelForm, LinkedResourceForm): widget=forms.SelectMultiple(attrs={"class": "bg-primary"}), required=False, ) - use_constrains = forms.CharField(label=_("Use Constraints"), required=False, widget=TinyMCE()) + use_constraints = forms.CharField(label=_("Use Constraints"), required=False, widget=TinyMCE()) constraints_other = forms.CharField(label=_("Other constraints"), required=False, widget=TinyMCE()) supplemental_information = forms.CharField(label=_("Supplemental information"), required=False, widget=TinyMCE()) diff --git a/geonode/base/models.py b/geonode/base/models.py index ccd312f1c7a..3cba28b3667 100644 --- a/geonode/base/models.py +++ b/geonode/base/models.py @@ -672,9 +672,9 @@ def __str__(self): class RelatedIdentifier(models.Model): related_identifer_help_text = _("Identifiers of related resources. These must be globally unique identifiers.") - related_identifier = models.CharField(max_length=255, help_text=related_identifer_help_text) - related_identifier_type = models.ForeignKey(RelatedIdentifierType, on_delete=models.CASCADE) - relation_type = models.ForeignKey(RelationType, on_delete=models.CASCADE) + related_identifier = models.CharField(max_length=255, help_text=related_identifer_help_text, blank=True) + related_identifier_type = models.ForeignKey(RelatedIdentifierType, null=True, blank=True, on_delete=models.CASCADE) + relation_type = models.ForeignKey(RelationType, null=True, blank=True, on_delete=models.CASCADE) def __str__(self): return f"Related Identifier: {self.related_identifier}({self.relation_type}: {self.related_identifier_type})" @@ -788,7 +788,7 @@ class ResourceBase(PolymorphicModel, PermissionLevelMixin, ItemBase): "(space or comma-separated)" ) regions_help_text = _("keyword identifies a location") - use_constrains_help_text = _( + use_constraints_help_text = _( "This metadata element shall provide information on the Use constraints applied to assure the protection of privacy or intellectual property (e.g. Trademark)" ) restriction_other_help_text = _("limitation(s) placed upon the access or use of the data.") @@ -961,7 +961,7 @@ class ResourceBase(PolymorphicModel, PermissionLevelMixin, ItemBase): blank=True, ) - use_constrains = models.TextField(_("Use Constraints"), null=True, blank=True) + use_constraints = models.TextField(_("Use Constraints"), null=True, blank=True) restriction_other = models.ManyToManyField( RestrictionCodeType, verbose_name=_("restrictions"), @@ -1143,10 +1143,11 @@ class ResourceBase(PolymorphicModel, PermissionLevelMixin, ItemBase): # Bonares related_identifier = models.ManyToManyField( RelatedIdentifier, - verbose_name=_("Related Identifier"), null=True, blank=True, help_text=related_identifer_help_text, + # related_name="related_identifier", + verbose_name=_("Related Identifier"), ) funders = models.ManyToManyField( Funder, verbose_name=_("Funder names"), null=True, blank=True, help_text=funders_help_text