Change version view. New way to get name and version from plugins.

This commit is contained in:
Norman Jäckel 2013-05-11 14:27:46 +02:00
parent 98c7611622
commit 76d7409830
2 changed files with 24 additions and 7 deletions

View File

@ -6,7 +6,9 @@
{% block content %} {% block content %}
<h1>{% trans 'Version' %}</h1> <h1>{% trans 'Version' %}</h1>
<ul>
{% for version in versions %} {% for version in versions %}
<p>{{ version.0 }} {% trans "Version" %}: {{ version.1 }}</p> <li>{{ version.0 }} {% trans "Version" %} {{ version.1 }}</li>
{% endfor %} {% endfor %}
</ul>
{% endblock %} {% endblock %}

View File

@ -19,7 +19,7 @@ from openslides.utils.views import TemplateView
class VersionView(TemplateView): class VersionView(TemplateView):
""" """
Show version infos. Shows version infos.
""" """
template_name = 'core/version.html' template_name = 'core/version.html'
@ -32,20 +32,35 @@ class VersionView(TemplateView):
# OpenSlides version. During development the git commit id is added. # OpenSlides version. During development the git commit id is added.
openslides_version_string = get_version() openslides_version_string = get_version()
if not RELEASE: if not RELEASE:
openslides_version_string += ' Commit: %s' % get_git_commit_id() openslides_version_string += ' Commit %s' % get_git_commit_id()
context['versions'] = [('OpenSlides', openslides_version_string)] context['versions'] = [('OpenSlides', openslides_version_string)]
# Versions of plugins. # Versions of plugins.
for plugin in settings.INSTALLED_PLUGINS: for plugin in settings.INSTALLED_PLUGINS:
# Get plugin
try: try:
mod = import_module(plugin) mod = import_module(plugin)
plugin_version = get_version(mod.VERSION) except ImportError:
except (ImportError, AttributeError, AssertionError):
continue continue
# Get version.
try:
plugin_version = mod.get_version()
except AttributeError:
try:
plugin_version = mod.VERSION
except AttributeError:
continue
# Get name.
try:
plugin_name = mod.get_name()
except AttributeError:
try: try:
plugin_name = mod.NAME plugin_name = mod.NAME
except AttributeError: except AttributeError:
plugin_name = mod.__name__.split('.')[0] plugin_name = mod.__name__.split('.')[0]
context['versions'].append((plugin_name, plugin_version)) context['versions'].append((plugin_name, plugin_version))
return context return context