admin: use version attribute of theme desc.xml (#3025)
This commit is contained in:
parent
0607c9ebff
commit
c3c1c4c362
|
@ -380,9 +380,12 @@ class SettingsDirectory(QommonSettingsDirectory):
|
|||
'<a rel="popup" href="upload_theme">%s</a>' % _('Upload New Theme')
|
||||
|
||||
'<form action="themes" enctype="multipart/form-data" method="post">'
|
||||
themes = qommon.template.get_themes()
|
||||
themes = qommon.template.get_themes_dict()
|
||||
'<ul class="biglist themes">'
|
||||
for theme, (label, desc, author, icon) in sorted(themes.items()):
|
||||
for theme, theme_dict in sorted(themes.items()):
|
||||
label = theme_dict.get('label')
|
||||
if 'version' in theme_dict:
|
||||
label = '%s (%s)' % (label, theme_dict.get('version'))
|
||||
if current_theme == theme:
|
||||
checked = ' checked="checked"'
|
||||
else:
|
||||
|
@ -391,12 +394,12 @@ class SettingsDirectory(QommonSettingsDirectory):
|
|||
'<strong class="label">'
|
||||
' <input name="theme" value="%s" type="radio"%s>%s</input></strong>' % (
|
||||
theme, checked, label)
|
||||
if icon:
|
||||
if 'icon' in theme_dict:
|
||||
'<img src="/themes/%s/icon.png" alt="" class="theme-icon" />' % theme
|
||||
'<p class="details">%s' % desc
|
||||
'<p class="details">%s' % theme_dict.get('desc', '')
|
||||
' [<a href="download_theme?theme=%s">%s</a>]' % (theme, _('download'))
|
||||
if author:
|
||||
'<br/>by %s' % author
|
||||
if 'author' in theme_dict:
|
||||
'<br/>by %s' % theme_dict.get('author')
|
||||
'</p>'
|
||||
'</li>'
|
||||
'</ul>'
|
||||
|
|
|
@ -87,13 +87,17 @@ def get_theme_dict(theme_xml):
|
|||
except: # parse error
|
||||
return None
|
||||
name = tree.attrib['name']
|
||||
version = tree.attrib.get('version')
|
||||
label = tree.findtext('label')
|
||||
desc = tree.findtext('desc')
|
||||
author = tree.findtext('author')
|
||||
icon = os.path.join(os.path.dirname(theme_xml), 'icon.png')
|
||||
if not os.path.exists(icon):
|
||||
icon = None
|
||||
theme = {'name': name, 'label': label, 'desc': desc, 'author': author, 'icon': icon}
|
||||
icon = None
|
||||
if type(theme_xml) is str:
|
||||
icon = os.path.join(os.path.dirname(theme_xml), 'icon.png')
|
||||
if not os.path.exists(icon):
|
||||
icon = None
|
||||
theme = {'name': name, 'label': label, 'desc': desc, 'author': author,
|
||||
'icon': icon, 'version': version}
|
||||
theme['keywords'] = []
|
||||
for keyword in tree.findall('keywords/keyword'):
|
||||
theme['keywords'].append(keyword.text)
|
||||
|
|
Loading…
Reference in New Issue