-
Notifications
You must be signed in to change notification settings - Fork 42
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
Vocabulary item view #347
Open
SarahW91
wants to merge
41
commits into
inveniosoftware:master
Choose a base branch
from
ulbmuenster:vocabulary_item_view
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Vocabulary item view #347
Changes from 36 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
d77a180
register new route
karkraeg 0b5aaaa
Implemented first Admin view based on mock API
karkraeg 4d3365b
add copyright
karkraeg f7404c0
remove WIP import
karkraeg 009be0a
remove more imports
karkraeg fb36717
provide API endpoint with aggregated counts for all types of vocabula…
karkraeg c0377de
add missing invenio-administration dependency
karkraeg dd1420d
Add and update docstrings
SarahW91 ebd3363
dirty commit, added resources
karkraeg 9bf7e2a
fix imports and cleanup
karkraeg ff50270
cleanup
karkraeg 8965685
overwrite api endpoint
karkraeg f405b4b
Fixes after review. Take out additional list view for now until it is…
SarahW91 3601b15
Fixed formatting and doc strings.
SarahW91 b2a3c93
Fixed formatting
SarahW91 0fc61ae
vocabulary types: Implement query functionality
SarahW91 43f25da
vocabulary types: Show count in list view
SarahW91 9de7fd2
vocabulary types: Implement sorting
SarahW91 a5e1f90
vocabulary type endpoint: fix formatting
SarahW91 78bec3d
vocabulary types endpoint: split implementation for service, config a…
SarahW91 fe43685
services: fix service proxy
karkraeg edfdf53
vocabulary types administration: Fix sidebar menu name and remove cre…
SarahW91 22f7835
vocabulary types administration: Add Uni Münster copyright notice.
SarahW91 5657042
vocabulary types administration tests: Use correct service for tests
SarahW91 2555b8e
Merge branch 'master' into all_vocabularies_endpoint
SarahW91 842f5c3
vocabulary types: cleanup
SarahW91 6c79b8b
vocabulary types items: add vocabulary items list view
SarahW91 ba10dcb
vocabulary types items: account for different sort options on differe…
SarahW91 b0a4bb7
vocabulary types items: add display fields for items
SarahW91 f210d7c
vocabulary types items: add subject column
SarahW91 9056ac3
Merge branch 'inveniosoftware:master' into vocabulary_item_view
SarahW91 1cbf807
Capitalize vocabulary type name in items view
SarahW91 8cf3e43
vocabulary item list view: Fixed formatting and pydocstyle
SarahW91 99f299d
vocabulary types: remove schema property from VocabularyTypeService
SarahW91 7475321
vocabulary types: remove unused read response handler from Vocabulari…
SarahW91 9d4ccbb
vocabulary types: rename route and response handler of VocabulariesAd…
SarahW91 9a2a0d7
vocabulary item list view: Avoid code duplication by overwriting get …
SarahW91 c9f79e8
vocabulary item list view: make view ui customizable via config.py
SarahW91 75240e9
vocabulary item list view: add resource name to config
SarahW91 8147305
Merge branch 'master' into vocabulary_item_view
SarahW91 f6ba1dc
formatting: run isort and black
SarahW91 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (C) 2024 CERN. | ||
# Copyright (C) 2024 Uni Münster. | ||
# | ||
# Invenio-Vocabularies is free software; you can redistribute it and/or | ||
# modify it under the terms of the MIT License; see LICENSE file for more | ||
# details. | ||
|
||
"""Invenio administration views module for vocabularies.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (C) 2020-2021 CERN. | ||
# Copyright (C) 2024 Uni Münster. | ||
# | ||
# Invenio-Vocabularies is free software; you can redistribute it and/or | ||
# modify it under the terms of the MIT License; see LICENSE file for more | ||
# details. | ||
|
||
"""Invenio administration views module for Vocabularies.""" |
118 changes: 118 additions & 0 deletions
118
invenio_vocabularies/administration/views/vocabularies.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (C) 2020-2021 CERN. | ||
# Copyright (C) 2024 Uni Münster. | ||
# | ||
# Invenio-Vocabularies is free software; you can redistribute it and/or | ||
# modify it under the terms of the MIT License; see LICENSE file for more | ||
# details. | ||
|
||
"""Vocabularies admin interface.""" | ||
from flask import current_app | ||
from invenio_administration.views.base import AdminResourceListView | ||
|
||
|
||
class VocabulariesListView(AdminResourceListView): | ||
"""Configuration for vocabularies list view.""" | ||
|
||
api_endpoint = "/vocabularies/" | ||
name = "vocabulary-types" | ||
menu_label = "Vocabulary Types" | ||
resource_config = "vocabulary_admin_resource" | ||
search_request_headers = {"Accept": "application/json"} | ||
title = "Vocabulary Types" | ||
category = "Site management" | ||
|
||
pid_path = "id" | ||
icon = "exchange" | ||
template = "invenio_administration/search.html" | ||
|
||
display_search = True | ||
display_delete = False | ||
display_edit = False | ||
display_create = False | ||
|
||
item_field_list = { | ||
"id": {"text": "Name", "order": 1}, | ||
"count": {"text": "Number of entries", "order": 2}, | ||
} | ||
|
||
search_config_name = "VOCABULARIES_TYPES_SEARCH" | ||
search_facets_config_name = "VOCABULARIES_TYPES_FACETS" | ||
search_sort_config_name = "VOCABULARIES_TYPES_SORT_OPTIONS" | ||
|
||
|
||
class VocabularyDetailsListView(AdminResourceListView): | ||
"""Configuration for vocabularies list view.""" | ||
|
||
def get_api_endpoint(self, pid_value=None): | ||
"""Overwrite get_api_endpoint to accept pid_value.""" | ||
if pid_value in current_app.config.get( | ||
"VOCABULARIES_CUSTOM_VOCABULARY_TYPES", [] | ||
): | ||
return f"/api/{pid_value}" | ||
else: | ||
return f"/api/vocabularies/{pid_value}" | ||
|
||
def get_context(self, **kwargs): | ||
SarahW91 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"""Create details view context.""" | ||
search_conf = self.init_search_config(**kwargs) | ||
schema = self.get_service_schema() | ||
serialized_schema = self._schema_to_json(schema) | ||
pid_value = kwargs.get("pid_value", "") | ||
return { | ||
"search_config": search_conf, | ||
"title": f"{pid_value.capitalize()} vocabulary items", | ||
"name": self.name, | ||
"resource_schema": serialized_schema, | ||
"fields": self.item_field_list, | ||
"display_search": self.display_search, | ||
"display_create": self.display_create, | ||
"display_edit": self.display_edit, | ||
"display_delete": self.display_delete, | ||
"display_read": self.display_read, | ||
"actions": self.serialize_actions(), | ||
"pid_path": self.pid_path, | ||
"pid_value": pid_value, | ||
"create_ui_endpoint": self.get_create_view_endpoint(), | ||
"list_ui_endpoint": self.get_list_view_endpoint(), | ||
"resource_name": ( | ||
self.resource_name if self.resource_name else self.pid_path | ||
), | ||
} | ||
SarahW91 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
name = "vocabulary-type-items" | ||
url = "/vocabulary-types/<pid_value>" | ||
|
||
api_endpoint = "/vocabularies/" | ||
|
||
# INFO name of the resource's list view name, enables navigation between items view and types view. | ||
list_view_name = "vocabulary-types" | ||
|
||
resource_config = "vocabulary_admin_resource" | ||
search_request_headers = {"Accept": "application/json"} | ||
|
||
pid_path = "id" | ||
|
||
# INFO only if disabled() (as a function) it's not in the sidebar, see https://github.com/inveniosoftware/invenio-administration/blob/main/invenio_administration/menu/menu.py#L54 | ||
disabled = lambda _: True | ||
|
||
template = "invenio_administration/search.html" | ||
|
||
display_delete = False | ||
display_create = False | ||
display_edit = True | ||
display_search = True | ||
|
||
# TODO: It would be nicer to choose the correct column depending on the vocabulary | ||
# TODO: It would ne nicer to use the title's translation in the currently selected language and fall back to English if this doesn't exist | ||
item_field_list = { | ||
"name": {"text": "Name", "order": 0}, | ||
"title['en']": {"text": "Title [en]", "order": 1}, | ||
"subject": {"text": "Subject", "order": 2}, | ||
"created": {"text": "Created", "order": 3}, | ||
} | ||
|
||
search_config_name = "VOCABULARIES_TYPES_ITEMS_SEARCH" | ||
search_facets_config_name = "VOCABULARIES_TYPES_ITEMS_FACETS" | ||
search_sort_config_name = "VOCABULARIES_TYPES_ITEMS_SORT_OPTIONS" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Have you considered inheriting from both Details and List views?
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.
Not yet. Could you explain how that might help with our issues?
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 would ensure less ambiguity on where the methods are actually coming from, this class now only imitates the interface of AdminResourceDetails view in order to use some of its frontend functionalities, while it does not actually inherit from the class itself. It might create divergence on the implementation of these "virtually" inherited methods the code it will be harder to maintain.
So to answer your question, it does not solve immediate problems but prevents ambiguity in the future