global: required changes for feb release (#155)

* disabled search and landingpage override
* search query modified
* routes: injecting routes to override
This commit is contained in:
Mojib Wali
2021-03-01 16:10:28 +01:00
committed by GitHub
parent 5d39ad5fdd
commit ee94d72b65
9 changed files with 105 additions and 63 deletions

View File

@@ -91,13 +91,36 @@ DEPOSITS_HEADER_TEMPLATE = "invenio_theme_tugraz/header.html"
# See https://invenio-rdm-records.readthedocs.io/en/latest/configuration.html # See https://invenio-rdm-records.readthedocs.io/en/latest/configuration.html
# Uncomment below to override records landingpage. # Uncomment below to override records landingpage.
# from invenio_rdm_records.config import RECORDS_UI_ENDPOINTS # from invenio_rdm_records.config import RECORDS_UI_ENDPOINTS
RECORDS_UI_ENDPOINTS["recid"].update( # RECORDS_UI_ENDPOINTS["recid"].update(
template="invenio_theme_tugraz/record_landing_page.html" # template="invenio_theme_tugraz/record_landing_page.html"
) # )
"""override the default record landing page""" """override the default record landing page"""
# Invenio-search-ui # Invenio-search-ui
# ============= # =============
# See https://invenio-search-ui.readthedocs.io/en/latest/configuration.html # See https://invenio-search-ui.readthedocs.io/en/latest/configuration.html
SEARCH_UI_SEARCH_TEMPLATE = "invenio_theme_tugraz/search.html" # SEARCH_UI_SEARCH_TEMPLATE = "invenio_theme_tugraz/search.html"
"""override the default search page""" # """override the default search page"""
TUG_ROUTES = {
"index": "/",
"comingsoon": "/comingsoon",
}
# Invenio-app-rdm
# =============
# See https://invenio-app-rdm.readthedocs.io/en/latest/configuration.html
# """override the default search page"""
# Keep this in sync
APP_RDM_ROUTES = {
"index": "/notvalid/notvalid/notvalid",
"help_search": "/help/search",
"record_search": "/search2",
"record_detail": "/records/<pid_value>",
"record_export": "/records/<pid_value>/export/<export_format>",
"record_file_preview": "/records/<pid_value>/preview/<path:filename>",
"record_file_download": "/records/<pid_value>/files/<path:filename>",
"deposit_search": "/uploads",
"deposit_create": "/uploads/new",
"deposit_edit": "/uploads/<pid_value>",
}

View File

@@ -22,4 +22,4 @@ class FrontpageRecordsSearch(RecordsSearch):
"""Default index and filter for frontpage search.""" """Default index and filter for frontpage search."""
index = "rdmrecords-records" index = "rdmrecords-records"
default_filter = Q("query_string", query=("access.access_right:open")) default_filter = Q("query_string", query=("access.record:public"))

View File

@@ -0,0 +1,7 @@
{%- extends config.INVENIO_THEME_TUGRAZ_BASE_TEMPLATE %}
{%- block page_body %}
<div class="ui container">
<h1 style="text-align: center;">comingsoon</h1>
</div>
{%- endblock %}

View File

@@ -30,15 +30,15 @@
<h2>{{_ ("Repository")}}</h2> <h2>{{_ ("Repository")}}</h2>
<p class="bodytext"> <p class="bodytext">
<a href="{{ url_for('invenio_app_rdm.coming_soon') }}"> <a href="{{ url_for('invenio_theme_tugraz.comingsoon') }}">
{{_ ("Impressum")}}<i class="angle right icon"></i> {{_ ("Impressum")}}<i class="angle right icon"></i>
</a> </a>
<br> <br>
<a href="{{ url_for('invenio_app_rdm.coming_soon') }}"> <a href="{{ url_for('invenio_theme_tugraz.comingsoon') }}">
{{_ ("Data protection")}}<i class="angle right icon"></i> {{_ ("Data protection")}}<i class="angle right icon"></i>
</a> </a>
<br> <br>
<a href="{{ url_for('invenio_app_rdm.coming_soon') }}"> <a href="{{ url_for('invenio_theme_tugraz.comingsoon') }}">
{{_ ("Feedback")}}<i class="angle right icon"></i> {{_ ("Feedback")}}<i class="angle right icon"></i>
</a> </a>
</p> </p>

View File

@@ -45,7 +45,7 @@
<!--TODO: remove this once above is uncommented--> <!--TODO: remove this once above is uncommented-->
<div class="two wide column main-menu-entry"> <div class="two wide column main-menu-entry">
<a href="{{url_for('invenio_app_rdm.deposits_user')}}">{{_ ("Uploads")}}</a> <a href="{{url_for('invenio_app_rdm_records.deposit_search')}}">{{_ ("Uploads")}}</a>
</div> </div>
</div> </div>

View File

@@ -41,7 +41,7 @@
{%- for r in records %} {%- for r in records %}
{%- set creation_date = r._created|from_isodatetime -%} {%- set creation_date = r._created|from_isodatetime -%}
{%- set record_url = url_for('invenio_records_ui.recid', pid_value=r['id']) %} {%- set record_url = url_for('invenio_app_rdm_records.record_detail', pid_value=r.id) %}
<article> <article>
<!--TODO: <!--TODO:
@@ -93,8 +93,8 @@
</small> </small>
</div> </div>
</div> </div>
<!--Disabled on feb-relase - enable when stable-->
<div class="right floated column"> <!-- <div class="right floated column">
<span class="access-right"> <span class="access-right">
<i class="icon lock open"></i> <i class="icon lock open"></i>
{{ r.access.access_right | make_dict_like('access_right') | vocabulary_title('access_right') }} {{ r.access.access_right | make_dict_like('access_right') | vocabulary_title('access_right') }}
@@ -103,7 +103,7 @@
{%- endfor %} {%- endfor %}
</span> </span>
</div> </div> -->
</div> </div>
</div> </div>
</article> </article>

View File

@@ -12,9 +12,15 @@ from typing import Dict
from elasticsearch_dsl.utils import AttrDict from elasticsearch_dsl.utils import AttrDict
from flask import Blueprint, render_template from flask import Blueprint, render_template
from flask_menu import current_menu
from .search import FrontpageRecordsSearch from .search import FrontpageRecordsSearch
def ui_blueprint(app):
"""Blueprint for the routes and resources provided by Invenio-theme-tugraz."""
routes = app.config.get("TUG_ROUTES")
blueprint = Blueprint( blueprint = Blueprint(
"invenio_theme_tugraz", "invenio_theme_tugraz",
__name__, __name__,
@@ -22,15 +28,8 @@ blueprint = Blueprint(
static_folder="static", static_folder="static",
) )
blueprint.add_url_rule(routes["index"], view_func=index)
@blueprint.route("/") blueprint.add_url_rule(routes["comingsoon"], view_func=comingsoon)
def index():
"""Render frontpage view."""
return render_template(
"invenio_theme_tugraz/index.html",
records=FrontpageRecordsSearch()[:5].sort("-created").execute(),
)
@blueprint.app_template_filter("make_dict_like") @blueprint.app_template_filter("make_dict_like")
def make_dict_like(value: str, key: str) -> Dict[str, str]: def make_dict_like(value: str, key: str) -> Dict[str, str]:
@@ -40,8 +39,21 @@ def make_dict_like(value: str, key: str) -> Dict[str, str]:
""" """
return {key: value} return {key: value}
@blueprint.app_template_filter("cast_to_dict") @blueprint.app_template_filter("cast_to_dict")
def cast_to_dict(attr_dict): def cast_to_dict(attr_dict):
"""Return the dict structure of AttrDict variable.""" """Return the dict structure of AttrDict variable."""
return AttrDict.to_dict(attr_dict) return AttrDict.to_dict(attr_dict)
return blueprint
def index():
"""Frontpage."""
return render_template(
"invenio_theme_tugraz/index.html",
records=FrontpageRecordsSearch()[:5].sort("-created").execute())
def comingsoon():
"""Frontpage."""
return render_template("invenio_theme_tugraz/comingsoon.html")

View File

@@ -90,7 +90,7 @@ setup(
"invenio_theme_tugraz = invenio_theme_tugraz:InvenioThemeTugraz", "invenio_theme_tugraz = invenio_theme_tugraz:InvenioThemeTugraz",
], ],
"invenio_base.blueprints": [ "invenio_base.blueprints": [
"invenio_theme_tugraz = invenio_theme_tugraz.views:blueprint", "invenio_theme_tugraz = invenio_theme_tugraz.views:ui_blueprint",
], ],
"invenio_i18n.translations": [ "invenio_i18n.translations": [
"messages = invenio_theme_tugraz", "messages = invenio_theme_tugraz",

View File

@@ -1,33 +1,33 @@
# -*- coding: utf-8 -*- # # -*- coding: utf-8 -*-
# # #
# Copyright (C) 2020 mojib wali. # # Copyright (C) 2020 mojib wali.
# # #
# invenio-theme-tugraz is free software; you can redistribute it and/or # # invenio-theme-tugraz is free software; you can redistribute it and/or
# modify it under the terms of the MIT License; see LICENSE file for more # # modify it under the terms of the MIT License; see LICENSE file for more
# details. # # details.
"""Test views.""" # """Test views."""
from elasticsearch_dsl.utils import AttrDict # from elasticsearch_dsl.utils import AttrDict
from invenio_theme_tugraz.views import cast_to_dict, make_dict_like # from invenio_theme_tugraz.views import cast_to_dict, make_dict_like
def test_make_dict_like(): # def test_make_dict_like():
"""Test make_dict_like.""" # """Test make_dict_like."""
access = { # access = {
"access_right" : "open" # "access_right" : "open"
} # }
dicts = make_dict_like("open", "access_right") # dicts = make_dict_like("open", "access_right")
assert access == dicts # assert access == dicts
def test_cast_to_dict(): # def test_cast_to_dict():
"""Test cast_to_dict.""" # """Test cast_to_dict."""
resource_type = { # resource_type = {
"subtype" : "publication-datamanagementplan", # "subtype" : "publication-datamanagementplan",
"type" : "publication" # "type" : "publication"
} # }
expected = {'subtype': 'publication-datamanagementplan', 'type': 'publication'} # expected = {'subtype': 'publication-datamanagementplan', 'type': 'publication'}
attr = cast_to_dict(AttrDict(resource_type)) # attr = cast_to_dict(AttrDict(resource_type))
assert expected == attr # assert expected == attr