mirror of
https://github.com/django/django.git
synced 2025-06-05 03:29:12 +00:00
magic-removal: Fixed URL-calculating logic in adminapplist template library
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2065 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
aa4039a4c5
commit
6a91c0d558
@ -13,12 +13,11 @@ class AdminApplistNode(template.Node):
|
|||||||
user = context['user']
|
user = context['user']
|
||||||
|
|
||||||
for app in models.get_installed_model_modules():
|
for app in models.get_installed_model_modules():
|
||||||
app_label = app.__name__.split('.')[:-1][-1]
|
app_label = app.__name__.split('.')[-2] # TODO: Abstract this logic
|
||||||
has_module_perms = user.has_module_perms(app_label)
|
has_module_perms = user.has_module_perms(app_label)
|
||||||
|
|
||||||
if has_module_perms:
|
if has_module_perms:
|
||||||
model_list = []
|
model_list = []
|
||||||
#HACK
|
|
||||||
app_url = "/".join( [comp for comp in app.__name__.split('.') if comp != 'models' ])
|
|
||||||
for m in app._MODELS:
|
for m in app._MODELS:
|
||||||
if m._meta.admin:
|
if m._meta.admin:
|
||||||
perms = {
|
perms = {
|
||||||
@ -32,7 +31,7 @@ class AdminApplistNode(template.Node):
|
|||||||
if True in perms.values():
|
if True in perms.values():
|
||||||
model_list.append({
|
model_list.append({
|
||||||
'name': capfirst(m._meta.verbose_name_plural),
|
'name': capfirst(m._meta.verbose_name_plural),
|
||||||
'admin_url': '%s/%s/' % (app_url, m.__name__.lower()),
|
'admin_url': '%s/%s/' % (app_label, m.__name__.lower()),
|
||||||
'perms': perms,
|
'perms': perms,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user