Ticket #15810: dj_adm_add_applabel_class.diff

File dj_adm_add_applabel_class.diff, 5.7 KB (added by aatanasov+django@…, 4 years ago)

patch which adds AppLabel to admin used to display app_label in a friendly way

  • django/contrib/admin/templates/admin/change_list.html

     
    4343      </a>
    4444       &rsaquo;
    4545       <a href="../">
    46          {{ app_label|capfirst }}
     46         {{ app_label.title|capfirst }}
    4747      </a>
    4848      &rsaquo;
    4949      {{ cl.opts.verbose_name_plural|capfirst }}
  • django/contrib/admin/templates/admin/delete_selected_confirmation.html

     
    44{% block breadcrumbs %}
    55<div class="breadcrumbs">
    66     <a href="../../">{% trans "Home" %}</a> &rsaquo;
    7      <a href="../">{{ app_label|capfirst }}</a> &rsaquo;
     7     <a href="../">{{ app_label.title|capfirst }}</a> &rsaquo;
    88     <a href="./">{{ opts.verbose_name_plural|capfirst }}</a> &rsaquo;
    99     {% trans 'Delete multiple objects' %}
    1010</div>
  • django/contrib/admin/templates/admin/object_history.html

     
    44{% block breadcrumbs %}
    55<div class="breadcrumbs">
    66    <a href="../../../../">{% trans 'Home' %}</a> &rsaquo;
    7     <a href="../../../">{{ app_label|capfirst }}</a> &rsaquo;
     7    <a href="../../../">{{ app_label.title|capfirst }}</a> &rsaquo;
    88    <a href="../../">{{ module_name }}</a> &rsaquo;
    99    <a href="../">{{ object|truncatewords:"18" }}</a> &rsaquo;
    1010    {% trans 'History' %}
  • django/contrib/admin/templates/admin/auth/user/change_password.html

     
    1010{% block breadcrumbs %}{% if not is_popup %}
    1111<div class="breadcrumbs">
    1212     <a href="../../../../">{% trans "Home" %}</a> &rsaquo;
    13      <a href="../../../">{{ opts.app_label|capfirst|escape }}</a> &rsaquo;
     13     <a href="../../../">{{ opts.app_label.title|capfirst|escape }}</a> &rsaquo;
    1414     <a href="../../">{{ opts.verbose_name_plural|capfirst }}</a> &rsaquo;
    1515     <a href="../">{{ original|truncatewords:"18" }}</a> &rsaquo;
    1616     {% trans 'Change password' %}
  • django/contrib/admin/templates/admin/change_form.html

     
    1717{% block breadcrumbs %}{% if not is_popup %}
    1818<div class="breadcrumbs">
    1919     <a href="../../../">{% trans "Home" %}</a> &rsaquo;
    20      <a href="../../">{{ app_label|capfirst|escape }}</a> &rsaquo;
     20     <a href="../../">{{ app_label.title|capfirst|escape }}</a> &rsaquo;
    2121     {% if has_change_permission %}<a href="../">{{ opts.verbose_name_plural|capfirst }}</a>{% else %}{{ opts.verbose_name_plural|capfirst }}{% endif %} &rsaquo;
    2222     {% if add %}{% trans "Add" %} {{ opts.verbose_name }}{% else %}{{ original|truncatewords:"18" }}{% endif %}
    2323</div>
  • django/contrib/admin/templates/admin/delete_confirmation.html

     
    44{% block breadcrumbs %}
    55<div class="breadcrumbs">
    66     <a href="../../../../">{% trans "Home" %}</a> &rsaquo;
    7      <a href="../../../">{{ app_label|capfirst }}</a> &rsaquo;
     7     <a href="../../../">{{ app_label.title|capfirst }}</a> &rsaquo;
    88     <a href="../../">{{ opts.verbose_name_plural|capfirst }}</a> &rsaquo;
    99     <a href="../">{{ object|truncatewords:"18" }}</a> &rsaquo;
    1010     {% trans 'Delete' %}
  • django/contrib/admin/util.py

     
    385385        return limit_choices_to # already a Q
    386386    else:
    387387        return models.Q(**limit_choices_to) # convert dict to Q
     388
     389
     390class AppLabel(str):
     391    def __new__(cls,value,title=None):
     392        obj = str.__new__(cls, value)
     393        obj._my_title = title
     394        return obj
     395
     396    def title(self):
     397        if self._my_title is not None:
     398            return self._my_title
     399        return super(AppLabel,self).title()
  • django/contrib/admin/sites.py

     
    388388        app_dict = {}
    389389        for model, model_admin in self._registry.items():
    390390            if app_label == model._meta.app_label:
     391                app_label = model._meta.app_label
    391392                if has_module_perms:
    392393                    perms = model_admin.get_model_perms(request)
    393394
     
    416417        # Sort the models alphabetically within each app.
    417418        app_dict['models'].sort(key=lambda x: x['name'])
    418419        context = {
    419             'title': _('%s administration') % capfirst(app_label),
     420            'title': _('%s administration') % (app_label.title()),
    420421            'app_list': [app_dict],
    421422            'root_path': self.root_path,
    422423        }
Back to Top