core: add about modal

This commit is contained in:
Jens Langhammer 2018-12-16 16:02:03 +01:00
parent 9117e09f1c
commit 9e289e9937
No known key found for this signature in database
GPG Key ID: BEBC05297D92821B
8 changed files with 60 additions and 2 deletions

View File

@ -9,6 +9,7 @@ class PassbookAuditConfig(AppConfig):
name = 'passbook.audit' name = 'passbook.audit'
label = 'passbook_audit' label = 'passbook_audit'
verbose_name = 'passbook Audit'
mountpoint = 'audit/' mountpoint = 'audit/'
def ready(self): def ready(self):

View File

@ -7,3 +7,4 @@ class PassbookCaptchaFactorConfig(AppConfig):
name = 'passbook.captcha_factor' name = 'passbook.captcha_factor'
label = 'passbook_captcha_factor' label = 'passbook_captcha_factor'
verbose_name = 'passbook Captcha'

View File

@ -12,6 +12,7 @@
{% endblock %} {% endblock %}
</title> </title>
<link rel="icon" type="image/png" href="{% static 'img/logo.png' %}"> <link rel="icon" type="image/png" href="{% static 'img/logo.png' %}">
<link rel="shortcut icon" type="image/png" href="{% static 'img/logo.png' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/patternfly.min.css' %}"> <link rel="stylesheet" type="text/css" href="{% static 'css/patternfly.min.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/patternfly-additions.min.css' %}"> <link rel="stylesheet" type="text/css" href="{% static 'css/patternfly-additions.min.css' %}">
{% block head %} {% block head %}
@ -25,5 +26,8 @@
<script src="{% static 'js/patternfly.min.js' %}"></script> <script src="{% static 'js/patternfly.min.js' %}"></script>
{% block scripts %} {% block scripts %}
{% endblock %} {% endblock %}
<div class="modals">
{% include 'partials/about_modal.html' %}
</div>
</body> </body>
</html> </html>

View File

@ -26,7 +26,7 @@
</button> </button>
<ul class="dropdown-menu" aria-labelledby="horizontalDropdownMenu1"> <ul class="dropdown-menu" aria-labelledby="horizontalDropdownMenu1">
<li><a href="#0">Help</a></li> <li><a href="#0">Help</a></li>
<li><a href="#0">About</a></li> <li><a data-toggle="modal" data-target="#about-modal" href="#0">{% trans 'About' %}</a></li>
</ul> </ul>
</li> </li>
<li class="dropdown"> <li class="dropdown">

View File

@ -0,0 +1,36 @@
{% load static %}
{% load i18n %}
{% load cache %}
{% load utils %}
<div class="modal fade" id="about-modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content about-modal-pf">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
<span class="pficon pficon-close"></span>
</button>
</div>
<div class="modal-body">
<h1>{% trans 'passbook' %}</h1>
<div class="product-versions-pf">
<ul class="list-unstyled">
{% app_versions as vers %}
{% cache 600 versions %}
{% for app, ver in vers.items %}
<li><strong>{{ app }}</strong> {{ ver }}</li>
{% endfor %}
{% endcache %}
</ul>
</div>
<div class="trademark-pf">
Trademark and Copyright Information
</div>
</div>
<div class="modal-footer">
<img style="max-height:64px;" src="{% static 'img/logo.png' %}" alt=" Symbol">
</div>
</div>
</div>
</div>

View File

@ -8,4 +8,4 @@ class PassbookLdapConfig(AppConfig):
name = 'passbook.ldap' name = 'passbook.ldap'
label = 'passbook_ldap' label = 'passbook_ldap'
verbose_name = 'Passbook LDAP' verbose_name = 'passbook LDAP'

View File

@ -2,6 +2,7 @@
import glob import glob
import os import os
import socket import socket
from importlib import import_module
from urllib.parse import urljoin from urllib.parse import urljoin
from django import template from django import template
@ -163,3 +164,17 @@ def unslug(_input):
def css_class(field, css): def css_class(field, css):
"""Add css class to form field""" """Add css class to form field"""
return field.as_widget(attrs={"class": css}) return field.as_widget(attrs={"class": css})
@register.simple_tag
def app_versions():
"""Return dictionary of app_name: version"""
app_versions = {}
for app in apps.get_app_configs():
ver_module = import_module(app.name)
ver = getattr(ver_module, '__version__', None)
if ver:
if not isinstance(ver, str):
ver = '.'.join([str(x) for x in ver])
app_versions[app.verbose_name] = ver
return app_versions

View File

@ -8,4 +8,5 @@ class PassbookTOTPConfig(AppConfig):
name = 'passbook.totp' name = 'passbook.totp'
label = 'passbook_totp' label = 'passbook_totp'
verbose_name = 'passbook TOTP'
mountpoint = 'user/totp/' mountpoint = 'user/totp/'