Ticket #5518: 05-uncapfirst-verbose-name.diff

File 05-uncapfirst-verbose-name.diff, 14.2 KB (added by Petr Marhoun <petr.marhoun@…>, 16 years ago)
  • django/contrib/admin/filterspecs.py

    === modified file 'django/contrib/admin/filterspecs.py'
     
    88
    99from django.db import models
    1010from django.utils.encoding import smart_unicode, iri_to_uri
     11from django.utils.text import uncapfirst
    1112from django.utils.translation import ugettext as _
    1213import datetime
    1314
     
    3435        raise NotImplementedError()
    3536
    3637    def title(self):
    37         return self.field.verbose_name
     38        return uncapfirst(self.field.verbose_name)
    3839
    3940    def output(self, cl):
    4041        t = []
     
    6465        return len(self.lookup_choices) > 1
    6566
    6667    def title(self):
    67         return self.lookup_title
     68        return uncapfirst(self.lookup_title)
    6869
    6970    def choices(self, cl):
    7071        yield {'selected': self.lookup_val is None,
     
    120121        )
    121122
    122123    def title(self):
    123         return self.field.verbose_name
     124        return uncapfirst(self.field.verbose_name)
    124125
    125126    def choices(self, cl):
    126127        for title, param_dict in self.links:
     
    139140        self.lookup_val2 = request.GET.get(self.lookup_kwarg2, None)
    140141
    141142    def title(self):
    142         return self.field.verbose_name
     143        return uncapfirst(self.field.verbose_name)
    143144
    144145    def choices(self, cl):
    145146        for k, v in ((_('All'), None), (_('Yes'), '1'), (_('No'), '0')):
     
    163164        self.lookup_choices = model_admin.queryset(request).distinct().order_by(f.name).values(f.name)
    164165
    165166    def title(self):
    166         return self.field.verbose_name
     167        return uncapfirst(self.field.verbose_name)
    167168
    168169    def choices(self, cl):
    169170        yield {'selected': self.lookup_val is None,
  • django/contrib/admin/options.py

    === modified file 'django/contrib/admin/options.py'
     
    99from django.http import Http404, HttpResponse, HttpResponseRedirect
    1010from django.shortcuts import get_object_or_404, render_to_response
    1111from django.utils.html import escape
    12 from django.utils.text import capfirst, get_text_list
     12from django.utils.text import capfirst, uncapfirst, get_text_list
    1313from django.utils.translation import ugettext as _
    1414from django.utils.encoding import force_unicode
    1515import sets
     
    414414
    415415        # default message       
    416416        if add:
    417             msg = _('The %(name)s "%(obj)s" was added successfully.') % {'name': opts.verbose_name, 'obj': new_obj}
     417            msg = _('The %(name)s "%(obj)s" was added successfully.') % {'name': uncapfirst(opts.verbose_name), 'obj': new_obj}
    418418        else:
    419             msg = _('The %(name)s "%(obj)s" was changed successfully.') % {'name': opts.verbose_name, 'obj': new_obj}
     419            msg = _('The %(name)s "%(obj)s" was changed successfully.') % {'name': uncapfirst(opts.verbose_name), 'obj': new_obj}
    420420
    421421        # save as new
    422422        if request.POST.has_key('_saveasnew'):
     
    429429                redirect_url = '../../../'
    430430        # save and add another
    431431        elif request.POST.has_key('_addanother'):
    432             msg += ' ' + (_('You may add another %s below.') % opts.verbose_name)
     432            msg += ' ' + (_('You may add another %s below.') % uncapfirst(opts.verbose_name))
    433433            if add:
    434434                redirect_url = request.path
    435435            else:
     
    521521            inline_admin_formsets.append(inline_admin_formset)
    522522
    523523        c = template.RequestContext(request, {
    524             'title': _('Add %s') % opts.verbose_name,
     524            'title': _('Add %s') % uncapfirst(opts.verbose_name),
    525525            'adminform': adminForm,
    526526            'is_popup': request.REQUEST.has_key('_popup'),
    527527            'media': media,
     
    547547            raise PermissionDenied
    548548
    549549        if obj is None:
    550             raise Http404('%s object with primary key %r does not exist.' % (opts.verbose_name, escape(object_id)))
     550            raise Http404('%s object with primary key %r does not exist.' % (uncapfirst(opts.verbose_name), escape(object_id)))
    551551
    552552        if request.POST and request.POST.has_key('_saveasnew'):
    553553            return self.add_view(request)
     
    596596            inline_admin_formsets.append(inline_admin_formset)
    597597
    598598        c = template.RequestContext(request, {
    599             'title': _('Change %s') % opts.verbose_name,
     599            'title': _('Change %s') % uncapfirst(opts.verbose_name),
    600600            'adminform': adminForm,
    601601            'object_id': object_id,
    602602            'original': obj,
     
    654654            raise PermissionDenied
    655655
    656656        if obj is None:
    657             raise Http404('%s object with primary key %r does not exist.' % (opts.verbose_name, escape(object_id)))
     657            raise Http404('%s object with primary key %r does not exist.' % (uncapfirst(opts.verbose_name), escape(object_id)))
    658658
    659659        # Populate deleted_objects, a data structure of all related objects that
    660660        # will also be deleted.
     
    668668            obj_display = str(obj)
    669669            obj.delete()
    670670            LogEntry.objects.log_action(request.user.id, ContentType.objects.get_for_model(self.model).id, object_id, obj_display, DELETION)
    671             request.user.message_set.create(message=_('The %(name)s "%(obj)s" was deleted successfully.') % {'name': force_unicode(opts.verbose_name), 'obj': force_unicode(obj_display)})
     671            request.user.message_set.create(message=_('The %(name)s "%(obj)s" was deleted successfully.') % {'name': force_unicode(uncapfirst(opts.verbose_name)), 'obj': force_unicode(obj_display)})
    672672            return HttpResponseRedirect("../../")
    673673        extra_context = {
    674674            "title": _("Are you sure?"),
    675             "object_name": opts.verbose_name,
     675            "object_name": uncapfirst(opts.verbose_name),
    676676            "object": obj,
    677677            "deleted_objects": deleted_objects,
    678678            "perms_lacking": perms_needed,
  • django/contrib/admin/templates/admin/change_form.html

    === modified file 'django/contrib/admin/templates/admin/change_form.html'
     
    1818<div class="breadcrumbs">
    1919     <a href="../../../">{% trans "Home" %}</a> &rsaquo;
    2020     <a href="../">{{ opts.verbose_name_plural|capfirst|escape }}</a> &rsaquo;
    21      {% if add %}{% trans "Add" %} {{ opts.verbose_name|escape }}{% else %}{{ original|truncatewords:"18"|escape }}{% endif %}
     21     {% if add %}{% trans "Add" %} {{ opts.verbose_name|uncapfirst|escape }}{% else %}{{ original|truncatewords:"18"|escape }}{% endif %}
    2222</div>
    2323{% endif %}{% endblock %}
    2424
  • django/contrib/admin/templates/admin/change_list.html

    === modified file 'django/contrib/admin/templates/admin/change_list.html'
     
    1515<div id="content-main">
    1616{% block object-tools %}
    1717{% if has_add_permission %}
    18 <ul class="object-tools"><li><a href="add/{% if is_popup %}?_popup=1{% endif %}" class="addlink">{% blocktrans with cl.opts.verbose_name|escape as name %}Add {{ name }}{% endblocktrans %}</a></li></ul>
     18<ul class="object-tools"><li><a href="add/{% if is_popup %}?_popup=1{% endif %}" class="addlink">{% blocktrans with cl.opts.verbose_name|uncapfirst|escape as name %}Add {{ name }}{% endblocktrans %}</a></li></ul>
    1919{% endif %}
    2020{% endblock %}
    2121<div class="module{% if cl.has_filters %} filtered{% endif %}" id="changelist">
  • django/contrib/admin/templates/admin/edit_inline/stacked.html

    === modified file 'django/contrib/admin/templates/admin/edit_inline/stacked.html'
     
    55
    66{% for inline_admin_form in inline_admin_formset %}
    77<div class="inline-related {% if forloop.last %}last-related{% endif %}">
    8   <h2><b>{{ inline_admin_formset.opts.verbose_name|title }}:</b>&nbsp;{% if inline_admin_form.original %}{{ inline_admin_form.original }}{% else %} #{{ forloop.counter }}{% endif %}
     8  <h2><b>{{ inline_admin_formset.opts.verbose_name|capfirst }}:</b>&nbsp;{% if inline_admin_form.original %}{{ inline_admin_form.original }}{% else %} #{{ forloop.counter }}{% endif %}
    99    {% if inline_admin_formset.formset.deletable %}<span class="delete">{{ inline_admin_form.deletion_field.field }} {{ inline_admin_form.deletion_field.label_tag }}</span>{% endif %}
    1010    </h2>
    1111  {% if inline_admin_form.show_url %}
  • django/contrib/admin/templates/admin/pagination.html

    === modified file 'django/contrib/admin/templates/admin/pagination.html'
     
    77{% endfor %}
    88{% endif %}
    99{% ifequal cl.result_count 1 %}
    10         {% blocktrans with cl.result_count as count and cl.opts.verbose_name|escape as verbose_name %}{{ count }} {{ verbose_name }}{% endblocktrans %}
     10        {% blocktrans with cl.result_count as count and cl.opts.verbose_name|uncapfirst|escape as verbose_name %}{{ count }} {{ verbose_name }}{% endblocktrans %}
    1111{% else %}
    12         {% blocktrans with cl.result_count as count and cl.opts.verbose_name_plural|escape as verbose_name_plural %}{{ count }} {{ verbose_name_plural }}{% endblocktrans %}
     12        {% blocktrans with cl.result_count as count and cl.opts.verbose_name_plural|uncapfirst|escape as verbose_name_plural %}{{ count }} {{ verbose_name_plural }}{% endblocktrans %}
    1313{% endifequal %}
    1414{% if show_all_url %}&nbsp;&nbsp;<a href="{{ show_all_url }}" class="showall">{% trans 'Show all' %}</a>{% endif %}
    1515</p>
  • django/contrib/admin/templatetags/admin_list.py

    === modified file 'django/contrib/admin/templatetags/admin_list.py'
     
    55from django.db import models
    66from django.utils import dateformat
    77from django.utils.html import escape
    8 from django.utils.text import capfirst
     8from django.utils.text import capfirst, uncapfirst
    99from django.utils.translation import get_date_formats, get_partial_date_formats, ugettext as _
    1010from django.utils.encoding import smart_unicode, smart_str, force_unicode
    1111from django.template import Library
     
    7979            # attribute "short_description". If that doesn't exist, fall back
    8080            # to the method name. And __str__ and __unicode__ are special-cases.
    8181            if field_name == '__unicode__':
    82                 header = force_unicode(lookup_opts.verbose_name)
     82                header = force_unicode(uncapfirst(lookup_opts.verbose_name))
    8383            elif field_name == '__str__':
    84                 header = smart_str(lookup_opts.verbose_name)
     84                header = smart_str(uncapfirst(lookup_opts.verbose_name))
    8585            else:
    8686                attr = getattr(cl.model, field_name) # Let AttributeErrors propagate.
    8787                try:
     
    9999            # after the else clause.
    100100        else:
    101101            if isinstance(f.rel, models.ManyToOneRel) and f.null:
    102                 yield {"text": f.verbose_name}
     102                yield {"text": uncapfirst(f.verbose_name)}
    103103                continue
    104104            else:
    105                 header = f.verbose_name
     105                header = uncapfirst(f.verbose_name)
     106
    106107
    107108        th_classes = []
    108109        new_order_type = 'asc'
  • django/contrib/admin/util.py

    === modified file 'django/contrib/admin/util.py'
     
    11from django.core.exceptions import ObjectDoesNotExist
    22from django.db import models
    33from django.utils.html import escape
    4 from django.utils.text import capfirst
     4from django.utils.text import capfirst, uncapfirst
    55from django.utils.encoding import force_unicode
    66
    77def _nest_help(obj, depth, val):
     
    8383                    # Don't display link to edit, because it either has no
    8484                    # admin or is edited inline.
    8585                    nh(deleted_objects, current_depth, [_('One or more %(fieldname)s in %(name)s: %(obj)s') % \
    86                         {'fieldname': force_unicode(related.field.verbose_name), 'name': force_unicode(related.opts.verbose_name), 'obj': escape(sub_obj)}, []])
     86                        {'fieldname': force_unicode(uncapfirst(related.field.verbose_name)), 'name': force_unicode(uncapfirst(related.opts.verbose_name)), 'obj': escape(sub_obj)}, []])
    8787                else:
    8888                    # Display a link to the admin page.
    8989                    nh(deleted_objects, current_depth, [
    90                         (_('One or more %(fieldname)s in %(name)s:') % {'fieldname': force_unicode(related.field.verbose_name), 'name': force_unicode(related.opts.verbose_name)}) + \
     90                        (_('One or more %(fieldname)s in %(name)s:') % {'fieldname': force_unicode(uncapfirst(related.field.verbose_name)), 'name': force_unicode(uncapfirst(related.opts.verbose_name))}) + \
    9191                        (u' <a href="../../../../%s/%s/%s/">%s</a>' % \
    9292                            (related.opts.app_label, related.opts.module_name, sub_obj._get_pk_val(), escape(sub_obj))), []])
    9393        # If there were related objects, and the user doesn't have
  • django/contrib/admin/views/main.py

    === modified file 'django/contrib/admin/views/main.py'
     
    99from django.db.models.query import handle_legacy_orderlist, QuerySet
    1010from django.http import Http404
    1111from django.utils.encoding import force_unicode, smart_str
     12from django.utils.text import uncapfirst
    1213from django.utils.translation import ugettext
    1314import operator
    1415
     
    146147        self.query = request.GET.get(SEARCH_VAR, '')
    147148        self.query_set = self.get_query_set()
    148149        self.get_results(request)
    149         self.title = (self.is_popup and ugettext('Select %s') % force_unicode(self.opts.verbose_name) or ugettext('Select %s to change') % force_unicode(self.opts.verbose_name))
     150        self.title = (self.is_popup and ugettext('Select %s') % force_unicode(uncapfirst(self.opts.verbose_name)) or ugettext('Select %s to change') % force_unicode(uncapfirst(self.opts.verbose_name)))
    150151        self.filter_specs, self.has_filters = self.get_filters(request)
    151152        self.pk_attname = self.lookup_opts.pk.attname
    152153
Back to Top