Skip to content
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

Draft
wants to merge 96 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
e51ee5d
Initial commit for the metadata architecture refactoring
Gpetrak Oct 11, 2024
afe2b79
improving the code
Gpetrak Oct 12, 2024
fbdb30a
update the first handler
Gpetrak Oct 14, 2024
65f477f
rename the file of the main schema
Gpetrak Oct 14, 2024
bafa137
fixing manage.py
Gpetrak Oct 14, 2024
47f1fa9
For testing a specific folder for json schemas examples was created
Gpetrak Oct 14, 2024
32fab1d
formatting the json schema files
Gpetrak Oct 14, 2024
506dc4e
update the json schema examples
Gpetrak Oct 15, 2024
b28305e
adding the metadata/schema endpoint under api/v2
Gpetrak Oct 17, 2024
972d638
rename the action of getting schema
Gpetrak Oct 17, 2024
28ede60
adding the metadata/instance/{pk} endpoint
Gpetrak Oct 18, 2024
9b71a99
adding handlers registry
Gpetrak Oct 20, 2024
da3b29f
update metadata manager
Gpetrak Oct 21, 2024
7be46be
update the metadata/{pk} to metadata/instance/{pk}
Gpetrak Oct 21, 2024
98542ee
update the /metadata/schema endpoint
Gpetrak Oct 21, 2024
d99183e
Handlers refactoring, i18n
etj Oct 21, 2024
0b464db
Merge branch 'metadata_manager' of github.com:GeoNode/geonode into me…
etj Oct 21, 2024
4423816
Add TKeywords subschema
etj Oct 21, 2024
4adabbe
Metadata TKeywords: fix max card
etj Oct 21, 2024
9450eab
TKeywords: Fix schema
etj Oct 21, 2024
9bbed4e
Tkeywords: void get_jsonschema_instance
etj Oct 21, 2024
1b1f589
TKeywords: Fix autocomplete; localization
etj Oct 22, 2024
028067c
Thesaurus schema: Improve localization
etj Oct 22, 2024
b161aa0
TKeywords: Improve autocomplete
etj Oct 23, 2024
963f480
adding PUT functionality to the endpoint metadata/instance/{pk}
Gpetrak Oct 22, 2024
6fc0047
rename the view of metadata/instance/{pk} endpoint
Gpetrak Oct 23, 2024
612a1f7
TKeywords: Improve autocomplete
etj Oct 23, 2024
f0ea8e8
TKeywords: move tkeywords just under category field
etj Oct 23, 2024
8e4bd6a
Many improvements and addings to the base handler
etj Oct 23, 2024
00d3c93
Some more improvements and addings to the base handler
etj Oct 23, 2024
ed7df68
Return proper json schema instance
etj Oct 24, 2024
41435ef
Return proper json schema instance
etj Oct 24, 2024
caae3d9
adding a handler for the regions field: RegionsHandler
Gpetrak Oct 24, 2024
ff45f10
Add DOI handler
etj Oct 24, 2024
9bc613d
Improvements and fixes
etj Oct 24, 2024
6957007
fixing Region autocomplete
Gpetrak Oct 24, 2024
94fd9ec
Add DOI handler
etj Oct 24, 2024
88a6a53
Simplify tkeywords schema
etj Oct 24, 2024
17d44ba
Merge branch 'metadata_manager' of https://github.com/GeoNode/geonode…
Gpetrak Oct 25, 2024
3f137d5
adding serialize method to other FKs of the BaseHandler
Gpetrak Oct 25, 2024
4bc01af
Extending PUT and removing serialization
Gpetrak Oct 25, 2024
e5b05a6
Fix PUT/PATCH
etj Oct 25, 2024
aa5afc8
Fixes: now patch returns without major errors
etj Oct 25, 2024
037ea1f
Storing FKs to the resource model
Gpetrak Oct 25, 2024
3d7e062
small improvements to store FK values
Gpetrak Oct 25, 2024
69dcc10
TKeywords get and patch working. Added i18n to instance request
etj Oct 25, 2024
481f5ea
Cleanup: black and flake
etj Oct 28, 2024
e2cc1c7
Added contacts schema.
etj Nov 4, 2024
b095a7a
Load+store contacts
etj Nov 4, 2024
aaf4f2f
Added linked resources handler
etj Nov 4, 2024
b4f1129
Regions autocomplete
etj Nov 5, 2024
d358c0a
Regions load/store
etj Nov 5, 2024
d472368
Extending the Regions autocomplete results
Gpetrak Nov 6, 2024
565f27d
format fixing
Gpetrak Nov 6, 2024
838a831
update the MetadataRegionsAutocomplete class
Gpetrak Nov 6, 2024
05a60b7
Metadata: review label i18n
etj Nov 20, 2024
337e781
Metadata: hkeywords handler - WIP
etj Nov 20, 2024
a039e16
Minor improvement
etj Nov 20, 2024
0ab811b
Metadata: hkeywords handler
etj Nov 21, 2024
64c41a9
Metadata: group handler
etj Nov 21, 2024
d1835ad
Metadata: set owner fields as required
etj Nov 22, 2024
ec7761f
Metadata: doi: implement update_resource
etj Nov 25, 2024
728a25a
Many improvements and fixes
etj Nov 28, 2024
857103f
Cleanup
etj Nov 28, 2024
dc9dd8c
Add error handling, Improve sparse field loading
etj Nov 29, 2024
d960746
Initial INSPIRE app
etj Nov 29, 2024
422cae8
May improvements: sparse fields, i18n,...
etj Dec 10, 2024
55c4ebc
Merge branch 'master' of https://github.com/GeoNode/geonode into meta…
Gpetrak Dec 10, 2024
1cfa446
tests for views
Gpetrak Dec 13, 2024
b89471e
adding more tests for views
Gpetrak Dec 13, 2024
ed76dfd
Tkeywords: hide property if no thesaurus configured
etj Dec 13, 2024
24bf1c8
Create test errors recursively
etj Dec 13, 2024
5316dbe
Recurse localization in complex sparse fields
etj Dec 13, 2024
ced8abe
Merge branch 'metadata_manager' of https://github.com/GeoNode/geonode…
Gpetrak Dec 17, 2024
99b1396
Metadata: fix contact roles
etj Dec 17, 2024
a619d02
Metadata: improve handling of None values in sparse fields
etj Dec 17, 2024
64bd634
Metadata: add authorization to metadata access
etj Dec 17, 2024
3172f75
Metadata: fix required rolenames
etj Dec 17, 2024
d33db5c
Metadata: improve type handling in sparse fields
etj Dec 17, 2024
ce36d86
adding tests for views and manager
Gpetrak Dec 18, 2024
8160a90
Metadata: improve handling of None values in sparse fields
etj Dec 18, 2024
73c4895
Metadata: tentative handling of categories via autocomplete
etj Dec 18, 2024
5ad930a
Metadata: tentative handling of categories via autocomplete
etj Dec 18, 2024
0eb0853
adding base handlers tests
Gpetrak Dec 18, 2024
e3defc2
Metadata: tentative handling of categories via autocomplete
etj Dec 18, 2024
f69ddde
Metadata: handling licenses via autocomplete
etj Dec 19, 2024
545a393
Black/flake
etj Dec 19, 2024
bd8d860
Fix i18n caching
etj Dec 19, 2024
352562d
adding more tests for the BaseHandler
Gpetrak Dec 19, 2024
98cfe08
Fix flake
etj Dec 19, 2024
e7b8045
Black/flake
etj Dec 19, 2024
bacbe51
Metadata: fix group handling
etj Dec 20, 2024
aef2940
Metadata: fix FK handling
etj Dec 20, 2024
a7dcf0a
adding tests for region and linkedrsources handers
Gpetrak Dec 20, 2024
0aa4d4e
Merge branch 'metadata_manager' of https://github.com/GeoNode/geonode…
Gpetrak Dec 20, 2024
8c1f40f
fixing tests
Gpetrak Dec 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion geonode/base/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def import_rdf(self, request):
if request.method == "POST":
try:
rdf_file = request.FILES["rdf_file"]
name = slugify(rdf_file.name)
name = slugify(rdf_file.name).removesuffix("-rdf")
call_command("load_thesaurus", file=rdf_file, name=name)
self.message_user(request, "Your RDF file has been imported", messages.SUCCESS)
return redirect("..")
Expand Down
22 changes: 17 additions & 5 deletions geonode/base/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1457,7 +1457,7 @@ def base_linked_resources(instance, user, params):
return Response(data={"message": e.args[0], "success": False}, status=500, exception=True)


