diff --git a/.pylintrc b/.pylintrc index 1530cd51cf9cce75e282ef482008458207de0478..2d0b9f37cb50ff484d26cbb82f7c9f29019ef164 100644 --- a/.pylintrc +++ b/.pylintrc @@ -148,6 +148,7 @@ disable=missing-module-docstring, bad-continuation, too-many-ancestors, no-self-use, + duplicate-code, # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option diff --git a/requirements.txt b/requirements.txt index dffdbf780c3d7d1d83ec9918bdbe8a8e5f98fb22..d2b691787f81594ac76b627c98c04ff72ad02e73 100644 --- a/requirements.txt +++ b/requirements.txt @@ -36,3 +36,4 @@ attrs==18.2.0 more-itertools==4.2.0 pluggy==0.8.0 py==1.7.0 +pyOpenSSL==19.0.0 diff --git a/uffd/default_config.cfg b/uffd/default_config.cfg index 5f9b2b026d4f8771edcc8577b99de6eb2c61e56b..5ac85c41cf9e18037d07b37572a8b1a1d11dc766 100644 --- a/uffd/default_config.cfg +++ b/uffd/default_config.cfg @@ -113,7 +113,12 @@ SERVICES=[ # # Infos are small/medium amounts of information displayed in a modal # # dialog. All matching items are visible. # 'infos': [ -# {'title': 'Documentation', 'html': '<p>Some information about the service as html</p>', 'required_group': 'users'}, +# { +# 'title': 'uffd', +# 'button_text': 'Documentation', # Defaults to the title if not set +# 'html': '<p>Some information about the service as html</p>', +# 'required_group': 'users', +# }, # ], # # Links to external sites, all matching items are visible # 'links': [ @@ -121,6 +126,13 @@ SERVICES=[ # ] # }, ] + +# A banner text that will be displayed above the services list +SERVICES_BANNER='' + +# If the banner should be shown to users who are not logged in +SERVICES_BANNER_PUBLIC=True + # Enable the service overview page for users who are not logged in SERVICES_PUBLIC=True diff --git a/uffd/services/templates/overview.html b/uffd/services/templates/overview.html index 7027676c40f21b2090769afee3becd86f4ebd71d..5b91772c043787a7f5aa7b4d1dc1fda8e0c058bc 100644 --- a/uffd/services/templates/overview.html +++ b/uffd/services/templates/overview.html @@ -8,6 +8,14 @@ <div class="alert alert-warning" role="alert">Some services may not be publicly listed! Log in to see all services you have access to.</div> {% endif %} +{% if banner %} +<div class="card"> + <div class="card-body"> + {{ banner|safe }} + </div> +</div> +{% endif %} + {% macro service_card(service) %} <div class="col mb-4"> <div class="card h-100 {{ 'text-muted' if not service.has_access }}"> @@ -41,7 +49,7 @@ <div class="list-group-item"><i class="fas fa-users" {{ iconstyle }}></i> {{ group.name }}</div> {% endfor %} {% for info in service.infos %} - <a href="#" class="list-group-item list-group-item-action" data-toggle="modal" data-target="#info-modal-{{ info.id }}"><i class="fas fa-info-circle" {{ iconstyle }}></i> {{ info.title }}</a> + <a href="#" class="list-group-item list-group-item-action" data-toggle="modal" data-target="#info-modal-{{ info.id }}"><i class="fas fa-info-circle" {{ iconstyle }}></i> {{ info.button_text }}</a> {% endfor %} {% for link in service.links %} <a href="{{ link.url }}" class="list-group-item list-group-item-action"><i class="fas fa-external-link-alt" {{ iconstyle }}></i> {{ link.title }}</a> diff --git a/uffd/services/views.py b/uffd/services/views.py index 4868eafc3f391fcba0041997695878e838b8c717..f4f9a805156966300b07748ac68f3dbd17a83d36 100644 --- a/uffd/services/views.py +++ b/uffd/services/views.py @@ -53,6 +53,7 @@ def get_services(user=None): continue info = { 'title': info_data['title'], + 'button_text': info_data.get('button_text', info_data['title']), 'html': info_data['html'], 'id': '%d-%d'%(len(services), len(service['infos'])), } @@ -82,4 +83,11 @@ def index(): services = get_services(user) if not current_app.config['SERVICES']: abort(404) - return render_template('overview.html', user=user, services=services) + + banner = current_app.config.get('SERVICES_BANNER') + + # Set the banner to None if it is not public and no user is logged in + if not (current_app.config["SERVICES_BANNER_PUBLIC"] or user): + banner = None + + return render_template('overview.html', user=user, services=services, banner=banner)