Skip to content

Commit

Permalink
formatting: run isort and black
Browse files Browse the repository at this point in the history
  • Loading branch information
SarahW91 committed Jul 16, 2024
1 parent 8147305 commit f6ba1dc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 27 deletions.
32 changes: 17 additions & 15 deletions invenio_vocabularies/administration/views/vocabularies.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2020-2024 CERN.
# 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 functools import partial
from invenio_search_ui.searchconfig import search_app_config, SortConfig, FacetsConfig
from invenio_administration.views.base import (
AdminResourceEditView,
AdminResourceListView,
)

from flask import current_app
from invenio_administration.views.base import AdminResourceListView
from invenio_search_ui.searchconfig import FacetsConfig, SortConfig, search_app_config


class VocabulariesListView(AdminResourceListView):
Expand Down Expand Up @@ -62,7 +60,9 @@ def get_api_endpoint(self, pid_value=None):
def init_search_config(self, **kwargs):
"""Build search view config."""
pid_value = kwargs.get("pid_value", "")
custom_search_config = current_app.config[self.search_config_name].get(pid_value)
custom_search_config = current_app.config[self.search_config_name].get(
pid_value
)

if custom_search_config:
available_sort_options = current_app.config[self.search_sort_config_name]
Expand All @@ -75,10 +75,12 @@ def init_search_config(self, **kwargs):
sort_options=available_sort_options,
endpoint=self.get_api_endpoint(**kwargs),
headers=self.get_search_request_headers(**kwargs),
sort=SortConfig(available_sort_options,
custom_search_config["sort"],
custom_search_config["sort_default"],
custom_search_config["sort_default_no_query"]),
sort=SortConfig(
available_sort_options,
custom_search_config["sort"],
custom_search_config["sort_default"],
custom_search_config["sort_default_no_query"],
),
facets=FacetsConfig(available_facets, custom_search_config["facets"]),
)
else:
Expand All @@ -96,9 +98,9 @@ def get(self, **kwargs):
if custom_config:
parent_context.update(custom_config)
else:
parent_context.update({
"title": f"{pid_value.capitalize()} vocabulary items"
})
parent_context.update(
{"title": f"{pid_value.capitalize()} vocabulary items"}
)

return self.render(**parent_context)

Expand Down
24 changes: 12 additions & 12 deletions invenio_vocabularies/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,36 +176,36 @@
"facets": [],
"sort": ["name"],
"sort_default": "name",
"sort_default_no_query": "name"
"sort_default_no_query": "name",
},
"awards": {
"facets": [],
"sort": ["name"],
"sort_default": "name",
"sort_default_no_query": "name"
"sort_default_no_query": "name",
},
"funders": {
"facets": [],
"sort": ["name"],
"sort_default": "name",
"sort_default_no_query": "name"
"sort_default_no_query": "name",
},
"names": {
"facets": [],
"sort": ["name"],
"sort_default": "name",
"sort_default_no_query": "name"
"sort_default_no_query": "name",
},
"subjects": {
"facets": [],
"sort": ["subject"],
"sort_default": "subject",
"sort_default_no_query": "subject"
"sort_default_no_query": "subject",
},
"facets": [],
"sort": ["title"],
"sort_default": "title",
"sort_default_no_query": "title"
"sort_default_no_query": "title",
}
"""Vocabulary type item search configurations per type and for generic vocabularies."""

Expand All @@ -222,7 +222,7 @@
display_edit=True,
display_read=True,
pid_path="id",
resource_name="name"
resource_name="name",
),
"awards": dict(
title="Awards vocabulary items",
Expand All @@ -236,7 +236,7 @@
display_edit=True,
display_read=True,
pid_path="id",
resource_name="name"
resource_name="name",
),
"funders": dict(
title="Funders vocabulary items",
Expand All @@ -250,7 +250,7 @@
display_edit=True,
display_read=True,
pid_path="id",
resource_name="name"
resource_name="name",
),
"names": dict(
title="Names vocabulary items",
Expand All @@ -264,7 +264,7 @@
display_edit=True,
display_read=True,
pid_path="id",
resource_name="name"
resource_name="name",
),
"subjects": dict(
title="Subjects vocabulary items",
Expand All @@ -278,6 +278,6 @@
display_edit=True,
display_read=True,
pid_path="id",
resource_name="subject"
)
resource_name="subject",
),
}

0 comments on commit f6ba1dc

Please sign in to comment.