From bc13f136f03bd8649ac5574484ac11d77be551c6 Mon Sep 17 00:00:00 2001 From: Michael Ziegler Date: Fri, 30 Apr 2010 14:26:18 +0200 Subject: [PATCH] add version info to the mumble app, and display the current and newest available version on the imprint page. --- pyweb/mumble/__init__.py | 30 +++++++++++++++++++++++ pyweb/processors.py | 4 +++ pyweb/settings.py | 1 + pyweb/templates/index.html | 2 +- pyweb/templates/mobile_index.html | 2 +- pyweb/templates/registration/imprint.html | 14 +++++++++-- pyweb/views.py | 2 ++ 7 files changed, 51 insertions(+), 4 deletions(-) diff --git a/pyweb/mumble/__init__.py b/pyweb/mumble/__init__.py index cb703eb..0681312 100644 --- a/pyweb/mumble/__init__.py +++ b/pyweb/mumble/__init__.py @@ -12,3 +12,33 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. """ + +version = { 'major': 2, 'minor': 2, 'beta': None } + +if version['beta']: + version_str = "v%(major)d.%(minor)dbeta%(beta)d" % version +else: + version_str = "v%(major)d.%(minor)d" % version + +def getVersions(): + """ Generator that yields all available upstream versions. """ + url = 'http://bitbucket.org/Svedrin/mumble-django/raw/tip/.hgtags' + from urllib2 import urlopen + webtags = urlopen(url) + try: + while True: + line = webtags.readline().strip() + if not line: + raise StopIteration + _, version = line.split(' ') + yield version + finally: + webtags.close() + +def getLatestUpstreamVersion(): + """ Return the latest version available upstream. """ + return max(getVersions()) + +def isUptodate(): + """ Check if this version of Mumble-Django is the latest available. """ + return version_str >= getLatestUpstreamVersion() diff --git a/pyweb/processors.py b/pyweb/processors.py index 381bd02..ed92297 100644 --- a/pyweb/processors.py +++ b/pyweb/processors.py @@ -17,3 +17,7 @@ def installed_apps(request): from django.conf import settings return { 'ROSETTA_INSTALLED': "rosetta" in settings.INSTALLED_APPS } + +def mumble_version(request): + from mumble import version_str + return { 'CURRENTVERSION': version_str } diff --git a/pyweb/settings.py b/pyweb/settings.py index 7c11d55..c8baaa1 100644 --- a/pyweb/settings.py +++ b/pyweb/settings.py @@ -206,6 +206,7 @@ TEMPLATE_CONTEXT_PROCESSORS = ( "django.core.context_processors.i18n", "django.core.context_processors.media", 'processors.installed_apps', + 'processors.mumble_version', ) TEST_RUNNER = 'mumble.testrunner.run_tests' diff --git a/pyweb/templates/index.html b/pyweb/templates/index.html index 5e0cfe1..7e06e76 100644 --- a/pyweb/templates/index.html +++ b/pyweb/templates/index.html @@ -67,7 +67,7 @@
- You are using Mumble-Django -- + You are using Mumble-Django {{ CURRENTVERSION }} -- interface built using ExtJS
diff --git a/pyweb/templates/mobile_index.html b/pyweb/templates/mobile_index.html index 4b5505b..6c02623 100644 --- a/pyweb/templates/mobile_index.html +++ b/pyweb/templates/mobile_index.html @@ -26,7 +26,7 @@
diff --git a/pyweb/templates/registration/imprint.html b/pyweb/templates/registration/imprint.html index 9276b45..11cb205 100644 --- a/pyweb/templates/registration/imprint.html +++ b/pyweb/templates/registration/imprint.html @@ -11,8 +11,18 @@
Furthermore, registered Django users can sign up for user accounts on the configured vservers and change their registration names and passwords, and Django admins can manage server admins through the webinterface.

- It is being developed by Michael "Svedrin" Ziegler. + It is being developed by Michael "Svedrin" Ziegler. See the attached AUTHORS and COPYRIGHT files for details.
+
+

+

+ + + + +
Version information
Running version{{ CURRENTVERSION }}
Newest available version{{ upstreamversion }}

+

+

+ All JavaScript elements were implemented using the ExtJS JavaScript library.

-

All JavaScript elements were implemented using the ExtJS JavaScript library.

{% endblock %} diff --git a/pyweb/views.py b/pyweb/views.py index 8bc6322..ffdc20e 100644 --- a/pyweb/views.py +++ b/pyweb/views.py @@ -35,6 +35,8 @@ def profile( request ): def imprint( request ): + import mumble return render_to_response( 'registration/imprint.html', + { 'upstreamversion': mumble.getLatestUpstreamVersion() }, context_instance = RequestContext(request) );