summaryrefslogtreecommitdiff
path: root/app/lib
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2015-12-01 22:31:52 -0500
committerluxagraf <sng@luxagraf.net>2015-12-01 22:31:52 -0500
commitef9747be6d50d536c149d31e978b61e2381baba3 (patch)
tree585592bece9300d9411e43bc19ef8aa32e4c7238 /app/lib
parentac914254cdde1e8fc9c5632482bd90a9d8cbf833 (diff)
updated site to work with django 1.9's new admin look
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/templatetags/templatetags/admin_reorder.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/app/lib/templatetags/templatetags/admin_reorder.py b/app/lib/templatetags/templatetags/admin_reorder.py
new file mode 100644
index 0000000..83ccf9e
--- /dev/null
+++ b/app/lib/templatetags/templatetags/admin_reorder.py
@@ -0,0 +1,45 @@
+from django.template.base import Node
+from django.conf import settings
+from django import template
+
+# Get template.Library instance
+register = template.Library()
+
+
+class AppOrderNode(Node):
+ """
+ Reorders the app_list and child model lists on the admin index page.
+ """
+ def render(self, context):
+ if 'app_list' in context:
+ app_list = list(context['app_list'])
+ ordered = []
+ # look at each app in the user order
+ for app in settings.ADMIN_REORDER:
+ app_name, app_models = app[0], app[1]
+ # look at each app in the orig order
+ for app_def in app_list:
+ if app_def['name'] == app_name:
+ model_list = list(app_def['models'])
+ mord = []
+ # look at models in user order
+ for model_name in app_models:
+ # look at models in orig order
+ for model_def in model_list:
+ if model_def['name'] == model_name:
+ mord.append(model_def)
+ model_list.remove(model_def)
+ break
+ mord[len(mord):] = model_list
+ ordered.append({'app_url': app_def['app_url'],
+ 'models': mord, 'name': app_def['name']})
+ app_list.remove(app_def)
+ break
+ ordered[len(ordered):] = app_list
+ context['app_list'] = ordered
+ return ''
+
+
+def app_order(parser, token):
+ return AppOrderNode()
+var = register.tag(app_order)