From eead7d15a19a623031c51319f5bf0c43fc3a6a67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=CC=81bastien=20De=CC=81le=CC=80ze?= Date: Tue, 25 Jun 2019 11:00:43 +0200 Subject: [PATCH] global: Code formatting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BETTER Format python code with Black BETTER Format html templates with Jinja extension Signed-off-by: Sébastien Délèze --- docs/conf.py | 199 +++++++++--------- setup.py | 120 +++++------ sonar/__init__.py | 2 +- sonar/modules/api.py | 24 +-- sonar/modules/cli.py | 1 + sonar/modules/documents/__init__.py | 2 +- sonar/modules/documents/api.py | 10 +- sonar/modules/documents/config.py | 7 +- sonar/modules/documents/ext.py | 4 +- .../modules/documents/marshmallow/__init__.py | 2 +- .../templates/documents/search_ui/count.html | 4 +- .../templates/documents/search_ui/facets.html | 81 ++++--- .../documents/search_ui/loading.html | 2 +- .../documents/search_ui/pagination.html | 14 +- .../documents/search_ui/select_box.html | 6 +- .../documents/search_ui/sort_order.html | 3 +- sonar/modules/ext.py | 4 +- sonar/modules/fetchers.py | 8 +- sonar/modules/institutions/__init__.py | 2 +- sonar/modules/institutions/api.py | 8 +- sonar/modules/institutions/cli.py | 23 +- sonar/modules/institutions/ext.py | 2 +- sonar/modules/institutions/jsonresolvers.py | 9 +- .../institutions/marshmallow/__init__.py | 2 +- sonar/modules/minters.py | 5 +- sonar/modules/providers.py | 14 +- sonar/theme/__init__.py | 2 +- sonar/theme/templates/sonar/401.html | 6 +- sonar/theme/templates/sonar/403.html | 6 +- sonar/theme/templates/sonar/404.html | 7 +- sonar/theme/templates/sonar/500.html | 10 +- .../sonar/accounts/forgot_password.html | 57 ++--- sonar/theme/templates/sonar/admin_header.html | 48 ++--- sonar/theme/templates/sonar/admin_layout.html | 106 +++++----- sonar/theme/templates/sonar/breadcrumbs.html | 32 +-- sonar/theme/templates/sonar/contact.html | 2 +- sonar/theme/templates/sonar/footer.html | 8 +- sonar/theme/templates/sonar/frontpage.html | 124 +++++------ sonar/theme/templates/sonar/javascript.html | 2 +- sonar/theme/templates/sonar/macros/macro.html | 12 +- .../templates/sonar/macros/messages.html | 24 +-- sonar/theme/templates/sonar/page_admin.html | 173 +++++++-------- sonar/theme/templates/sonar/page_cover.html | 89 ++++---- sonar/theme/templates/sonar/page_error.html | 10 +- .../theme/templates/sonar/page_settings.html | 68 +++--- sonar/theme/templates/sonar/search.html | 144 ++++++------- sonar/theme/templates/sonar/trackingcode.html | 2 +- sonar/theme/views.py | 9 +- sonar/theme/webpack.py | 20 +- sonar/version.py | 2 +- tests/api/conftest.py | 2 +- tests/e2e/conftest.py | 2 +- tests/e2e/test_front_page.py | 7 +- tests/test_version.py | 1 + tests/ui/conftest.py | 2 +- tests/ui/institutions/test_jsonresolvers.py | 23 +- tests/ui/test_api.py | 35 ++- tests/ui/test_fetchers.py | 2 +- tests/ui/test_views.py | 2 +- 59 files changed, 781 insertions(+), 816 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index d531fe912..a0668d4d6 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -17,40 +17,40 @@ # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' +# needs_sphinx = '1.0' # Do not warn on external images. -suppress_warnings = ['image.nonlocal_uri'] +suppress_warnings = ["image.nonlocal_uri"] # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.coverage', - 'sphinx.ext.doctest', - 'sphinx.ext.intersphinx', - 'sphinx.ext.viewcode', + "sphinx.ext.autodoc", + "sphinx.ext.coverage", + "sphinx.ext.doctest", + "sphinx.ext.intersphinx", + "sphinx.ext.viewcode", ] # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # source_suffix = ['.rst', '.md'] -source_suffix = '.rst' +source_suffix = ".rst" # The encoding of source files. -#source_encoding = 'utf-8-sig' +# source_encoding = 'utf-8-sig' # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = u'Swiss Open Access Repository' -copyright = u'2019, RERO' -author = u'RERO' +project = u"Swiss Open Access Repository" +copyright = u"2019, RERO" +author = u"RERO" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -60,11 +60,11 @@ # Get the version string. Cannot be done with import! g = {} -with open(os.path.join(os.path.dirname(__file__), '..', - 'sonar', 'version.py'), - 'rt') as fp: +with open( + os.path.join(os.path.dirname(__file__), "..", "sonar", "version.py"), "rt" +) as fp: exec(fp.read(), g) - version = g['__version__'] + version = g["__version__"] # The full version, including alpha/beta/rc tags. release = version @@ -78,9 +78,9 @@ # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: -#today = '' +# today = '' # Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' +# today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. @@ -88,46 +88,46 @@ # The reST default role (used for this markup: `text`) to use for all # documents. -#default_role = None +# default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True +# add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). -#add_module_names = True +# add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. -#show_authors = False +# show_authors = False # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] +# modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. -#keep_warnings = False +# keep_warnings = False # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = False # -- Options for HTML output ---------------------------------------------- -html_theme = 'alabaster' +html_theme = "alabaster" html_theme_options = { - 'description': 'SONAR is a future archive of scholarly publications. It intends to collect, promote and preserve the publications of authors affiliated with Swiss public research institutions', - 'github_user': 'inveniosoftware', - 'github_repo': 'sonar', - 'github_button': False, - 'github_banner': True, - 'show_powered_by': False, - 'extra_nav_links': { - 'sonar@GitHub': 'https://github.com/rero/sonar', - 'sonar@PyPI': 'https://pypi.python.org/pypi/sonar/', - } + "description": "SONAR is a future archive of scholarly publications. It intends to collect, promote and preserve the publications of authors affiliated with Swiss public research institutions", + "github_user": "inveniosoftware", + "github_repo": "sonar", + "github_button": False, + "github_banner": True, + "show_powered_by": False, + "extra_nav_links": { + "sonar@GitHub": "https://github.com/rero/sonar", + "sonar@PyPI": "https://pypi.python.org/pypi/sonar/", + }, } # The theme to use for HTML and HTML Help pages. See the documentation for @@ -136,159 +136,152 @@ # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. -#html_theme_options = {} +# html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] +# html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". -#html_title = None +# html_title = None # A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None +# html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. -#html_logo = None +# html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. -#html_favicon = None +# html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -#html_static_path = ['_static'] +# html_static_path = ['_static'] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied # directly to the root of the documentation. -#html_extra_path = [] +# html_extra_path = [] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' +# html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. -#html_use_smartypants = True +# html_use_smartypants = True # Custom sidebar templates, maps document names to template names. html_sidebars = { - '**': [ - 'about.html', - 'navigation.html', - 'relations.html', - 'searchbox.html', - 'donate.html', + "**": [ + "about.html", + "navigation.html", + "relations.html", + "searchbox.html", + "donate.html", ] } # Additional templates that should be rendered to pages, maps page names to # template names. -#html_additional_pages = {} +# html_additional_pages = {} # If false, no module index is generated. -#html_domain_indices = True +# html_domain_indices = True # If false, no index is generated. -#html_use_index = True +# html_use_index = True # If true, the index is split into individual pages for each letter. -#html_split_index = False +# html_split_index = False # If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True +# html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True +# html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True +# html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. -#html_use_opensearch = '' +# html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None +# html_file_suffix = None # Language to be used for generating the HTML full-text search index. # Sphinx supports the following languages: # 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' # 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' -#html_search_language = 'en' +# html_search_language = 'en' # A dictionary with options for the search language support, empty by default. # Now only 'ja' uses this config value -#html_search_options = {'type': 'default'} +# html_search_options = {'type': 'default'} # The name of a javascript file (relative to the configuration directory) that # implements a search results scorer. If empty, the default will be used. -#html_search_scorer = 'scorer.js' +# html_search_scorer = 'scorer.js' # Output file base name for HTML help builder. -htmlhelp_basename = 'sonar_namedoc' +htmlhelp_basename = "sonar_namedoc" # -- Options for LaTeX output --------------------------------------------- latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -#'papersize': 'letterpaper', - -# The font size ('10pt', '11pt' or '12pt'). -#'pointsize': '10pt', - -# Additional stuff for the LaTeX preamble. -#'preamble': '', - -# Latex figure (float) alignment -#'figure_align': 'htbp', + # The paper size ('letterpaper' or 'a4paper'). + #'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + #'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + #'preamble': '', + # Latex figure (float) alignment + #'figure_align': 'htbp', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'sonar.tex', u'sonar Documentation', - u'RERO', 'manual'), + (master_doc, "sonar.tex", u"sonar Documentation", u"RERO", "manual") ] # The name of an image file (relative to this directory) to place at the top of # the title page. -#latex_logo = None +# latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. -#latex_use_parts = False +# latex_use_parts = False # If true, show page references after internal links. -#latex_show_pagerefs = False +# latex_show_pagerefs = False # If true, show URL addresses after external links. -#latex_show_urls = False +# latex_show_urls = False # Documents to append as an appendix to all manuals. -#latex_appendices = [] +# latex_appendices = [] # If false, no module index is generated. -#latex_domain_indices = True +# latex_domain_indices = True # -- Options for manual page output --------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -man_pages = [ - (master_doc, 'sonar', u'sonar Documentation', - [author], 1) -] +man_pages = [(master_doc, "sonar", u"sonar Documentation", [author], 1)] # If true, show URL addresses after external links. -#man_show_urls = False +# man_show_urls = False # -- Options for Texinfo output ------------------------------------------- @@ -297,30 +290,36 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'sonar', u'Swiss Open Access Repository Documentation', - author, 'sonar', 'SONAR is a future archive of scholarly publications. It intends to collect, promote and preserve the publications of authors affiliated with Swiss public research institutions', - 'Miscellaneous'), + ( + master_doc, + "sonar", + u"Swiss Open Access Repository Documentation", + author, + "sonar", + "SONAR is a future archive of scholarly publications. It intends to collect, promote and preserve the publications of authors affiliated with Swiss public research institutions", + "Miscellaneous", + ) ] # Documents to append as an appendix to all manuals. -#texinfo_appendices = [] +# texinfo_appendices = [] # If false, no module index is generated. -#texinfo_domain_indices = True +# texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' +# texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. -#texinfo_no_detailmenu = False +# texinfo_no_detailmenu = False # Example configuration for intersphinx: refer to the Python standard library. intersphinx_mapping = { - 'python': ('https://docs.python.org/', None), + "python": ("https://docs.python.org/", None), # TODO: Configure external documentation references, eg: # 'Flask-Admin': ('https://flask-admin.readthedocs.io/en/latest/', None), } # Autodoc configuraton. -autoclass_content = 'both' +autoclass_content = "both" diff --git a/setup.py b/setup.py index 13cb3016d..9e09b350b 100644 --- a/setup.py +++ b/setup.py @@ -14,98 +14,84 @@ from setuptools import find_packages, setup -readme = open('README.rst').read() +readme = open("README.rst").read() packages = find_packages() # Get the version string. Cannot be done with import! g = {} -with open(os.path.join('sonar', 'version.py'), 'rt') as fp: +with open(os.path.join("sonar", "version.py"), "rt") as fp: exec(fp.read(), g) - version = g['__version__'] + version = g["__version__"] setup( - name='sonar', + name="sonar", version=version, description=__doc__, long_description=readme, - keywords='sonar Invenio', - license='MIT', - author='RERO', - author_email='software@rero.ch', - url='https://github.com/rero/sonar', + keywords="sonar Invenio", + license="MIT", + author="RERO", + author_email="software@rero.ch", + url="https://github.com/rero/sonar", packages=packages, zip_safe=False, include_package_data=True, - platforms='any', + platforms="any", entry_points={ - 'console_scripts': [ - 'sonar = invenio_app.cli:cli', + "console_scripts": ["sonar = invenio_app.cli:cli"], + "flask.commands": ["fixtures = sonar.modules.cli:fixtures"], + "invenio_base.apps": ["documents = sonar.modules.documents:Documents"], + "invenio_base.blueprints": [ + "sonar = sonar.theme.views:blueprint", + "documents = sonar.modules.documents.views:blueprint", ], - 'flask.commands': [ - 'fixtures = sonar.modules.cli:fixtures' + "invenio_assets.webpack": ["sonar_theme = sonar.theme.webpack:theme"], + "invenio_config.module": [ + "sonar = sonar.config", + "sonar_app = sonar.modules.config", + "sonar_documents = sonar.modules.documents.config", ], - 'invenio_base.apps': [ - 'documents = sonar.modules.documents:Documents' + "invenio_i18n.translations": ["messages = sonar"], + "invenio_base.api_apps": [ + "documents = sonar.modules.documents:Documents", + "institutions = sonar.modules.institutions:Institutions", ], - 'invenio_base.blueprints': [ - 'sonar = sonar.theme.views:blueprint', - 'documents = sonar.modules.documents.views:blueprint' + "invenio_jsonschemas.schemas": [ + "documents = sonar.modules.documents.jsonschemas", + "institutions = sonar.modules.institutions.jsonschemas", ], - 'invenio_assets.webpack': [ - 'sonar_theme = sonar.theme.webpack:theme', + "invenio_search.mappings": [ + "documents = sonar.modules.documents.mappings", + "institutions = sonar.modules.institutions.mappings", ], - 'invenio_config.module': [ - 'sonar = sonar.config', - 'sonar_app = sonar.modules.config', - 'sonar_documents = sonar.modules.documents.config' + "invenio_pidstore.minters": [ + "document_id = \ + sonar.modules.documents.api:document_pid_minter", + "institution_id = \ + sonar.modules.institutions.api:institution_pid_minter", ], - 'invenio_i18n.translations': [ - 'messages = sonar', - ], - 'invenio_base.api_apps': [ - 'documents = sonar.modules.documents:Documents', - 'institutions = sonar.modules.institutions:Institutions' - ], - 'invenio_jsonschemas.schemas': [ - 'documents = sonar.modules.documents.jsonschemas', - 'institutions = sonar.modules.institutions.jsonschemas' - ], - 'invenio_search.mappings': [ - 'documents = sonar.modules.documents.mappings', - 'institutions = sonar.modules.institutions.mappings' - ], - 'invenio_pidstore.minters': [ - 'document_id = \ - sonar.modules.documents.api:document_pid_minter', - 'institution_id = \ - sonar.modules.institutions.api:institution_pid_minter' - ], - 'invenio_pidstore.fetchers': [ - 'document_id = \ - sonar.modules.documents.api:document_pid_fetcher', - 'institution_id = \ - sonar.modules.institutions.api:institution_pid_fetcher' + "invenio_pidstore.fetchers": [ + "document_id = \ + sonar.modules.documents.api:document_pid_fetcher", + "institution_id = \ + sonar.modules.institutions.api:institution_pid_fetcher", ], "invenio_records.jsonresolver": [ "institution = sonar.modules.institutions.jsonresolvers" - ] + ], }, classifiers=[ - 'Environment :: Web Environment', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: MIT License', - 'Operating System :: OS Independent', - 'Programming Language :: Python', - 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.6', - 'Development Status :: 3 - Alpha', - ], - setup_requires=[ - 'pytest-runner>=3.0.0,<5', + "Environment :: Web Environment", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Topic :: Internet :: WWW/HTTP :: Dynamic Content", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Development Status :: 3 - Alpha", ], - tests_require=[ - 'pytest-invenio>=1.0.0,<1.1.0', - ] + setup_requires=["pytest-runner>=3.0.0,<5"], + tests_require=["pytest-invenio>=1.0.0,<1.1.0"], ) diff --git a/sonar/__init__.py b/sonar/__init__.py index 42a5206fa..84ca528a3 100644 --- a/sonar/__init__.py +++ b/sonar/__init__.py @@ -12,4 +12,4 @@ from .version import __version__ -__all__ = ('__version__', ) +__all__ = ("__version__",) diff --git a/sonar/modules/api.py b/sonar/modules/api.py index 79933d810..15d0de6f5 100644 --- a/sonar/modules/api.py +++ b/sonar/modules/api.py @@ -26,7 +26,7 @@ class SonarRecord(Record): minter = None fetcher = None provider = None - object_type = 'rec' + object_type = "rec" schema = None @classmethod @@ -38,15 +38,16 @@ def create(cls, data, id_=None, dbcommit=False, **kwargs): if not id_: id_ = uuid4() - if '$schema' not in data: + if "$schema" not in data: data["$schema"] = current_jsonschemas.path_to_url( - '{schema}s/{schema}-v1.0.0.json'.format(schema=cls.schema)) + "{schema}s/{schema}-v1.0.0.json".format(schema=cls.schema) + ) cls.minter(id_, data) record = super(SonarRecord, cls).create(data=data, id_=id_, **kwargs) - if(dbcommit): + if dbcommit: record.dbcommit() return record @@ -57,12 +58,10 @@ def get_record_by_pid(cls, pid, with_deleted=False): assert cls.provider try: persistent_identifier = PersistentIdentifier.get( - cls.provider.pid_type, - pid + cls.provider.pid_type, pid ) return super(SonarRecord, cls).get_record( - persistent_identifier.object_uuid, - with_deleted=with_deleted + persistent_identifier.object_uuid, with_deleted=with_deleted ) except NoResultFound: return None @@ -72,10 +71,9 @@ def get_record_by_pid(cls, pid, with_deleted=False): @classmethod def get_ref_link(cls, type, id): """Get $ref link for the given type of record.""" - return 'https://{host}/api/{type}/{id}'.format( - host=current_app.config.get('JSONSCHEMAS_HOST'), - type=type, - id=id) + return "https://{host}/api/{type}/{id}".format( + host=current_app.config.get("JSONSCHEMAS_HOST"), type=type, id=id + ) def dbcommit(self): """Commit changes to db.""" @@ -88,4 +86,4 @@ class SonarSearch(RecordsSearch): class Meta: """Search only on item index.""" - index = 'records' + index = "records" diff --git a/sonar/modules/cli.py b/sonar/modules/cli.py index d8b41fbdc..2b7f490ee 100644 --- a/sonar/modules/cli.py +++ b/sonar/modules/cli.py @@ -18,5 +18,6 @@ def fixtures(): """Fixtures management commands.""" + fixtures.add_command(documents) fixtures.add_command(institutions) diff --git a/sonar/modules/documents/__init__.py b/sonar/modules/documents/__init__.py index f73511e12..4016cb9e4 100644 --- a/sonar/modules/documents/__init__.py +++ b/sonar/modules/documents/__init__.py @@ -12,4 +12,4 @@ from .ext import Documents -__all__ = ('Documents', ) +__all__ = ("Documents",) diff --git a/sonar/modules/documents/api.py b/sonar/modules/documents/api.py index def69fe45..4749e0e7b 100644 --- a/sonar/modules/documents/api.py +++ b/sonar/modules/documents/api.py @@ -18,11 +18,7 @@ from ..providers import Provider # provider -DocumentProvider = type( - 'DocumentProvider', - (Provider,), - dict(pid_type='doc') -) +DocumentProvider = type("DocumentProvider", (Provider,), dict(pid_type="doc")) # minter document_pid_minter = partial(id_minter, provider=DocumentProvider) # fetcher @@ -35,7 +31,7 @@ class DocumentSearch(SonarSearch): class Meta: """Search only on item index.""" - index = 'documents' + index = "documents" doc_types = [] @@ -45,4 +41,4 @@ class DocumentRecord(SonarRecord): minter = document_pid_minter fetcher = document_pid_fetcher provider = DocumentProvider - schema = 'document' + schema = "document" diff --git a/sonar/modules/documents/config.py b/sonar/modules/documents/config.py index f8636e41f..91cf4deb9 100644 --- a/sonar/modules/documents/config.py +++ b/sonar/modules/documents/config.py @@ -8,9 +8,6 @@ """SONAR documents configuration.""" -SONAR_DOCUMENTS_RERO_DOC_URL = 'http://doc.rero.ch/search' +SONAR_DOCUMENTS_RERO_DOC_URL = "http://doc.rero.ch/search" -SONAR_DOCUMENTS_INSTITUTIONS_MAP = dict( - usi='ticino.unisi', - hevs='valais.hevs' -) +SONAR_DOCUMENTS_INSTITUTIONS_MAP = dict(usi="ticino.unisi", hevs="valais.hevs") diff --git a/sonar/modules/documents/ext.py b/sonar/modules/documents/ext.py index 5c443f6fb..91e4e618a 100644 --- a/sonar/modules/documents/ext.py +++ b/sonar/modules/documents/ext.py @@ -24,10 +24,10 @@ def __init__(self, app=None): def init_app(self, app): """Flask application initialization.""" self.init_config(app) - app.extensions['sonar_documents'] = self + app.extensions["sonar_documents"] = self def init_config(self, app): """Initialize configuration.""" for k in dir(config): - if k.startswith('SONAR_DOCUMENTS_'): + if k.startswith("SONAR_DOCUMENTS_"): app.config.setdefault(k, getattr(config, k)) diff --git a/sonar/modules/documents/marshmallow/__init__.py b/sonar/modules/documents/marshmallow/__init__.py index 04da6733c..861353c08 100644 --- a/sonar/modules/documents/marshmallow/__init__.py +++ b/sonar/modules/documents/marshmallow/__init__.py @@ -12,4 +12,4 @@ from .json import DocumentMetadataSchemaV1, DocumentSchemaV1 -__all__ = ('DocumentMetadataSchemaV1', 'DocumentSchemaV1',) +__all__ = ("DocumentMetadataSchemaV1", "DocumentSchemaV1") diff --git a/sonar/modules/documents/static/templates/documents/search_ui/count.html b/sonar/modules/documents/static/templates/documents/search_ui/count.html index 0409e8c6b..a40938eff 100644 --- a/sonar/modules/documents/static/templates/documents/search_ui/count.html +++ b/sonar/modules/documents/static/templates/documents/search_ui/count.html @@ -1,9 +1,7 @@
- diff --git a/sonar/modules/documents/static/templates/documents/search_ui/facets.html b/sonar/modules/documents/static/templates/documents/search_ui/facets.html index b82d51e82..11e371d91 100644 --- a/sonar/modules/documents/static/templates/documents/search_ui/facets.html +++ b/sonar/modules/documents/static/templates/documents/search_ui/facets.html @@ -1,45 +1,42 @@
-
-
-
{{ aggr.key }}
-
    -
  • -
    - - +
    +
    +
    {{ aggr.key }}
    +
      +
    • +
      + + +
      +
      +
      +
        +
      • + {{ subFacets.key }} ({{ subFacets.doc_count }}) +
      • +
      -
      -
      -
        -
      • - {{ subFacets.key }} ({{ subFacets.doc_count }}) -
      • -
      -
      -
      -
    • -
    - -
      -
    • - {{ selectedValue }} (0) -
    • -
    -
    +
    +
  • +
