Skip to content

Commit

Permalink
views: allow list view to receive a pid_value
Browse files Browse the repository at this point in the history
this is desired when you want to use a list view as a details page
  • Loading branch information
carlinmack committed May 22, 2024
1 parent 50d024e commit 931dd81
Showing 1 changed file with 26 additions and 23 deletions.
49 changes: 26 additions & 23 deletions invenio_administration/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,32 +385,35 @@ def get_available_facets(self):
return self.resource.service.config.search.facets
return self.available_facets

def get(self):
"""GET view method."""
def get_context(self, **kwargs):
search_conf = self.init_search_config()
schema = self.get_service_schema()
serialized_schema = self._schema_to_json(schema)
return self.render(
**{
"search_config": search_conf,
"title": self.title,
"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,
"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
),
}
)
pid_value = kwargs.get("pid_value", "")
return {
"search_config": search_conf,
"title": self.title,
"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
),
}

def get(self, **kwargs):
"""GET view method."""
return self.render(**self.get_context(**kwargs))


class AdminResourceViewSet:
Expand Down

0 comments on commit 931dd81

Please sign in to comment.