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 @@
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 @@