Skip to content

Commit 543063c

Browse files
committed
Merge pull request sshwsfc#165 from clint74/develop
Adding apps_icons
2 parents effe5c0 + c57282d commit 543063c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

xadmin/views/base.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ class CommAdminView(BaseAdminView):
298298
global_models_icon = {}
299299
default_model_icon = None
300300
apps_label_title = {}
301+
apps_icons = {}
301302

302303
def get_site_menu(self):
303304
return None
@@ -321,6 +322,7 @@ def get_url(https://github.com/menu,%20had_urls):
321322
if getattr(model_admin, 'hidden_menu', False):
322323
continue
323324
app_label = model._meta.app_label
325+
app_icon = None
324326
model_dict = {
325327
'title': unicode(capfirst(model._meta.verbose_name_plural)),
326328
'url': self.get_model_url(model, "changelist"),
@@ -349,16 +351,22 @@ def get_url(https://github.com/menu,%20had_urls):
349351
app_title = getattr(mod, 'verbose_name')
350352
elif 'app_title' in dir(mod):
351353
app_title = getattr(mod, 'app_title')
354+
#find app icon
355+
if app_label.lower() in self.apps_icons:
356+
app_icon = self.apps_icons[app_label.lower()]
352357

353358
nav_menu[app_key] = {
354359
'title': app_title,
355360
'menus': [model_dict],
356361
}
357362

358363
app_menu = nav_menu[app_key]
359-
if ('first_icon' not in app_menu or
364+
if app_icon:
365+
app_menu['first_icon'] = app_icon
366+
elif ('first_icon' not in app_menu or
360367
app_menu['first_icon'] == self.default_model_icon) and model_dict.get('icon'):
361368
app_menu['first_icon'] = model_dict['icon']
369+
362370
if 'first_url' not in app_menu and model_dict.get('url'):
363371
app_menu['first_url'] = model_dict['url']
364372

0 commit comments

Comments
 (0)