Skip to content

Commit

Permalink
use constraints fully working
Browse files Browse the repository at this point in the history
  • Loading branch information
silvadealmeida committed Aug 21, 2024
1 parent 6034c57 commit 6004159
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion 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
12 changes: 9 additions & 3 deletions geonode/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,10 +791,13 @@ class ResourceBase(PolymorphicModel, PermissionLevelMixin, ItemBase):
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.")
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 @@ -959,9 +962,12 @@ class ResourceBase(PolymorphicModel, PermissionLevelMixin, ItemBase):
verbose_name=_("Use Constrain Restrictions"),
null=True,
blank=True,
help_text=use_constraint_restrictions_help_text,
)

use_constraints = models.TextField(_("Use Constraints"), null=True, blank=True)
use_constraints = models.TextField(
_("Use Constraints"), null=True, blank=True, help_text=constraints_other_help_text
)
restriction_other = models.ManyToManyField(
RestrictionCodeType,
verbose_name=_("restrictions"),
Expand Down
8 changes: 8 additions & 0 deletions geonode/layers/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,14 @@ def dataset_metadata(
layer.regions.add(*new_regions)
layer.category = new_category

use_constraint_restrictions = [x for x in dataset_form.cleaned_data["use_constraint_restrictions"]]
if use_constraint_restrictions:
layer.use_constraint_restrictions.add(*use_constraint_restrictions)

restriction_other = [x for x in dataset_form.cleaned_data["restriction_other"]]
if restriction_other:
layer.restriction_other.add(*restriction_other)

from geonode.upload.models import Upload

up_sessions = Upload.objects.filter(resource_id=layer.resourcebase_ptr_id)
Expand Down
1 change: 0 additions & 1 deletion geonode/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2165,7 +2165,6 @@ def get_geonode_catalogue_service():
"id_resource-date",
"category_form",
"id_resource-attribution",
"id_resource-constraints_other",
"id_resource-data_quality_statement",
]
UI_REQUIRED_FIELDS = ast.literal_eval(os.getenv("UI_REQUIRED_FIELDS ", "[]"))
Expand Down

0 comments on commit 6004159

Please sign in to comment.