Skip to content

Commit

Permalink
Merge pull request #163 from zalf-rdm/issue_#112_use_constraints
Browse files Browse the repository at this point in the history
Issue #112 use constraints
  • Loading branch information
silvadealmeida authored Aug 21, 2024
2 parents 73ca001 + 6004159 commit 3907ec1
Show file tree
Hide file tree
Showing 21 changed files with 4,155 additions and 2,027 deletions.
4 changes: 3 additions & 1 deletion geonode/api/resourcebase_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ class CommonModelApi(ModelResource):
"edition",
"purpose",
"maintenance_frequency",
"restriction_code_type",
"use_constraint_restrictions",
"use_constraints",
"restriction_other",
"constraints_other",
"license",
"language",
Expand Down
14 changes: 9 additions & 5 deletions geonode/base/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ def __init__(self, *args, **kwargs):
self.fields["edition"] = serializers.CharField(required=False)
self.fields["purpose"] = serializers.CharField(required=False)
self.fields["maintenance_frequency"] = serializers.CharField(required=False)
self.fields["constraints_other"] = serializers.CharField(required=False)

self.fields["language"] = serializers.CharField(required=False)
self.fields["supplemental_information"] = serializers.CharField(required=False)
self.fields["data_quality_statement"] = serializers.CharField(required=False)
Expand Down Expand Up @@ -710,12 +710,15 @@ def __init__(self, *args, **kwargs):
self.fields["tkeywords"] = ComplexDynamicRelationField(SimpleThesaurusKeywordSerializer, embed=False, many=True)
self.fields["regions"] = DynamicRelationField(SimpleRegionSerializer, embed=True, many=True, read_only=True)
self.fields["category"] = ComplexDynamicRelationField(SimpleTopicCategorySerializer, embed=True, many=False)
self.fields["restriction_code_type"] = ComplexDynamicRelationField(

self.fields["use_constraint_restrictions"] = ComplexDynamicRelationField(
RestrictionCodeTypeSerializer, embed=True, many=True
)
self.fields["use_constrains"] = ComplexDynamicRelationField(
self.fields["use_constraints"] = serializers.CharField(read_only=True)
self.fields["restriction_other"] = ComplexDynamicRelationField(
RestrictionCodeTypeSerializer, embed=True, many=True
)
self.fields["constraints_other"] = serializers.CharField(read_only=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(
Expand Down Expand Up @@ -791,9 +794,10 @@ class Meta:
"edition",
"purpose",
"maintenance_frequency",
"restriction_code_type",
"use_constrains",
"use_constraint_restrictions",
"use_constraints",
"constraints_other",
"restriction_other",
"license",
"language",
"spatial_representation_type",
Expand Down
9 changes: 8 additions & 1 deletion geonode/base/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
LinkedResource,
Region,
ResourceBase,
RestrictionCodeType,
Thesaurus,
ThesaurusKeyword,
ThesaurusKeywordLabel,
Expand Down Expand Up @@ -517,7 +518,13 @@ class ResourceBaseForm(TranslationModelForm, LinkedResourceForm):
)

purpose = forms.CharField(label=_("Purpose"), required=False, widget=TinyMCE())

use_constraint_restrictions = forms.ModelMultipleChoiceField(
RestrictionCodeType.objects.all(),
# widget=forms.SelectMultiple,
widget=forms.SelectMultiple(attrs={"class": "bg-primary"}),
required=False,
)
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())
Expand Down
52 changes: 25 additions & 27 deletions geonode/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class RestrictionCodeType(models.Model):
is_choice = models.BooleanField(default=True)

def __str__(self):
return str(self.gn_description)
return str(self.identifier)

class Meta:
ordering = ("identifier",)
Expand Down Expand Up @@ -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})"
Expand Down Expand Up @@ -788,13 +788,16 @@ 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_code_type_help_text = _("limitation(s) placed upon the access or use of the data.")
use_constraint_restrictions_help_text = _("limitation(s) placed upon the access or use of the data by Admin.")
use_constraints_help_text = _("limitation(s) placed upon the access or use of the data by Admin.")
restriction_other_help_text = _("limitation(s) placed upon the access or use of the data by User.")
constraints_other_help_text = _(
"other restrictions and legal prerequisites for accessing and using the resource or" " metadata"
"other restrictions and legal prerequisites for accessing and using the resource or metadata by User"
)

license_help_text = _("license of the dataset")
metadata_license_help_text = _("license of the metadata")
language_help_text = _("language used within the dataset")
Expand Down Expand Up @@ -953,22 +956,25 @@ class ResourceBase(PolymorphicModel, PermissionLevelMixin, ItemBase):
regions = models.ManyToManyField(
Region, verbose_name=_("keywords region"), null=True, blank=True, help_text=regions_help_text
)
use_constrains = models.ManyToManyField(

use_constraint_restrictions = models.ManyToManyField(
RestrictionCodeType,
verbose_name=_("use_constrains"),
help_text=use_constrains_help_text,
verbose_name=_("Use Constrain Restrictions"),
null=True,
blank=True,
related_name="use_constrains",
limit_choices_to=Q(is_choice=True),
help_text=use_constraint_restrictions_help_text,
)

use_constraints = models.TextField(
_("Use Constraints"), null=True, blank=True, help_text=constraints_other_help_text
)
restriction_code_type = models.ManyToManyField(
restriction_other = models.ManyToManyField(
RestrictionCodeType,
verbose_name=_("restrictions"),
help_text=restriction_code_type_help_text,
help_text=restriction_other_help_text,
null=True,
blank=True,
related_name="restriction_code_type",
related_name="restriction_other",
limit_choices_to=Q(is_choice=True),
)
constraints_other = models.TextField(
Expand Down Expand Up @@ -1143,10 +1149,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
Expand All @@ -1160,15 +1167,6 @@ class ResourceBase(PolymorphicModel, PermissionLevelMixin, ItemBase):
verbose_name=_("Related Project"),
)

use_contraints = models.TextField(
_("use_constraints"),
max_length=2000,
blank=True,
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)"
),
)

objects = ResourceBaseManager()

class Meta:
Expand Down Expand Up @@ -1377,7 +1375,7 @@ def organizationname(self):

@property
def restriction_code(self):
return self.restriction_code_type.gn_description if self.restriction_code_type else None
return self.restriction_other.gn_description if self.restriction_other else None

@property
def topiccategory(self):
Expand Down Expand Up @@ -1512,7 +1510,7 @@ def metadata_completeness(self):
"regions",
"title",
]
if self.restriction_code_type == "otherRestrictions":
if self.restriction_other == "otherRestrictions":
required_fields.append("constraints_other")
filled_fields = []
for required_field in required_fields:
Expand Down
Loading

0 comments on commit 3907ec1

Please sign in to comment.