-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GNIP 97: New metadata editor #12794
base: master
Are you sure you want to change the base?
GNIP 97: New metadata editor #12794
Conversation
Hi @gannebamm, happy new year! |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #12794 +/- ##
==========================================
+ Coverage 67.00% 67.95% +0.95%
==========================================
Files 952 975 +23
Lines 56912 58883 +1971
Branches 6725 6886 +161
==========================================
+ Hits 38134 40016 +1882
- Misses 17166 17229 +63
- Partials 1612 1638 +26 |
@@ -1517,11 +1517,25 @@ def base_linked_resources_payload(instance, user, params={}): | |||
linked_by_visib_ids = linked_by_visib.values_list("id", flat=True) | |||
linked_by = [lres for lres in linked_by_over_loopable if lres.source.id in linked_by_visib_ids] | |||
|
|||
ret["linked_by"] = LinkedResourceSerializer( | |||
instance=linked_by, serialize_source=True, embed=True, many=True | |||
).data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any reason why the serializer is no longer used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is used indeed.
Please note that the code you're pointing to has changed name from base_linked_resources_payload
to base_linked_resources_instances
. The new base_linked_resources_payload
calls base_linked_resources_instances
(now also used elsewere for DRY), and still uses the serializer, returning the same content as before.
geonode/inspire/metadata.py
Outdated
CONTEXT_ID = "inspire" | ||
|
||
|
||
class INSPIREHandler(MetadataHandler): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my undestanding, the inspire app is not totally required, is more a documentation app. If is not used, i would propose to switch it as documentation or if is needed for testing purpose only, i would document this and move the app in the tests.
Is open to discussion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls note that I used the inspire app for an example in this very thread (#12794 (comment)). It is a really good point for documentation and testing handler overriding. I know it is something not used outside Europe, but I guess we need some real override implementation inside geonode.
geonode/metadata/api/views.py
Outdated
perms_dict={ | ||
"default": { | ||
"GET": ["base.view_resourcebase"], | ||
"POST": ["change_resourcebase_metadata"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be PUT si is the method used in the function?
I am not sure to be ready to do a helpful review from my position. However, I was wondering why the schema will include geonode specific properties like |
Hi @ridoo
|
# override base schema: was a codelist, is a fixed value in the codelist | |
jsonschema["properties"][FIELD_RESTRICTION_TYPE] = { | |
"type": "string", | |
"title": "restrictions", | |
"ui:widget": "hidden", | |
"geonode:handler": "inspire", | |
} |
geonode:required
so for which cases geonode:required is necessary?
JSON schema defines the required fields (using the annotation required
) in a level above the sub schema definition.
The handlers only work on their own sub schema.
The MetadataManager
uses the geonode:required
custom annotations to build the upper level required
array:
geonode/geonode/metadata/manager.py
Lines 78 to 85 in 7e81443
# Set required fields. | |
required = [] | |
for fieldname, field in schema["properties"].items(): | |
if field.get("geonode:required", False): | |
required.append(fieldname) | |
if required: | |
schema["required"] = required |
Complete rewriting of the metadata editor according to GNIP 97
Checklist
For all pull requests:
The following are required only for core and extension modules (they are welcomed, but not required, for contrib modules):
Submitting the PR does not require you to check all items, but by the time it gets merged, they should be either satisfied or inapplicable.