def base_linked_resources_payload(instance, user, params={}):
def base_linked_resources_instances(instance, user, params={}):
resource_type = params.get("resource_type", None)
link_type = params.get("link_type", None)
type_list = resource_type.split(",") if resource_type else []
Expand Down Expand Up @@ -1498,7 +1498,7 @@ def base_linked_resources_payload(instance, user, params={}):
linked_to_visib_ids = linked_to_visib.values_list("id", flat=True)
linked_to = [lres for lres in linked_to_over_loopable if lres.target.id in linked_to_visib_ids]

ret["linked_to"] = LinkedResourceSerializer(linked_to, embed=True, many=True).data
ret["linked_to"] = linked_to

if not link_type or link_type == "linked_by":
linked_by_over = instance.get_linked_resources(as_target=True)
Expand All @@ -1517,11 +1517,23 @@ 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
ret["linked_by"] = linked_by

if not ret["WARNINGS"]:
ret.pop("WARNINGS")

return ret


def base_linked_resources_payload(instance, user, params={}):
lres = base_linked_resources_instances(instance, user, params)
ret = {
"linked_to": LinkedResourceSerializer(lres["linked_to"], embed=True, many=True).data,
"linked_by": LinkedResourceSerializer(
instance=lres["linked_by"], serialize_source=True, embed=True, many=True
).data,
}
if lres.get("WARNINGS", None):
ret["WARNINGS"] = lres["WARNINGS"]

