diff --git a/apps/common/templatetags/version_tags.py b/apps/common/templatetags/version_tags.py new file mode 100644 index 0000000000..a4e84f4e83 --- /dev/null +++ b/apps/common/templatetags/version_tags.py @@ -0,0 +1,13 @@ +from django.template import Library +from django.utils.importlib import import_module + +register = Library() + + +@register.simple_tag +def app_version(app_name): + try: + app = import_module(app_name) + return app.get_version() + except ImportError: + return u'' diff --git a/apps/main/__init__.py b/apps/main/__init__.py index adc3d46ade..0735aa3c13 100644 --- a/apps/main/__init__.py +++ b/apps/main/__init__.py @@ -14,6 +14,29 @@ check_settings = {'text': _(u'settings'), 'view': 'check_settings', 'famfam': 'c statistics = {'text': _(u'statistics'), 'view': 'statistics', 'famfam': 'table'} diagnostics = {'text': _(u'diagnostics'), 'view': 'diagnostics', 'famfam': 'pill'} +__version_info__ = { + 'major': 0, + 'minor': 5, + 'micro': 0, + 'releaselevel': 'alpha', + 'serial': 1 +} + +def get_version(): + """ + Return the formatted version information + """ + vers = ["%(major)i.%(minor)i" % __version_info__, ] + + if __version_info__['micro']: + vers.append(".%(micro)i" % __version_info__) + if __version_info__['releaselevel'] != 'final': + vers.append('%(releaselevel)s%(serial)i' % __version_info__) + return ''.join(vers) + +__version__ = get_version() + + main_menu = [ {'text': _(u'home'), 'view': 'home', 'famfam': 'house', 'position': 0}, {'text': _(u'tools'), 'view': 'tools_menu', 'links': [ diff --git a/apps/main/templates/about.html b/apps/main/templates/about.html index a798e60bf2..0e129a8e8b 100644 --- a/apps/main/templates/about.html +++ b/apps/main/templates/about.html @@ -1,12 +1,13 @@ {% extends "base.html" %} {% load i18n %} {% load project_tags %} +{% load version_tags %} {% block title %} :: {% trans "About this program" %}{% endblock %} {% block content %}