Commits

Poul Sysolyatin committed 1ae9239

Small bugfixes

Comments (0)

Files changed (9)

russian_admin/admin.py

 ``from django.contrib import admin`` на ``from russian_admin import admin``.
 """
 
-from __future__ import absolute_import
 from django.contrib import admin
 from django.contrib.admin import *
-from .sites import AdminSite, site
+from russian_admin.sites import AdminSite, site
 
 class ModelAdmin(admin.ModelAdmin):
     pass

russian_admin/breadcrumbs.py

     def rename(self, f, name = u''):
         def wrapper(*args, **kwargs):
             extra_context = kwargs.get('extra_context', {})
-            extra_context['app_label'] = _(extra_context.get('app_label', self.app_label))
             if 'delete_view' != f.__name__:
                 extra_context['title'] = self.get_title_by_name(f.__name__, args[1], name)
             else:
         for model in model_or_iterable:
             if admin_class is None:
                 admin_class = type(model.__name__+'Admin', (admin.ModelAdmin,), {})
+
             self.app_label = model._meta.app_label
             current_name = model._meta.verbose_name.upper()
             admin_class.add_view = self.rename(admin_class.add_view, current_name)

russian_admin/sites.py

 # -*- coding: utf-8 -*-
-from __future__ import absolute_import
 from django.contrib.admin import sites
-from .breadcrumbs import I18nLabel
-from .admin import ModelAdmin
+from russian_admin.breadcrumbs import I18nLabel
+from russian_admin.admin import ModelAdmin
 
 class AdminSite(sites.AdminSite):
 

russian_admin/templates/russian_admin/admin/change_form.html

 {% block breadcrumbs %}{% if not is_popup %}
 <div class="breadcrumbs">
      <a href="../../../">{% trans "Home" %}</a> &rsaquo;
-     <a href="../../">{{ app_label|capfirst|escape }}</a> &rsaquo;
+     {% load russian_admin_tags %}
+     <a href="../../">{{ app_label|capfirst|labeltr|escape }}</a> &rsaquo;
      {% if has_change_permission %}<a href="../">{{ opts.verbose_name_plural|capfirst }}</a>{% else %}{{ opts.verbose_name_plural|capfirst }}{% endif %} &rsaquo;
      {% if add %}{% trans "Add" %} {{ opts.verbose_name|inflect:"вн" }}{% else %}{{ original|truncatewords:"18" }}{% endif %}
 </div>

russian_admin/templates/russian_admin/admin/change_list.html

       </a>
        &rsaquo;
        <a href="../">
-         {{ app_label|capfirst }}
+         {% load russian_admin_tags %}
+         {{ app_label|capfirst|labeltr }}
       </a>
       &rsaquo;
       {{ cl.opts.verbose_name_plural|capfirst }}

russian_admin/templates/russian_admin/admin/delete_selected_confirmation.html

 {% extends "admin/base_site.html" %}
-{% load i18n l10n pymorphy_tags util_tags %}
+{% load i18n l10n pymorphy_tags russian_admin_tags %}
 
 {% block breadcrumbs %}
 <div class="breadcrumbs">

russian_admin/templatetags/__init__.py

Empty file added.

russian_admin/templatetags/russian_admin_tags.py

+from django import template
+from pymorphy.django_conf import default_morph as morph
+from django.utils.translation import ugettext as _
+
+register = template.Library()
+
+@register.filter
+def plural_from_object(source, object):
+    l = len(object[0])
+    if 1 == l:
+      return source
+    return morph.pluralize_inflected_ru(source.upper(), l).lower()
+
+@register.filter
+def labeltr(label):
+  return _( label )
     long_description = open('README.rst').read(),
 
     license = 'MIT license',
-    packages = ['russian_admin'],
+    packages = ['russian_admin',
+                'russian_admin.dashboard',
+               ],
 
     package_data={
         'russian_admin': [