return ret
6 changes: 0 additions & 6 deletions geonode/base/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
OwnerRightsRequestView,
ResourceBaseAutocomplete,
HierarchicalKeywordAutocomplete,
ThesaurusKeywordLabelAutocomplete,
LinkedResourcesAutocomplete,
)

Expand Down Expand Up @@ -57,11 +56,6 @@
ThesaurusAvailable.as_view(),
name="thesaurus_available",
),
re_path(
r"^thesaurus_autocomplete/$",
ThesaurusKeywordLabelAutocomplete.as_view(),
name="thesaurus_autocomplete",
),
re_path(
r"^datasets_autocomplete/$",
DatasetsAutocomplete.as_view(),
Expand Down
26 changes: 0 additions & 26 deletions geonode/base/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,32 +334,6 @@ class HierarchicalKeywordAutocomplete(SimpleSelect2View):
filter_arg = "slug__icontains"


class ThesaurusKeywordLabelAutocomplete(autocomplete.Select2QuerySetView):
def get_queryset(self):
thesaurus = settings.THESAURUS
tname = thesaurus["name"]
lang = "en"

# Filters thesaurus results based on thesaurus name and language
qs = ThesaurusKeywordLabel.objects.all().filter(keyword__thesaurus__identifier=tname, lang=lang)

if self.q:
qs = qs.filter(label__icontains=self.q)

return qs

# Overides the get results method to return custom json to frontend
def get_results(self, context):
return [
{
"id": self.get_result_value(result.keyword),
"text": self.get_result_label(result),
"selected_text": self.get_selected_result_label(result),
}
for result in context["object_list"]
]


class DatasetsAutocomplete(SimpleSelect2View):
model = Dataset
filter_arg = "title__icontains"
Expand Down
Empty file added geonode/inspire/__init__.py
Empty file.
32 changes: 32 additions & 0 deletions geonode/inspire/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#########################################################################
#
# Copyright (C) 2024 OSGeo
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#########################################################################
from django.apps import AppConfig

from geonode.notifications_helper import NotificationsAppConfigBase


class BaseAppConfig(NotificationsAppConfigBase, AppConfig):
name = "geonode.inspire"

def ready(self):
super().ready()

from geonode.inspire.metadata import init

init()
Loading
Loading