+ +
    +
  • + {{ selectedValue }} (0) +
  • +
-
\ No newline at end of file +
+
\ No newline at end of file diff --git a/sonar/modules/documents/static/templates/documents/search_ui/loading.html b/sonar/modules/documents/static/templates/documents/search_ui/loading.html index a12d81174..1003dab56 100644 --- a/sonar/modules/documents/static/templates/documents/search_ui/loading.html +++ b/sonar/modules/documents/static/templates/documents/search_ui/loading.html @@ -1,6 +1,6 @@
- +
{{ loadingMessage }}
\ No newline at end of file diff --git a/sonar/modules/documents/static/templates/documents/search_ui/pagination.html b/sonar/modules/documents/static/templates/documents/search_ui/pagination.html index f60a25c03..7a7d8d465 100644 --- a/sonar/modules/documents/static/templates/documents/search_ui/pagination.html +++ b/sonar/modules/documents/static/templates/documents/search_ui/pagination.html @@ -4,30 +4,32 @@
  • - +
  • - {{ page.value }} + {{ page.value }}
  • diff --git a/sonar/modules/documents/static/templates/documents/search_ui/select_box.html b/sonar/modules/documents/static/templates/documents/search_ui/select_box.html index dca87f9c8..ff774a964 100644 --- a/sonar/modules/documents/static/templates/documents/search_ui/select_box.html +++ b/sonar/modules/documents/static/templates/documents/search_ui/select_box.html @@ -1,6 +1,6 @@ - \ No newline at end of file diff --git a/sonar/modules/documents/static/templates/documents/search_ui/sort_order.html b/sonar/modules/documents/static/templates/documents/search_ui/sort_order.html index a16e0ba77..314aba37a 100644 --- a/sonar/modules/documents/static/templates/documents/search_ui/sort_order.html +++ b/sonar/modules/documents/static/templates/documents/search_ui/sort_order.html @@ -1,4 +1,5 @@ - \ No newline at end of file diff --git a/sonar/modules/ext.py b/sonar/modules/ext.py index 57dabba2c..a2cfcf10e 100644 --- a/sonar/modules/ext.py +++ b/sonar/modules/ext.py @@ -24,10 +24,10 @@ def __init__(self, app=None): def init_app(self, app): """Flask application initialization.""" self.init_config(app) - app.extensions['sonar_app'] = self + app.extensions["sonar_app"] = self def init_config(self, app): """Initialize configuration.""" for k in dir(config): - if k.startswith('SONAR_APP_'): + if k.startswith("SONAR_APP_"): app.config.setdefault(k, getattr(config, k)) diff --git a/sonar/modules/fetchers.py b/sonar/modules/fetchers.py index ba6a71b9c..96c1e4157 100644 --- a/sonar/modules/fetchers.py +++ b/sonar/modules/fetchers.py @@ -13,11 +13,11 @@ from collections import namedtuple -FetchedPID = namedtuple('FetchedPID', ['provider', 'pid_type', 'pid_value']) +FetchedPID = namedtuple("FetchedPID", ["provider", "pid_type", "pid_value"]) """A pid fetcher.""" -def id_fetcher(record_uuid, data, provider, pid_key='pid'): +def id_fetcher(record_uuid, data, provider, pid_key="pid"): """Fetch a record's identifiers. :param record_uuid: The record UUID. @@ -25,7 +25,5 @@ def id_fetcher(record_uuid, data, provider, pid_key='pid'): :returns: A :data:`sonar.modules.fetchers.FetchedPID` instance. """ return FetchedPID( - provider=provider, - pid_type=provider.pid_type, - pid_value=data[pid_key] + provider=provider, pid_type=provider.pid_type, pid_value=data[pid_key] ) diff --git a/sonar/modules/institutions/__init__.py b/sonar/modules/institutions/__init__.py index b1200c997..714a631d5 100644 --- a/sonar/modules/institutions/__init__.py +++ b/sonar/modules/institutions/__init__.py @@ -12,4 +12,4 @@ from .ext import Institutions -__all__ = ('Institutions', ) +__all__ = ("Institutions",) diff --git a/sonar/modules/institutions/api.py b/sonar/modules/institutions/api.py index f72dba2a1..bd35681a7 100644 --- a/sonar/modules/institutions/api.py +++ b/sonar/modules/institutions/api.py @@ -17,9 +17,7 @@ # provider InstitutionProvider = type( - 'InstitutionProvider', - (Provider,), - dict(pid_type='inst') + "InstitutionProvider", (Provider,), dict(pid_type="inst") ) # minter institution_pid_minter = partial(id_minter, provider=InstitutionProvider) @@ -33,7 +31,7 @@ class InstitutionSearch(SonarSearch): class Meta: """Search only on item index.""" - index = 'institutions' + index = "institutions" doc_types = [] @@ -43,4 +41,4 @@ class InstitutionRecord(SonarRecord): minter = institution_pid_minter fetcher = institution_pid_fetcher provider = InstitutionProvider - schema = 'institution' + schema = "institution" diff --git a/sonar/modules/institutions/cli.py b/sonar/modules/institutions/cli.py index 5881016fa..cbb914afa 100644 --- a/sonar/modules/institutions/cli.py +++ b/sonar/modules/institutions/cli.py @@ -27,13 +27,14 @@ def institutions(): """Institutions CLI commands.""" -@institutions.command('import') +@institutions.command("import") @with_appcontext def import_institutions(): """Import institutions from JSON file.""" - institution_file = './data/institutions.json' - click.secho('Importing institution from {file}'.format( - file=institution_file)) + institution_file = "./data/institutions.json" + click.secho( + "Importing institution from {file}".format(file=institution_file) + ) indexer = RecordIndexer() @@ -42,10 +43,10 @@ def import_institutions(): for record in records: try: # Check existence in DB - db_record = InstitutionRecord.get_record_by_pid(record['pid']) + db_record = InstitutionRecord.get_record_by_pid(record["pid"]) if db_record: - raise ClickException('Record already exists in DB') + raise ClickException("Record already exists in DB") # Register record to DB db_record = InstitutionRecord.create(record) @@ -54,7 +55,11 @@ def import_institutions(): indexer.index(db_record) except Exception as error: click.secho( - 'Institution {institution} could not be imported: {error}' - .format(institution=record, error=str(error)), fg='red') + "Institution {institution} could not " + "be imported: {error}".format( + institution=record, error=str(error) + ), + fg="red", + ) - click.secho('Finished', fg='green') + click.secho("Finished", fg="green") diff --git a/sonar/modules/institutions/ext.py b/sonar/modules/institutions/ext.py index 558f193c7..eedbd45f2 100644 --- a/sonar/modules/institutions/ext.py +++ b/sonar/modules/institutions/ext.py @@ -22,7 +22,7 @@ def __init__(self, app=None): def init_app(self, app): """Flask application initialization.""" self.init_config(app) - app.extensions['sonar_institutions'] = self + app.extensions["sonar_institutions"] = self def init_config(self, app): """Initialize configuration. diff --git a/sonar/modules/institutions/jsonresolvers.py b/sonar/modules/institutions/jsonresolvers.py index ec3a5d40e..24a55fb03 100644 --- a/sonar/modules/institutions/jsonresolvers.py +++ b/sonar/modules/institutions/jsonresolvers.py @@ -16,12 +16,13 @@ # the host corresponds to the config value for the key JSONSCHEMAS_HOST -@jsonresolver.route('/api/institutions/', host='sonar.ch') +@jsonresolver.route("/api/institutions/", host="sonar.ch") def institution_resolver(pid): """Resolve referenced institution.""" - resolver = Resolver(pid_type='inst', object_type="rec", - getter=Record.get_record) + resolver = Resolver( + pid_type="inst", object_type="rec", getter=Record.get_record + ) _, record = resolver.resolve(pid) - del record['$schema'] + del record["$schema"] return record diff --git a/sonar/modules/institutions/marshmallow/__init__.py b/sonar/modules/institutions/marshmallow/__init__.py index 1d1f806f3..09892f102 100644 --- a/sonar/modules/institutions/marshmallow/__init__.py +++ b/sonar/modules/institutions/marshmallow/__init__.py @@ -11,4 +11,4 @@ from .json import InstitutionMetadataSchemaV1, InstitutionSchemaV1 -__all__ = ('InstitutionMetadataSchemaV1', 'InstitutionSchemaV1',) +__all__ = ("InstitutionMetadataSchemaV1", "InstitutionSchemaV1") diff --git a/sonar/modules/minters.py b/sonar/modules/minters.py index f2faef3d0..709fd6f20 100644 --- a/sonar/modules/minters.py +++ b/sonar/modules/minters.py @@ -11,13 +11,14 @@ from __future__ import absolute_import, print_function, unicode_literals -def id_minter(record_uuid, data, provider, pid_key='pid', object_type='rec'): +def id_minter(record_uuid, data, provider, pid_key="pid", object_type="rec"): """SONAR minter.""" # Create persistent identifier provider = provider.create( object_type=object_type, object_uuid=record_uuid, - pid_value=data.get(pid_key)) + pid_value=data.get(pid_key), + ) pid = provider.pid data[pid_key] = pid.pid_value diff --git a/sonar/modules/providers.py b/sonar/modules/providers.py index 4b0b0a873..08b233e7f 100644 --- a/sonar/modules/providers.py +++ b/sonar/modules/providers.py @@ -45,23 +45,23 @@ def create(cls, object_type=None, object_uuid=None, **kwargs): :param kwargs: You specify the pid_value. """ # PID value not already exists, generating a new one - if not kwargs.get('pid_value'): - kwargs['pid_value'] = str(RecordIdentifier.next()) + if not kwargs.get("pid_value"): + kwargs["pid_value"] = str(RecordIdentifier.next()) - kwargs.setdefault('status', cls.default_status) + kwargs.setdefault("status", cls.default_status) if object_type and object_uuid: - kwargs['status'] = PIDStatus.REGISTERED + kwargs["status"] = PIDStatus.REGISTERED try: # Try to retreive PID - return cls.get(kwargs['pid_value'], cls.pid_type) + return cls.get(kwargs["pid_value"], cls.pid_type) except PIDDoesNotExistError: # Set default status - kwargs.setdefault('status', cls.default_status) + kwargs.setdefault("status", cls.default_status) # if record is registered, change PID status if object_type and object_uuid: - kwargs['status'] = PIDStatus.REGISTERED + kwargs["status"] = PIDStatus.REGISTERED # Call base provider return super(Provider, cls).create( diff --git a/sonar/theme/__init__.py b/sonar/theme/__init__.py index c178da485..fbd1880de 100644 --- a/sonar/theme/__init__.py +++ b/sonar/theme/__init__.py @@ -12,4 +12,4 @@ from ..version import __version__ -__all__ = ('__version__', ) +__all__ = ("__version__",) diff --git a/sonar/theme/templates/sonar/401.html b/sonar/theme/templates/sonar/401.html index 76a243ca3..e7366df49 100755 --- a/sonar/theme/templates/sonar/401.html +++ b/sonar/theme/templates/sonar/401.html @@ -10,6 +10,6 @@ {% extends config.THEME_ERROR_TEMPLATE %} {% block message %} -

    {{_('Unauthorized')}}

    -

    {{_('You need to be authenticated to view this page.')}}

    -{% endblock message %} +

    {{_('Unauthorized')}}

    +

    {{_('You need to be authenticated to view this page.')}}

    +{% endblock message %} \ No newline at end of file diff --git a/sonar/theme/templates/sonar/403.html b/sonar/theme/templates/sonar/403.html index ae66ea0c0..a6c7b1ac4 100755 --- a/sonar/theme/templates/sonar/403.html +++ b/sonar/theme/templates/sonar/403.html @@ -10,6 +10,6 @@ {% extends config.THEME_ERROR_TEMPLATE %} {% block message %} -

    {{_('Permission required')}}

    -

    {{_('You do not have sufficient permissions to view this page.')}}

    -{% endblock message %} +

    {{_('Permission required')}}

    +

    {{_('You do not have sufficient permissions to view this page.')}}

    +{% endblock message %} \ No newline at end of file diff --git a/sonar/theme/templates/sonar/404.html b/sonar/theme/templates/sonar/404.html index 47f59caab..ad4751eaf 100755 --- a/sonar/theme/templates/sonar/404.html +++ b/sonar/theme/templates/sonar/404.html @@ -10,7 +10,6 @@ {% extends config.THEME_ERROR_TEMPLATE %} {% block message %} -

    {{_('Page not found')}}

    -

    {{_('The page you are looking for could not be found.')}}

    -{% endblock message %} - +

    {{_('Page not found')}}

    +

    {{_('The page you are looking for could not be found.')}}

    +{% endblock message %} \ No newline at end of file diff --git a/sonar/theme/templates/sonar/500.html b/sonar/theme/templates/sonar/500.html index b163f44f6..5584067c3 100755 --- a/sonar/theme/templates/sonar/500.html +++ b/sonar/theme/templates/sonar/500.html @@ -10,8 +10,8 @@ {% extends config.THEME_ERROR_TEMPLATE %} {% block message %} -

    {{_('Internal server error')}}

    - {% if g.sentry_event_id %} -

    {{_('Error identifier')}}: {{ g.sentry_event_id }}

    - {% endif %} -{% endblock message %} +

    {{_('Internal server error')}}

    +{% if g.sentry_event_id %} +

    {{_('Error identifier')}}: {{ g.sentry_event_id }}

    +{% endif %} +{% endblock message %} \ No newline at end of file diff --git a/sonar/theme/templates/sonar/accounts/forgot_password.html b/sonar/theme/templates/sonar/accounts/forgot_password.html index 228b78c3c..e8aadc6df 100644 --- a/sonar/theme/templates/sonar/accounts/forgot_password.html +++ b/sonar/theme/templates/sonar/accounts/forgot_password.html @@ -4,33 +4,34 @@ {%- set messages = get_flashed_messages(with_categories=true) -%} {% block panel %} - {%- with form = forgot_password_form %} -
    -
    -
    -

    {{_('Reset Password')}}

    - {%- if messages %} - {%- for category, message in messages %} -

    {{ message }}

    - {%- endfor %} - {%- else %} -

    {{_('Enter your email address below and we will send you a link to reset your password.')}}

    -
    - {{ form.hidden_tag() }} - {{ render_field(form.email, icon="glyphicon glyphicon-user", autofocus=True) }} - -
    - {%- endif %} -
    -
    - {%- if current_user.is_anonymous %} -
    - {{_('Log In')}} - {%- if security.registerable %} - {{_('Sign Up')}} - {% endif %} -
    - {% endif %} +{%- with form = forgot_password_form %} +
    +
    +
    +

    {{_('Reset Password')}}

    + {%- if messages %} + {%- for category, message in messages %} +

    {{ message }}

    + {%- endfor %} + {%- else %} +

    {{_('Enter your email address below and we will send you a link to reset your password.')}} +

    +
    + {{ form.hidden_tag() }} + {{ render_field(form.email, icon="glyphicon glyphicon-user", autofocus=True) }} + +
    + {%- endif %}
    - {%- endwith %} +
    + {%- if current_user.is_anonymous %} +
    + {{_('Log In')}} + {%- if security.registerable %} + {{_('Sign Up')}} + {% endif %} +
    + {% endif %} +
    +{%- endwith %} {% endblock panel %} \ No newline at end of file diff --git a/sonar/theme/templates/sonar/admin_header.html b/sonar/theme/templates/sonar/admin_header.html index dae8f22a1..35ffc74bb 100755 --- a/sonar/theme/templates/sonar/admin_header.html +++ b/sonar/theme/templates/sonar/admin_header.html @@ -13,29 +13,29 @@ {{ config.ADMIN_APPNAME }} -{% endblock headerbox %} +{% endblock headerbox %} \ No newline at end of file diff --git a/sonar/theme/templates/sonar/admin_layout.html b/sonar/theme/templates/sonar/admin_layout.html index d606e9b6b..8ea0757a3 100755 --- a/sonar/theme/templates/sonar/admin_layout.html +++ b/sonar/theme/templates/sonar/admin_layout.html @@ -10,60 +10,60 @@ {% macro menu_icon(item) -%} {% set icon_type = item.get_icon_type() %} {%- if icon_type %} - {% set icon_value = item.get_icon_value() %} - {% if icon_type == 'glyph' %} - - {% elif icon_type == 'fa' %} - - {% elif icon_type == 'image' %} - menu image - {% elif icon_type == 'image-url' %} - menu image - {% endif %} +{% set icon_value = item.get_icon_value() %} +{% if icon_type == 'glyph' %} + +{% elif icon_type == 'fa' %} + +{% elif icon_type == 'image' %} +menu image +{% elif icon_type == 'image-url' %} +menu image +{% endif %} {% endif %} {%- endmacro %} {% macro menu_overwrite() %} - {%- for item in admin_view.admin.menu()|sort(attribute='name') %} - {%- if item.is_category() -%} - {% set children = item.get_children() %} - {%- if children %} - {% set class_name = item.get_class_name() %} - {%- if item.is_active(admin_view) %} -
  • - {% else -%} -
  • - {%- endif %} - - {% if item.class_name %} {% endif %} - {{ item.name }} - - -
      - {%- for child in children|sort(attribute='name') -%} - {% set class_name = child.get_class_name() %} - {%- if child.is_active(admin_view) %} -
    • - {% else %} -
    • - {%- endif %} - {{ menu_icon(child) }}{{ child.name }} -
    • - {%- endfor %} -
    -
  • - {% endif %} - {%- else %} - {%- if item.is_accessible() and item.is_visible() -%} - {% set class_name = item.get_class_name() %} - {%- if item.is_active(admin_view) %} -
  • - {%- else %} -
  • - {%- endif %} - {{ menu_icon(item) }}{{ item.name }} -
  • - {%- endif -%} - {% endif -%} - {% endfor %} -{% endmacro %} +{%- for item in admin_view.admin.menu()|sort(attribute='name') %} +{%- if item.is_category() -%} +{% set children = item.get_children() %} +{%- if children %} +{% set class_name = item.get_class_name() %} +{%- if item.is_active(admin_view) %} +
  • + {% else -%} +
  • + {%- endif %} + + {% if item.class_name %} {% endif %} + {{ item.name }} + + +
      + {%- for child in children|sort(attribute='name') -%} + {% set class_name = child.get_class_name() %} + {%- if child.is_active(admin_view) %} +
    • + {% else %} +
    • + {%- endif %} + {{ menu_icon(child) }}{{ child.name }} +
    • + {%- endfor %} +
    +
  • +{% endif %} +{%- else %} +{%- if item.is_accessible() and item.is_visible() -%} +{% set class_name = item.get_class_name() %} +{%- if item.is_active(admin_view) %} +
  • + {%- else %} +
  • + {%- endif %} + {{ menu_icon(item) }}{{ item.name }} +
  • +{%- endif -%} +{% endif -%} +{% endfor %} +{% endmacro %} \ No newline at end of file diff --git a/sonar/theme/templates/sonar/breadcrumbs.html b/sonar/theme/templates/sonar/breadcrumbs.html index 2c363bae3..6a59460a9 100755 --- a/sonar/theme/templates/sonar/breadcrumbs.html +++ b/sonar/theme/templates/sonar/breadcrumbs.html @@ -7,21 +7,21 @@ under the terms of the MIT License; see LICENSE file for more details. #} {%- if breadcrumbs|length > 1 %} - {%- endif %} \ No newline at end of file diff --git a/sonar/theme/templates/sonar/contact.html b/sonar/theme/templates/sonar/contact.html index 60fd38aef..04678b445 100644 --- a/sonar/theme/templates/sonar/contact.html +++ b/sonar/theme/templates/sonar/contact.html @@ -1,5 +1,5 @@ {% extends 'sonar/page.html' %} {%- block page_body %} -

    Contact

    +

    Contact

    {% endblock %} \ No newline at end of file diff --git a/sonar/theme/templates/sonar/footer.html b/sonar/theme/templates/sonar/footer.html index 1ce1a3738..6b95d7856 100755 --- a/sonar/theme/templates/sonar/footer.html +++ b/sonar/theme/templates/sonar/footer.html @@ -29,13 +29,13 @@ @@ -44,4 +44,4 @@
    - + \ No newline at end of file diff --git a/sonar/theme/templates/sonar/frontpage.html b/sonar/theme/templates/sonar/frontpage.html index 45bf28882..d45c4ae77 100755 --- a/sonar/theme/templates/sonar/frontpage.html +++ b/sonar/theme/templates/sonar/frontpage.html @@ -13,75 +13,81 @@ {% block header %}
    -
    -
    - +
    +
    + -
    -
    -
    -
    -
    {{_('Software under development !')}}
    -
    +
    +
    +
    {{_('Software under development !')}}
    +
    {% endblock %} {%- block page_body %} -
    -
    -

    {{_('The project')}}

    -

    {{_('The SONAR project aims to create a scholarly archive that collects, promotes and preserves the publications of authors affiliated with Swiss public research institutions.')}}

    +
    +
    +

    {{_('The project')}}

    +

    + {{_('The SONAR project aims to create a scholarly archive that collects, promotes and preserves the publications of authors affiliated with Swiss public research institutions.')}} +

    {{_('Further info on the project page')}} sonar.ch.

    -
    -
    -

    {{_('Institution views (test)')}}

    - Università della Svizzera italiana -
    -
    -

    {{_('Follow us')}}

    -
    -
    - -
    -
    {{_('Project website on')}} sonar.ch
    +
    +
    +

    {{_('Institution views (test)')}}

    + Università della Svizzera italiana +
    +
    +

    {{_('Follow us')}}

    +
    +
    +
    -
    -
    - -
    -
    {{_('Source code on')}} Github
    +
    {{_('Project website on')}} sonar.ch
    +
    +
    +
    +
    -
    -
    - -
    - +
    {{_('Source code on')}} Github
    -
    +
    +
    +
    + +
    + +
    -{%- endblock %} +
    +{%- endblock %} \ No newline at end of file diff --git a/sonar/theme/templates/sonar/javascript.html b/sonar/theme/templates/sonar/javascript.html index e4dd7d85e..a5ba40d52 100755 --- a/sonar/theme/templates/sonar/javascript.html +++ b/sonar/theme/templates/sonar/javascript.html @@ -12,4 +12,4 @@ {{ webpack['i18n_app.js']}} {# assets "invenio_theme_js" %}{% endassets #} -{# i18n assets #} +{# i18n assets #} \ No newline at end of file diff --git a/sonar/theme/templates/sonar/macros/macro.html b/sonar/theme/templates/sonar/macros/macro.html index 3600c675d..584c49ede 100644 --- a/sonar/theme/templates/sonar/macros/macro.html +++ b/sonar/theme/templates/sonar/macros/macro.html @@ -1,8 +1,8 @@ {% macro dl(title, content) %} -
    - {{ title }}: -
    -
    - {{ content|safe }} -
    +
    + {{ title }}: +
    +
    + {{ content|safe }} +
    {% endmacro %} \ No newline at end of file diff --git a/sonar/theme/templates/sonar/macros/messages.html b/sonar/theme/templates/sonar/macros/messages.html index cab854007..c3514a35f 100755 --- a/sonar/theme/templates/sonar/macros/messages.html +++ b/sonar/theme/templates/sonar/macros/messages.html @@ -7,15 +7,15 @@ under the terms of the MIT License; see LICENSE file for more details. #} {%- macro flashed_messages() -%} - {%- block messages %} - {%- for category, msg in get_flashed_messages(with_categories=True) %} - {%- set category = 'info' if category not in ['info', 'danger', 'warning', 'success'] else category %} -
    -
    - × - {{ msg }} -
    -
    - {%- endfor %} - {%- endblock messages %} -{%- endmacro %} +{%- block messages %} +{%- for category, msg in get_flashed_messages(with_categories=True) %} +{%- set category = 'info' if category not in ['info', 'danger', 'warning', 'success'] else category %} +
    +
    + × + {{ msg }} +
    +
    +{%- endfor %} +{%- endblock messages %} +{%- endmacro %} \ No newline at end of file diff --git a/sonar/theme/templates/sonar/page_admin.html b/sonar/theme/templates/sonar/page_admin.html index 48b9e5775..78396afd6 100755 --- a/sonar/theme/templates/sonar/page_admin.html +++ b/sonar/theme/templates/sonar/page_admin.html @@ -12,105 +12,105 @@ {%- import 'admin/static.html' as admin_static with context -%} - + + {%- block head %} - {%- block head_meta %} - - - - {%- if description %} - {% endif %} - {%- if keywords %} - {% endif %} - {%- if config.get('THEME_GOOGLE_SITE_VERIFICATION', None) %} - {%- for google_id in config.THEME_GOOGLE_SITE_VERIFICATION %} - - {%- endfor %} - {%- endif %} - {%- endblock head_meta %} - {%- block head_title %} - {%- set title = title or _(config.THEME_SITENAME) or _('Invenio') %} - {{ title }} - {%- endblock head_title %} - - {%- block head_links %} - - {%- if keywords %} - {% endif %} - {%- block head_links_langs %} - {%- if alternate_urls %} - {%- for alt_ln, alternate_url in alternate_urls.items() %} - - {%- endfor %} - {%- endif %} - {%- endblock head_links_langs %} - - {%- block head_apple_icons %} - {%- for size in [144, 114, 72, 57] %} - {%- set icon_name = 'apple-touch-icon-%d-precomposed.png' | format(size) %} - - {%- endfor %} - {%- endblock head_apple_icons %} - - {%- endblock head_links %} - - {%- block header %}{% endblock header %} - {%- block css %} - {{ webpack['theme.css'] }} - {{ webpack['theme-admin.css'] }} - - + - - {%- endblock css %} + + {%- endblock css %} {%- endblock head %} - - {%- block browserupgrade %} + + {%- block browserupgrade %} - {%- endblock browserupgrade %} - -
    - {% include 'invenio_theme/admin_header.html' %} - - -
    - {% if admin_view.name %} + {%- endblock browserupgrade %} + +
    + {% include 'invenio_theme/admin_header.html' %} + + +
    + {% if admin_view.name %}
    {{ layout.messages() }}

    {{ admin_view.name }}

    - {% endif %} -
    - {% set render_ctx = h.resolve_ctx() %} - {% block body %}{% endblock %} -
    + {% endif %} +
    + {% set render_ctx = h.resolve_ctx() %} + {% block body %}{% endblock %} +
    +
    + {%- include config.THEME_FOOTER_TEMPLATE -%}
    - {%- include config.THEME_FOOTER_TEMPLATE -%} -
    - {%- block javascript %} + {%- block javascript %} {{ webpack['manifest.js'] }} {{ webpack['vendor.js'] }} {{ webpack['adminlte.js'] }} - - {%- endblock javascript %} + + {%- endblock javascript %} - {%- block trackingcode %} + {%- block trackingcode %} {% include config.THEME_TRACKINGCODE_TEMPLATE %} - {%- endblock %} + {%- endblock %} + + {% block tail %}{% endblock %} + - {% block tail %}{% endblock %} - - + \ No newline at end of file diff --git a/sonar/theme/templates/sonar/page_cover.html b/sonar/theme/templates/sonar/page_cover.html index 5bc4341e6..51f7b0138 100755 --- a/sonar/theme/templates/sonar/page_cover.html +++ b/sonar/theme/templates/sonar/page_cover.html @@ -13,66 +13,65 @@ {%- set body_css_classes=['cover-page', 'bg-primary'] %} {%- block body %} - {%- block browserupgrade %} - - {%- endblock browserupgrade %} +{%- endblock browserupgrade %} -
    +
    {% block page_header %} -
    -
    -
    - {%- block brand %} - {%- if config.THEME_LOGO %} - - - - {%- elif config.THEME_SITENAME %} - - {{ _(config.THEME_SITENAME) }} - - {% endif %} - {%- endblock %} +
    +
    +
    + {%- block brand %} + {%- if config.THEME_LOGO %} + + + + {%- elif config.THEME_SITENAME %} + + {{ _(config.THEME_SITENAME) }} + + {% endif %} + {%- endblock %} -
    - {%- block flashmessages %} - {%- from "invenio_theme/macros/messages.html" import flashed_messages with context -%} - {{ flashed_messages() }} - {%- endblock flashmessages %} -
    +
    + {%- block flashmessages %} + {%- from "invenio_theme/macros/messages.html" import flashed_messages with context -%} + {{ flashed_messages() }} + {%- endblock flashmessages %}
    +
    {% endblock page_header%} - + {%- block page_body %} -
    -
    - {% block panel %} -
    -
    -
    - {% block panel_content %} -

    {{ panel_title }}

    +
    +
    + {% block panel %} +
    +
    +
    + {% block panel_content %} +

    {{ panel_title }}

    {% endblock panel_content %} -
    -
    - {% endblock panel %} +
    + {% endblock panel %}
    - {%- endblock page_body %}
    + {%- endblock page_body %} +
    - {%- block javascript %} - {% include config.THEME_JAVASCRIPT_TEMPLATE %} - {% endblock javascript %} +{%- block javascript %} +{% include config.THEME_JAVASCRIPT_TEMPLATE %} +{% endblock javascript %} - {%- block trackingcode %} - {% include config.THEME_TRACKINGCODE_TEMPLATE %} - {% endblock %} +{%- block trackingcode %} +{% include config.THEME_TRACKINGCODE_TEMPLATE %} +{% endblock %} {%- endblock body %} \ No newline at end of file diff --git a/sonar/theme/templates/sonar/page_error.html b/sonar/theme/templates/sonar/page_error.html index 1be6672ba..4e7789b0e 100755 --- a/sonar/theme/templates/sonar/page_error.html +++ b/sonar/theme/templates/sonar/page_error.html @@ -11,10 +11,10 @@ {% block page_body %}
    -
    -
    - {% block message %}{% endblock message %} +
    +
    + {% block message %}{% endblock message %} +
    -
    -{% endblock %} +{% endblock %} \ No newline at end of file diff --git a/sonar/theme/templates/sonar/page_settings.html b/sonar/theme/templates/sonar/page_settings.html index 986f162eb..cf9a8232e 100755 --- a/sonar/theme/templates/sonar/page_settings.html +++ b/sonar/theme/templates/sonar/page_settings.html @@ -12,48 +12,48 @@ {%- block page_body scoped %}
    -
    - {%- block settings_menu scoped %} -
    -
    -
    {{ _('Settings') }}
    -
      +
      + {%- block settings_menu scoped %} +
      +
      +
      {{ _('Settings') }}
      + -
      +
    - {%- endblock %}
    -
    - {%- block settings_content scoped %} -
    -
    -
    - {%- block settings_content_title scoped %} - {%- if panel_icon %} - {%- block settings_content_title_icon scoped %} - - {%- endblock %} - {%- endif %} - {{ panel_title|default("") }} - {%- endblock %} -
    - {%- block settings_body scoped %} -
    - {%- block settings_form scoped %} - {%- endblock settings_form %} -
    - {%- endblock settings_body %} + {%- endblock %} +
    +
    + {%- block settings_content scoped %} +
    +
    +
    + {%- block settings_content_title scoped %} + {%- if panel_icon %} + {%- block settings_content_title_icon scoped %} + + {%- endblock %} + {%- endif %} + {{ panel_title|default("") }} + {%- endblock %} +
    + {%- block settings_body scoped %} +
    + {%- block settings_form scoped %} + {%- endblock settings_form %}
    + {%- endblock settings_body %}
    - {%- endblock %}
    + {%- endblock %} +
    -{%- endblock %} +{%- endblock %} \ No newline at end of file diff --git a/sonar/theme/templates/sonar/search.html b/sonar/theme/templates/sonar/search.html index 8dca8496d..b789a1299 100644 --- a/sonar/theme/templates/sonar/search.html +++ b/sonar/theme/templates/sonar/search.html @@ -1,99 +1,83 @@ {% extends config.SEARCH_UI_BASE_TEMPLATE %} {%- block css %} - {{ super() }} - {{ webpack['search_ui_theme.css'] }} - {# assets "invenio_search_ui_search_css" %}{% endassets #} +{{ super() }} +{{ webpack['search_ui_theme.css'] }} +{# assets "invenio_search_ui_search_css" %}{% endassets #} {%- endblock css %} {%- block javascript %} - {{ super() }} - {{ webpack['search_ui.js'] }} - {# assets "invenio_search_ui_search_js" %}{% endassets #} +{{ super() }} +{{ webpack['search_ui.js'] }} +{# assets "invenio_search_ui_search_js" %}{% endassets #} {%- endblock javascript %} {%- block body_inner %} {%- endblock body_inner %} {%- block page_body %} -
    -
    - - -
    -
    - {%- block search_sort %} - {%- set sort_options = config.get('RECORDS_REST_SORT_OPTIONS', {}).get(config.SEARCH_UI_SEARCH_INDEX) %} - {%- if sort_options %} -
    -
    - {{ _('Sort by') }} -
    -
    - {%- block search_sort_select scoped %} - - - {%- endblock search_sort_select %} -
    -
    - {%- block search_sort_order scoped %} - - - {%- endblock search_sort_order %} -
    -
    - {%- endif %} - {%- endblock search_sort %} -
    +
    +
    + +
    -
    -
    - - -
    -
    - - - - - - - - - - +
    + {%- block search_sort %} + {%- set sort_options = config.get('RECORDS_REST_SORT_OPTIONS', {}).get(config.SEARCH_UI_SEARCH_INDEX) %} + {%- if sort_options %} +
    +
    + {{ _('Sort by') }} +
    +
    + {%- block search_sort_select scoped %} + + + {%- endblock search_sort_select %} +
    +
    + {%- block search_sort_order scoped %} + + + {%- endblock search_sort_order %} +
    + {%- endif %} + {%- endblock search_sort %}
    +
    +
    +
    + + +
    +
    + + + + + + + + + + +
    +
    {%- endblock page_body -%} \ No newline at end of file diff --git a/sonar/theme/templates/sonar/trackingcode.html b/sonar/theme/templates/sonar/trackingcode.html index 646bd13fc..83fa51b09 100755 --- a/sonar/theme/templates/sonar/trackingcode.html +++ b/sonar/theme/templates/sonar/trackingcode.html @@ -5,4 +5,4 @@ Invenio is free software; you can redistribute it and/or modify it under the terms of the MIT License; see LICENSE file for more details. -#} +#} \ No newline at end of file diff --git a/sonar/theme/views.py b/sonar/theme/views.py index c3a631c9b..6d384dae2 100644 --- a/sonar/theme/views.py +++ b/sonar/theme/views.py @@ -18,14 +18,11 @@ from flask import Blueprint, g, render_template blueprint = Blueprint( - 'sonar', - __name__, - template_folder='templates', - static_folder='static' + "sonar", __name__, template_folder="templates", static_folder="static" ) -@blueprint.route('/error') +@blueprint.route("/error") def error(): """Error to generate exception for test purposes.""" - raise Exception('this is an error for test purposes') + raise Exception("this is an error for test purposes") diff --git a/sonar/theme/webpack.py b/sonar/theme/webpack.py index 181c5c733..e5f046478 100644 --- a/sonar/theme/webpack.py +++ b/sonar/theme/webpack.py @@ -14,17 +14,17 @@ theme = WebpackBundle( __name__, - 'assets', + "assets", entry={ - 'app': './js/app.js', - 'search_ui': './js/search_ui.js', - 'sonar-theme': './scss/sonar/theme.scss', - 'usi-theme': './scss/usi/theme.scss' + "app": "./js/app.js", + "search_ui": "./js/search_ui.js", + "sonar-theme": "./scss/sonar/theme.scss", + "usi-theme": "./scss/usi/theme.scss", }, dependencies={ - 'popper.js': '^1.15', - 'jquery': '^3.2', - 'bootstrap': '^4.3', - 'font-awesome': '^4.0' - } + "popper.js": "^1.15", + "jquery": "^3.2", + "bootstrap": "^4.3", + "font-awesome": "^4.0", + }, ) diff --git a/sonar/version.py b/sonar/version.py index 8bc4145ea..fd4770bbe 100644 --- a/sonar/version.py +++ b/sonar/version.py @@ -14,4 +14,4 @@ from __future__ import absolute_import, print_function -__version__ = '0.0.1' +__version__ = "0.0.1" diff --git a/tests/api/conftest.py b/tests/api/conftest.py index cfed0722c..8bc33ebed 100644 --- a/tests/api/conftest.py +++ b/tests/api/conftest.py @@ -14,7 +14,7 @@ from invenio_app.factory import create_api -@pytest.fixture(scope='module') +@pytest.fixture(scope="module") def create_app(): """Create test app.""" return create_api diff --git a/tests/e2e/conftest.py b/tests/e2e/conftest.py index 871f11970..28941adb1 100644 --- a/tests/e2e/conftest.py +++ b/tests/e2e/conftest.py @@ -14,7 +14,7 @@ from invenio_app.factory import create_app as create_ui_api -@pytest.fixture(scope='module') +@pytest.fixture(scope="module") def create_app(): """Create test app.""" return create_ui_api diff --git a/tests/e2e/test_front_page.py b/tests/e2e/test_front_page.py index 470c6003c..b44cdb307 100644 --- a/tests/e2e/test_front_page.py +++ b/tests/e2e/test_front_page.py @@ -5,6 +5,7 @@ def test_frontpage(live_server, browser): """Test retrieval of front page.""" - browser.get(url_for('invenio_theme_frontpage.index', _external=True)) - assert "Swiss Open Access Repository" == \ - browser.find_element_by_tag_name('img').get_attribute('alt') + browser.get(url_for("invenio_theme_frontpage.index", _external=True)) + assert "Swiss Open Access Repository" == browser.find_element_by_tag_name( + "img" + ).get_attribute("alt") diff --git a/tests/test_version.py b/tests/test_version.py index 2f7f68f32..37ec5c791 100644 --- a/tests/test_version.py +++ b/tests/test_version.py @@ -14,4 +14,5 @@ def test_version(): """Test version import.""" from sonar import __version__ + assert __version__ diff --git a/tests/ui/conftest.py b/tests/ui/conftest.py index e09032494..fb0d0c097 100644 --- a/tests/ui/conftest.py +++ b/tests/ui/conftest.py @@ -14,7 +14,7 @@ from invenio_app.factory import create_ui -@pytest.fixture(scope='module') +@pytest.fixture(scope="module") def create_app(): """Create test app.""" return create_ui diff --git a/tests/ui/institutions/test_jsonresolvers.py b/tests/ui/institutions/test_jsonresolvers.py index b9ed8bd78..1442acd41 100644 --- a/tests/ui/institutions/test_jsonresolvers.py +++ b/tests/ui/institutions/test_jsonresolvers.py @@ -17,15 +17,18 @@ def test_institution_resolver(client): """Test institution resolver.""" - InstitutionRecord.create({ - "pid": "usi", - "name": "Università della Svizzera italiana" - }) + InstitutionRecord.create( + {"pid": "usi", "name": "Università della Svizzera italiana"} + ) - record = DocumentRecord.create({ - "title": "The title of the record", - "institution": {"$ref": "https://sonar.ch/api/institutions/usi"} - }) + record = DocumentRecord.create( + { + "title": "The title of the record", + "institution": {"$ref": "https://sonar.ch/api/institutions/usi"}, + } + ) - assert record.replace_refs().get('institution')['name'] == 'Università ' \ - 'della Svizzera italiana' + assert ( + record.replace_refs().get("institution")["name"] == "Università " + "della Svizzera italiana" + ) diff --git a/tests/ui/test_api.py b/tests/ui/test_api.py index 26ac96bc4..8cbb7f290 100644 --- a/tests/ui/test_api.py +++ b/tests/ui/test_api.py @@ -15,43 +15,38 @@ def test_create(app): """Test creating a record.""" - DocumentRecord.create({ - "pid": "1", - "title": "The title of the record" - }) + DocumentRecord.create({"pid": "1", "title": "The title of the record"}) - DocumentRecord.create({ - "pid": "2", - "title": "The title of the record" - }, dbcommit=True) + DocumentRecord.create( + {"pid": "2", "title": "The title of the record"}, dbcommit=True + ) def test_get_ref_link(app): """Test ref link.""" - assert DocumentRecord.get_ref_link('document', '1') == 'https://sonar.ch' \ - '/api/document/1' + assert ( + DocumentRecord.get_ref_link("document", "1") == "https://sonar.ch" + "/api/document/1" + ) def test_get_record_by_pid(app): """Test get record by PID.""" - assert DocumentRecord.get_record_by_pid('ABCD') is None + assert DocumentRecord.get_record_by_pid("ABCD") is None - record = DocumentRecord.create({ - "pid": "ABCD", - "title": "The title of the record" - }) + record = DocumentRecord.create( + {"pid": "ABCD", "title": "The title of the record"} + ) - assert DocumentRecord.get_record_by_pid('ABCD')['pid'] == 'ABCD' + assert DocumentRecord.get_record_by_pid("ABCD")["pid"] == "ABCD" record.delete() - assert DocumentRecord.get_record_by_pid('ABCD') is None + assert DocumentRecord.get_record_by_pid("ABCD") is None def test_dbcommit(app): """Test record commit to db.""" - record = DocumentRecord.create({ - "title": "The title of the record" - }) + record = DocumentRecord.create({"title": "The title of the record"}) record.dbcommit() diff --git a/tests/ui/test_fetchers.py b/tests/ui/test_fetchers.py index d153e91ad..3ac44cafa 100644 --- a/tests/ui/test_fetchers.py +++ b/tests/ui/test_fetchers.py @@ -15,4 +15,4 @@ def test_id_fetcher(): """Test id fetcher.""" - assert DocumentRecord.fetcher('1', {'pid': '1'}).pid_value == '1' + assert DocumentRecord.fetcher("1", {"pid": "1"}).pid_value == "1" diff --git a/tests/ui/test_views.py b/tests/ui/test_views.py index cf96f66f3..be2514e4d 100644 --- a/tests/ui/test_views.py +++ b/tests/ui/test_views.py @@ -15,4 +15,4 @@ def test_error(client): """Test error page""" with pytest.raises(Exception): - assert client.get(url_for('sonar.error')) + assert client.get(url_for("sonar.error"))