diff options
-rw-r--r-- | app/lib/templatetags/templatetags/admin_reorder.py | 45 | ||||
-rw-r--r-- | app/projects/views.py | 4 | ||||
-rw-r--r-- | design/templates/admin/buttons.html | 13 | ||||
-rw-r--r-- | design/templates/admin/index.html | 2 |
4 files changed, 55 insertions, 9 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) diff --git a/app/projects/views.py b/app/projects/views.py index 39ae781..23500e0 100644 --- a/app/projects/views.py +++ b/app/projects/views.py @@ -1,6 +1,6 @@ from django.shortcuts import render_to_response, get_object_or_404 from django.template import RequestContext -from django.db.models import get_model +from django.apps import apps from projects.shortcuts import render_to_geojson from projects.models.natparks import NationalParks @@ -17,7 +17,7 @@ projects = { def detail(request, slug): """Projects by slug""" name = projects[slug] - model = get_model('projects', name) + model = apps.get_model('projects', name) if slug == 'national-parks': qs = model.objects.filter(visited__exact=True).order_by("-date_visited_begin") else: diff --git a/design/templates/admin/buttons.html b/design/templates/admin/buttons.html index a4a2080..677fa08 100644 --- a/design/templates/admin/buttons.html +++ b/design/templates/admin/buttons.html @@ -12,21 +12,20 @@ overflow: visible !important; } .item a { - min-width: 150px; - font-size: 110%; + text-transform: uppercase; + min-width: 180px; + font-size: 90%; position: relative; display: inline-block; margin: 0px; - padding: 5px; - height: 28px; - font-weight: bold; + padding: 7px 5px; + height: 32px; -moz-box-sizing: border-box; cursor: pointer; overflow: hidden; vertical-align: top; color: rgb(255, 255, 255); - border: 2px solid rgb(91, 128, 178); - background: url("../img/default-bg.gif") repeat-x scroll center bottom rgb(124, 160, 199); + background: #79aec8; } </style> diff --git a/design/templates/admin/index.html b/design/templates/admin/index.html index 19a5d1b..f8d201f 100644 --- a/design/templates/admin/index.html +++ b/design/templates/admin/index.html @@ -12,7 +12,9 @@ {% block content %} <div id="content-main"> +{% load admin_reorder %} {% if app_list %} + {% app_order %} {% for app in app_list %} <div class="module"> <table> |