Commits

Andrei Maksimovich committed c7e82ec Merge

merge 0.4.1 version

Comments (0)

Files changed (24)

 253b2464507e9cb426f866c1f2561e859233ea69 v0.2.0
 4ebbf2cf39b5cd8cd7f470726ac72f8516895804 v0.4.0
 3e822763bab3c567e003c957786397e0fb781929 v0.3.0
+628450a80e701ee4ea749d2a2e28b6023f52b64a v0.4.1
 ada8a46a7366f8aac1c90ff94594a4668a9b88d5 24Oct2011
 django-admin-tools changelog
 ============================
 
+Version 0.4.1, 15 November 2011:
+--------------------------------
+
+* Static files and django 1.3 support
+* Fixed modules instanciation issues (fixes #65)
+* Nested groups support & better html id generation (fixes issue #70)
+* Fixed various js and css problems
+* Added translation for Finnish + updates on other languages
+* More robust dashboard layout
+* Added force_show_title property to Group module
+
+
 Version 0.4.0, 13 December 2010:
 --------------------------------
 

admin_tools/__init__.py

  * a customizable menu bar,
  * tools to make admin theming easier.
 """
-VERSION = '0.4.0'
+VERSION = '0.4.1'

admin_tools/adminboard/management/commands/customdashboard.py

             raise CommandError('file "%s" already exists' % dst)
         context['file'] = os.path.basename(dst).split('.')[0]
         open(dst, 'w').write(render_to_string(tpl, context))
-        print '"%s" written.' % os.path.join(dst)
+        self.stdout.write('"%s" written.' % os.path.join(dst))
 

admin_tools/adminboard/modules.py

         A string determining how the group should be rendered, this can be one
         of the following values: 'tabs' (default), 'accordion' or 'stacked'.
 
+    ``force_show_title``
+        Default behaviour for Group module is to force children to always show
+        the title if Group has ``display`` = ``stacked``. If this flag is set
+        to ``False``, children title is shown according to their``show_title``
+        property. Note that in this case is children responsibility to have
+        meaningful content if no title is shown.
+
     Here's an example of modules group::
 
         from admin_tools.adminboard import modules, Dashboard
     .. image:: images/dashboard_module_group.png
     """
 
+    force_show_title = True
     template = 'admin_tools/adminboard/modules/group.html'
     display = 'tabs'
 
             module.collapsible = False
             module.draggable = False
             module.deletable = False
-            module.show_title = (self.display == 'stacked')
+            if self.force_show_title:
+                module.show_title = (self.display == 'stacked')
             module.init_with_context(context)
         self._initialized = True
 

admin_tools/adminboard/static/admin_tools/js/dashboard.js

 var init_dashboard = function(id, columns, preferences, url) {
-    $('#'+id).dashboard({
+    jQuery('#'+id).dashboard({
         'columns': columns,
         'load_preferences_function': function(options) {
             return preferences;
             jQuery.post(url, { data: JSON.stringify(preferences) });
         }
     });
-    $(".group-tabs").tabs();
-    $(".group-accordion").accordion({header: '.group-accordion-header'});
+    jQuery(".group-tabs").tabs();
+    jQuery(".group-accordion").accordion({header: '.group-accordion-header'});
 };

admin_tools/adminboard/static/admin_tools/js/jquery/jquery.dashboard.js

         var start = 0;
         var stop = 0;
         var last_stop = 0;
-        if (options.columns != sizes.length) {
-            // don't break layout if columns count changed
+        // don't break layout if columns count or elts count changed
+        var elts_count = 0;
+        for (var i in sizes) {
+            elts_count += sizes[i];
+        }
+        if (options.columns != sizes.length || elts_count != elts.length) {
+            // reset sizes so we don't break
             sizes = [];
         }
         for (var i = 0; i < options.columns; i++) {

admin_tools/adminboard/templates/admin_tools/adminboard/module.html

+{% load i18n %}
 {% if not module.is_empty %}
     <div id="module_{{ module.id }}" class="{{ module.render_css_classes }}">
-        {% if module.show_title %}<h2>{{ module.title }}</h2>{% endif %}
+        {% if module.show_title %}<h2>{% trans module.title %}</h2>{% endif %}
         <div class="dashboard-module-content">
             {% spaceless %}
             {% if module.pre_content %}

admin_tools/adminboard/utils.py

 
 def _get_dashboard_cls(dashboard_cls, context):
     if type(dashboard_cls) is types.DictType:
-        curr_url = context.get('request').META['PATH_INFO']
+        curr_url = context.get('request').path
         for key in dashboard_cls:
             admin_site_mod, admin_site_inst = key.rsplit('.', 1)
             admin_site_mod = import_module(admin_site_mod)

admin_tools/adminboard/views.py

 from django.contrib.auth.decorators import login_required
 from django.http import HttpResponse
-from django.views.generic.simple import direct_to_template
+from django.template import RequestContext
+from django.shortcuts import render_to_response
 
 try:
     from django.views.decorators.csrf import csrf_exempt
             dashboard_id=dashboard_id,
             instance=preferences
         )
-    return direct_to_template(request, 'admin_tools/adminboard/preferences_form.html', {
-        'form': form,   
-    })
+    return render_to_response('admin_tools/adminboard/preferences_form.html',
+                              RequestContext(request, {'form': form}))

admin_tools/locale/fi/LC_MESSAGES/django.po

 #
 msgid ""
 msgstr ""
-"Project-Id-Version: django-admin-tools 0.4.0\n"
+"Project-Id-Version: django-admin-tools 0.4.1\n"
 "Report-Msgid-Bugs-To: \n"
 "POT-Creation-Date: 2011-01-27 08:34+0100\n"
 "PO-Revision-Date: 2011-01-27 06:11+0200\n"

admin_tools/locale/nl/LC_MESSAGES/django.mo

Binary file modified.

admin_tools/locale/zh_TW/LC_MESSAGES/django.mo

Binary file modified.

admin_tools/locale/zh_TW/LC_MESSAGES/django.po

 
 #: adminboard/dashboards.py:81 menu/menus.py:100
 msgid "Dashboard"
-msgstr ""
+msgstr "控制台"
 
 #: adminboard/dashboards.py:217
 msgid "Quick links"
-msgstr ""
+msgstr "捷徑"
 
 #: adminboard/dashboards.py:223
 msgid "Return to site"
-msgstr ""
+msgstr "首頁"
 
 #: adminboard/dashboards.py:224 theming/templates/admin/base.html:43
 msgid "Change password"
 
 #: adminboard/dashboards.py:232 adminboard/modules.py:385 menu/menus.py:103
 msgid "Applications"
-msgstr ""
+msgstr "應用程序"
 
 #: adminboard/dashboards.py:238 menu/menus.py:107
 msgid "Administration"
-msgstr ""
+msgstr "管理"
 
 #: adminboard/dashboards.py:243 adminboard/dashboards.py:297
 #: adminboard/modules.py:538
 
 #: adminboard/dashboards.py:247
 msgid "Latest Django News"
-msgstr ""
+msgstr "最新 Django 新聞"
 
 #: adminboard/dashboards.py:254
 msgid "Support"
-msgstr ""
+msgstr "支援"
 
 #: adminboard/dashboards.py:257
 msgid "Django documentation"

admin_tools/media/admin_tools/css/menu.css

     background: transparent url(../images/admin-tools.png) repeat-x 0 -245px;
 }
 
-#header ul#navigation-menu li.disabled:hover,
-#header ul#navigation-menu li.disabled .over {
+#header ul#navigation-menu li.disabled a:hover,
+#header ul#navigation-menu li.disabled a.over {
     background: none;
 }

admin_tools/media/admin_tools/js/dashboard.js

 var init_dashboard = function(id, columns, preferences, url) {
-    $('#'+id).dashboard({
+    jQuery('#'+id).dashboard({
         'columns': columns,
         'load_preferences_function': function(options) {
             return preferences;
             jQuery.post(url, { data: JSON.stringify(preferences) });
         }
     });
-    $(".group-tabs").tabs();
-    $(".group-accordion").accordion({header: '.group-accordion-header'});
+    jQuery(".group-tabs").tabs();
+    jQuery(".group-accordion").accordion({header: '.group-accordion-header'});
 };

admin_tools/media/admin_tools/js/jquery/jquery.dashboard.js

         var start = 0;
         var stop = 0;
         var last_stop = 0;
-        if (options.columns != sizes.length) {
-            // don't break layout if columns count changed
+        // don't break layout if columns count or elts count changed
+        var elts_count = 0;
+        for (var i in sizes) {
+            elts_count += sizes[i];
+        }
+        if (options.columns != sizes.length || elts_count != elts.length) {
+            // reset sizes so we don't break
             sizes = [];
         }
         for (var i = 0; i < options.columns; i++) {

admin_tools/menu/management/commands/custommenu.py

             'project': project_name,
             'file': os.path.basename(dst).split('.')[0]
         }))
-        print '"%s" written.' % os.path.join(dst)
+        self.stdout.write('"%s" written.' % os.path.join(dst))
 

admin_tools/menu/static/admin_tools/css/menu.css

     background: transparent url(../images/admin-tools.png) repeat-x 0 -245px;
 }
 
-#header ul#navigation-menu li.disabled:hover,
-#header ul#navigation-menu li.disabled .over {
+#header ul#navigation-menu li.disabled a:hover,
+#header ul#navigation-menu li.disabled a.over {
     background: none;
 }

admin_tools/menu/templates/admin_tools/menu/item.html

 {% spaceless %}
 {% if not item.is_empty %}
 <li class="menu-item{% ifequal index 1 %} first{% endifequal %}{% if not item.enabled %} disabled{% endif %}{% if selected %} selected{% endif %}{% if item.css_classes %} {{ item.css_classes|join:' ' }}{% endif %}">
-<a href="{% if item.url and item.enabled %}{{ item.url }}{% else %}#{% endif %}"{% if item.description %} title="{{ item.description }}"{% endif %}{% if item.accesskey %} accesskey="{{ item.accesskey }}"{% endif %}>{% if item.children %}<span class="icon"></span>{% endif %}{{ item.title }}</a>
-    {% if item.children %}
+<a href="{% if item.url and item.enabled %}{{ item.url }}{% else %}#{% endif %}"{% if item.description %} title="{{ item.description }}"{% endif %}{% if item.accesskey %} accesskey="{{ item.accesskey }}"{% endif %}>{% if item.children and item.enabled %}<span class="icon"></span>{% endif %}{{ item.title }}</a>
+    {% if item.children and item.enabled %}
     <ul>
         {% for child_item in item.children %}
         {% admin_tools_render_menu_item child_item %}

admin_tools/menu/views.py

 from django.contrib.auth.decorators import login_required
 from django.http import HttpResponse, HttpResponseRedirect
-from django.shortcuts import get_object_or_404
-from django.views.generic.simple import direct_to_template
+from django.shortcuts import get_object_or_404, render_to_response
+from django.template import RequestContext
 
 try:
     from django.views.decorators.csrf import csrf_exempt
                 if request.POST.get('next'):
                     return HttpResponseRedirect(request.POST.get('next'))
                 return HttpResponse('Added')
-            return direct_to_template(request, 'admin_tools/menu/remove_bookmark_form.html', {
+            return render_to_response('admin_tools/menu/remove_bookmark_form.html',
+                       RequestContext(request, {
                 'bookmark': bookmark,
                 'url': bookmark.url,
-            });
+            }))
     else:
         form = BookmarkForm(user=request.user)
-    return direct_to_template(request, 'admin_tools/menu/form.html', {
-        'form': form,   
+    return render_to_response('admin_tools/menu/form.html',
+               RequestContext(request, {
+        'form': form,
         'title': 'Add Bookmark',
-    })
+    }))
 
 
 @login_required
             return HttpResponse('Saved')
     else:
         form = BookmarkForm(user=request.user, instance=bookmark)
-    return direct_to_template(request, 'admin_tools/menu/form.html', {
-        'form': form,   
+    return render_to_response('admin_tools/menu/form.html',
+               RequestContext(request, {
+        'form': form,
         'title': 'Edit Bookmark',
-    })
+    }))
 
 
 @login_required
             if request.POST.get('next'):
                 return HttpResponseRedirect(request.POST.get('next'))
             return HttpResponse('Deleted')
-        return direct_to_template(request, 'admin_tools/menu/add_bookmark_form.html', {
+        return render_to_response('admin_tools/menu/add_bookmark_form.html',
+                   RequestContext(request, {
             'url': request.POST.get('next'),
             'title': '**title**' #This gets replaced on the javascript side
-        });
-    return direct_to_template(request, 'admin_tools/menu/delete_confirm.html', {
+        }))
+    return render_to_response('admin_tools/menu/delete_confirm.html',
+               RequestContext(request, {
         'bookmark': bookmark,
         'title': 'Delete Bookmark',
-    })
+    }))

admin_tools/theming/templates/admin/base.html

-{% load theming_tags %}
+{% load theming_tags admin_static %}
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" lang="{{ LANGUAGE_CODE }}" xml:lang="{{ LANGUAGE_CODE }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif %}>
 <head>
 <title>{% block title %}{% endblock %}</title>
-<link rel="stylesheet" type="text/css" href="{% block stylesheet %}{% admin_static "admin/css/base.css" %}{% endblock %}" />
+<link rel="stylesheet" type="text/css" href="{% block stylesheet %}{% static "admin/css/base.css" %}{% endblock %}" />
 {% block extrastyle %}{% endblock %}
-<!--[if lte IE 7]><link rel="stylesheet" type="text/css" href="{% block stylesheet_ie %}{% load adminmedia %}{% admin_media_prefix %}css/ie.css{% endblock %}" /><![endif]-->
-{% if LANGUAGE_BIDI %}<link rel="stylesheet" type="text/css" href="{% block stylesheet_rtl %}{% admin_media_prefix %}css/rtl.css{% endblock %}" />{% endif %}
+<!--[if lte IE 7]><link rel="stylesheet" type="text/css" href="{% block stylesheet_ie %}{% load adminmedia %}{% static "admin/css/ie.css" %}{% endblock %}" /><![endif]-->
+{% if LANGUAGE_BIDI %}<link rel="stylesheet" type="text/css" href="{% block stylesheet_rtl %}{% static "admin/css/rtl.css" %}{% endblock %}" />{% endif %}
 {% render_theming_css %}
-<script type="text/javascript">window.__admin_media_prefix__ = "{% filter escapejs %}{% admin_static "admin/" %}{% endfilter %}";</script>
+<script type="text/javascript">window.__admin_media_prefix__ = "{% filter escapejs %}{% static "admin/" %}{% endfilter %}";</script>
 {% block extrahead %}{% endblock %}
 {% block blockbots %}<meta name="robots" content="NONE,NOARCHIVE" />{% endblock %}
 </head>

admin_tools/utils.py

     if type(dashboard_cls) is types.DictType:
         if context:
             request = context.get('request')
-        curr_url = request.META['PATH_INFO']
+        curr_url = request.path
         for key in dashboard_cls:
             mod, inst = key.rsplit('.', 1)
             mod = import_module(mod)
         for item in included:
             model, perms = item
             if fnmatch(full_name(model), pattern):
-                result.remove(item)
+                try:
+                    result.remove(item)
+                except ValueError:  # if the item was already removed skip
+                    pass
     return result
 
 
     This documentation covers the latest version of django-admin-tools (tip).
     For older versions please follow the links below:
 
+    * `Version 0.4.0 <http://readthedocs.org/docs/django-admin-tools/v0.4.1/>`_
     * `Version 0.4.0 <http://readthedocs.org/docs/django-admin-tools/v0.4.0/>`_
     * `Version 0.3.0 <http://readthedocs.org/docs/django-admin-tools/v0.3.0/>`_
     * `Version 0.2.0 <http://readthedocs.org/docs/django-admin-tools/v0.2.0/>`_