Skip to content

Commit 014b64c

Browse files
committed
Revert "Factor versions data out of VersionDebugPanel."
This reverts commit d05dcbb.
1 parent d05dcbb commit 014b64c

File tree

2 files changed

+33
-43
lines changed

2 files changed

+33
-43
lines changed

debug_toolbar/debug/version.py

Lines changed: 0 additions & 34 deletions
This file was deleted.

debug_toolbar/panels/version.py

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
import sys
2+
3+
import django
4+
from django.conf import settings
15
from django.template.loader import render_to_string
26
from django.utils.translation import ugettext_lazy as _
7+
8+
import debug_toolbar
39
from debug_toolbar.panels import DebugPanel
4-
from debug_toolbar.debug.version import DebugVersions
10+
511

612
class VersionDebugPanel(DebugPanel):
713
"""
@@ -10,26 +16,44 @@ class VersionDebugPanel(DebugPanel):
1016
name = 'Version'
1117
has_content = True
1218

13-
def __init__(self, context={}):
14-
super(VersionDebugPanel, self).__init__(context)
15-
self.debug_version = DebugVersions()
16-
1719
def nav_title(self):
1820
return _('Versions')
1921

2022
def nav_subtitle(self):
21-
return 'Django %s' % self.debug_version.django_version()
23+
return 'Django %s' % django.get_version()
2224

2325
def url(self):
2426
return ''
25-
27+
2628
def title(self):
2729
return _('Versions')
2830

2931
def content(self):
32+
versions = {}
33+
for app in settings.INSTALLED_APPS + ['django']:
34+
name = app.split('.')[-1].replace('_', ' ').capitalize()
35+
__import__(app)
36+
app = sys.modules[app]
37+
if hasattr(app, 'get_version'):
38+
get_version = app.get_version
39+
if callable(get_version):
40+
version = get_version()
41+
else:
42+
version = get_version
43+
elif hasattr(app, 'VERSION'):
44+
version = app.VERSION
45+
elif hasattr(app, '__version__'):
46+
version = app.__version__
47+
else:
48+
continue
49+
if isinstance(version, (list, tuple)):
50+
version = '.'.join(str(o) for o in version)
51+
versions[name] = version
52+
3053
context = self.context.copy()
3154
context.update({
32-
'versions': self.debug_version.get_versions(),
33-
'paths': self.debug_version.get_paths(),
55+
'versions': versions,
56+
'paths': sys.path,
3457
})
58+
3559
return render_to_string('debug_toolbar/panels/versions.html', context)

0 commit comments

Comments
 (0)