Commits

shavrin_ivan  committed bb17436

Changes allow selects dashboard_cls usin regex rule. Example: regex based url as admin_index.

  • Participants
  • Parent commits 889114a

Comments (0)

Files changed (2)

File admin_tools/dashboard/utils.py

 from django.utils.text import capfirst
 from django.core.urlresolvers import reverse
 
+import re
+from urllib import unquote
+
 from admin_tools.dashboard.registry import Registry
 from admin_tools.utils import get_admin_site
 
             admin_site_mod = import_module(admin_site_mod)
             admin_site = getattr(admin_site_mod, admin_site_inst)
             admin_url = reverse('%s:index' % admin_site.name)
-            if curr_url.startswith(admin_url):
+            admin_url_re = re.compile(unquote(admin_url))
+            if admin_url_re.match(curr_url):
                 mod, inst = dashboard_cls[key].rsplit('.', 1)
                 mod = import_module(mod)
                 return getattr(mod, inst)

File admin_tools/utils.py

 import types
 from fnmatch import fnmatch
 
+import re
+from urllib import unquote
+
 from django.conf import settings
 from django.contrib import admin
 from django.core.urlresolvers import reverse
             mod = import_module(mod)
             admin_site = getattr(mod, inst)
             admin_url = reverse('%s:index' % admin_site.name)
-            if curr_url.startswith(admin_url):
+            admin_url_re = re.compile(unquote(admin_url))
+            if admin_url_re.match(curr_url):
                 return admin_site
     else:
         return admin.site