Code

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

File 05-uncapfirst-verbose-name.diff, 14.2 KB (added by Petr Marhoun <petr.marhoun@…>, 6 years ago)
Line 
1=== modified file 'django/contrib/admin/filterspecs.py'
2--- django/contrib/admin/filterspecs.py 2007-11-13 02:21:19 +0000
3+++ django/contrib/admin/filterspecs.py 2007-11-13 02:16:19 +0000
4@@ -8,6 +8,7 @@
5 
6 from django.db import models
7 from django.utils.encoding import smart_unicode, iri_to_uri
8+from django.utils.text import uncapfirst
9 from django.utils.translation import ugettext as _
10 import datetime
11 
12@@ -34,7 +35,7 @@
13         raise NotImplementedError()
14 
15     def title(self):
16-        return self.field.verbose_name
17+        return uncapfirst(self.field.verbose_name)
18 
19     def output(self, cl):
20         t = []
21@@ -64,7 +65,7 @@
22         return len(self.lookup_choices) > 1
23 
24     def title(self):
25-        return self.lookup_title
26+        return uncapfirst(self.lookup_title)
27 
28     def choices(self, cl):
29         yield {'selected': self.lookup_val is None,
30@@ -120,7 +121,7 @@
31         )
32 
33     def title(self):
34-        return self.field.verbose_name
35+        return uncapfirst(self.field.verbose_name)
36 
37     def choices(self, cl):
38         for title, param_dict in self.links:
39@@ -139,7 +140,7 @@
40         self.lookup_val2 = request.GET.get(self.lookup_kwarg2, None)
41 
42     def title(self):
43-        return self.field.verbose_name
44+        return uncapfirst(self.field.verbose_name)
45 
46     def choices(self, cl):
47         for k, v in ((_('All'), None), (_('Yes'), '1'), (_('No'), '0')):
48@@ -163,7 +164,7 @@
49         self.lookup_choices = model_admin.queryset(request).distinct().order_by(f.name).values(f.name)
50 
51     def title(self):
52-        return self.field.verbose_name
53+        return uncapfirst(self.field.verbose_name)
54 
55     def choices(self, cl):
56         yield {'selected': self.lookup_val is None,
57
58=== modified file 'django/contrib/admin/options.py'
59--- django/contrib/admin/options.py     2007-11-15 19:56:56 +0000
60+++ django/contrib/admin/options.py     2007-11-15 19:57:01 +0000
61@@ -9,7 +9,7 @@
62 from django.http import Http404, HttpResponse, HttpResponseRedirect
63 from django.shortcuts import get_object_or_404, render_to_response
64 from django.utils.html import escape
65-from django.utils.text import capfirst, get_text_list
66+from django.utils.text import capfirst, uncapfirst, get_text_list
67 from django.utils.translation import ugettext as _
68 from django.utils.encoding import force_unicode
69 import sets
70@@ -414,9 +414,9 @@
71 
72         # default message       
73         if add:
74-            msg = _('The %(name)s "%(obj)s" was added successfully.') % {'name': opts.verbose_name, 'obj': new_obj}
75+            msg = _('The %(name)s "%(obj)s" was added successfully.') % {'name': uncapfirst(opts.verbose_name), 'obj': new_obj}
76         else:
77-            msg = _('The %(name)s "%(obj)s" was changed successfully.') % {'name': opts.verbose_name, 'obj': new_obj}
78+            msg = _('The %(name)s "%(obj)s" was changed successfully.') % {'name': uncapfirst(opts.verbose_name), 'obj': new_obj}
79 
80         # save as new
81         if request.POST.has_key('_saveasnew'):
82@@ -429,7 +429,7 @@
83                 redirect_url = '../../../'
84         # save and add another
85         elif request.POST.has_key('_addanother'):
86-            msg += ' ' + (_('You may add another %s below.') % opts.verbose_name)
87+            msg += ' ' + (_('You may add another %s below.') % uncapfirst(opts.verbose_name))
88             if add:
89                 redirect_url = request.path
90             else:
91@@ -521,7 +521,7 @@
92             inline_admin_formsets.append(inline_admin_formset)
93 
94         c = template.RequestContext(request, {
95-            'title': _('Add %s') % opts.verbose_name,
96+            'title': _('Add %s') % uncapfirst(opts.verbose_name),
97             'adminform': adminForm,
98             'is_popup': request.REQUEST.has_key('_popup'),
99             'media': media,
100@@ -547,7 +547,7 @@
101             raise PermissionDenied
102 
103         if obj is None:
104-            raise Http404('%s object with primary key %r does not exist.' % (opts.verbose_name, escape(object_id)))
105+            raise Http404('%s object with primary key %r does not exist.' % (uncapfirst(opts.verbose_name), escape(object_id)))
106 
107         if request.POST and request.POST.has_key('_saveasnew'):
108             return self.add_view(request)
109@@ -596,7 +596,7 @@
110             inline_admin_formsets.append(inline_admin_formset)
111 
112         c = template.RequestContext(request, {
113-            'title': _('Change %s') % opts.verbose_name,
114+            'title': _('Change %s') % uncapfirst(opts.verbose_name),
115             'adminform': adminForm,
116             'object_id': object_id,
117             'original': obj,
118@@ -654,7 +654,7 @@
119             raise PermissionDenied
120 
121         if obj is None:
122-            raise Http404('%s object with primary key %r does not exist.' % (opts.verbose_name, escape(object_id)))
123+            raise Http404('%s object with primary key %r does not exist.' % (uncapfirst(opts.verbose_name), escape(object_id)))
124 
125         # Populate deleted_objects, a data structure of all related objects that
126         # will also be deleted.
127@@ -668,11 +668,11 @@
128             obj_display = str(obj)
129             obj.delete()
130             LogEntry.objects.log_action(request.user.id, ContentType.objects.get_for_model(self.model).id, object_id, obj_display, DELETION)
131-            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)})
132+            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)})
133             return HttpResponseRedirect("../../")
134         extra_context = {
135             "title": _("Are you sure?"),
136-            "object_name": opts.verbose_name,
137+            "object_name": uncapfirst(opts.verbose_name),
138             "object": obj,
139             "deleted_objects": deleted_objects,
140             "perms_lacking": perms_needed,
141
142=== modified file 'django/contrib/admin/templates/admin/change_form.html'
143--- django/contrib/admin/templates/admin/change_form.html       2007-11-13 02:21:19 +0000
144+++ django/contrib/admin/templates/admin/change_form.html       2007-11-13 02:16:19 +0000
145@@ -18,7 +18,7 @@
146 <div class="breadcrumbs">
147      <a href="../../../">{% trans "Home" %}</a> &rsaquo;
148      <a href="../">{{ opts.verbose_name_plural|capfirst|escape }}</a> &rsaquo;
149-     {% if add %}{% trans "Add" %} {{ opts.verbose_name|escape }}{% else %}{{ original|truncatewords:"18"|escape }}{% endif %}
150+     {% if add %}{% trans "Add" %} {{ opts.verbose_name|uncapfirst|escape }}{% else %}{{ original|truncatewords:"18"|escape }}{% endif %}
151 </div>
152 {% endif %}{% endblock %}
153 
154
155=== modified file 'django/contrib/admin/templates/admin/change_list.html'
156--- django/contrib/admin/templates/admin/change_list.html       2007-11-13 02:21:19 +0000
157+++ django/contrib/admin/templates/admin/change_list.html       2007-11-13 02:16:19 +0000
158@@ -15,7 +15,7 @@
159 <div id="content-main">
160 {% block object-tools %}
161 {% if has_add_permission %}
162-<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>
163+<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>
164 {% endif %}
165 {% endblock %}
166 <div class="module{% if cl.has_filters %} filtered{% endif %}" id="changelist">
167
168=== modified file 'django/contrib/admin/templates/admin/edit_inline/stacked.html'
169--- django/contrib/admin/templates/admin/edit_inline/stacked.html       2007-11-13 02:21:19 +0000
170+++ django/contrib/admin/templates/admin/edit_inline/stacked.html       2007-11-13 02:16:19 +0000
171@@ -5,7 +5,7 @@
172 
173 {% for inline_admin_form in inline_admin_formset %}
174 <div class="inline-related {% if forloop.last %}last-related{% endif %}">
175-  <h2><b>{{ inline_admin_formset.opts.verbose_name|title }}:</b>&nbsp;{% if inline_admin_form.original %}{{ inline_admin_form.original }}{% else %} #{{ forloop.counter }}{% endif %}
176+  <h2><b>{{ inline_admin_formset.opts.verbose_name|capfirst }}:</b>&nbsp;{% if inline_admin_form.original %}{{ inline_admin_form.original }}{% else %} #{{ forloop.counter }}{% endif %}
177     {% if inline_admin_formset.formset.deletable %}<span class="delete">{{ inline_admin_form.deletion_field.field }} {{ inline_admin_form.deletion_field.label_tag }}</span>{% endif %}
178     </h2>
179   {% if inline_admin_form.show_url %}
180
181=== modified file 'django/contrib/admin/templates/admin/pagination.html'
182--- django/contrib/admin/templates/admin/pagination.html        2007-11-13 02:21:19 +0000
183+++ django/contrib/admin/templates/admin/pagination.html        2007-11-13 02:16:19 +0000
184@@ -7,9 +7,9 @@
185 {% endfor %}
186 {% endif %}
187 {% ifequal cl.result_count 1 %}
188-       {% blocktrans with cl.result_count as count and cl.opts.verbose_name|escape as verbose_name %}{{ count }} {{ verbose_name }}{% endblocktrans %}
189+       {% blocktrans with cl.result_count as count and cl.opts.verbose_name|uncapfirst|escape as verbose_name %}{{ count }} {{ verbose_name }}{% endblocktrans %}
190 {% else %}
191-       {% blocktrans with cl.result_count as count and cl.opts.verbose_name_plural|escape as verbose_name_plural %}{{ count }} {{ verbose_name_plural }}{% endblocktrans %}
192+       {% blocktrans with cl.result_count as count and cl.opts.verbose_name_plural|uncapfirst|escape as verbose_name_plural %}{{ count }} {{ verbose_name_plural }}{% endblocktrans %}
193 {% endifequal %}
194 {% if show_all_url %}&nbsp;&nbsp;<a href="{{ show_all_url }}" class="showall">{% trans 'Show all' %}</a>{% endif %}
195 </p>
196
197=== modified file 'django/contrib/admin/templatetags/admin_list.py'
198--- django/contrib/admin/templatetags/admin_list.py     2007-11-13 02:21:19 +0000
199+++ django/contrib/admin/templatetags/admin_list.py     2007-11-13 02:16:19 +0000
200@@ -5,7 +5,7 @@
201 from django.db import models
202 from django.utils import dateformat
203 from django.utils.html import escape
204-from django.utils.text import capfirst
205+from django.utils.text import capfirst, uncapfirst
206 from django.utils.translation import get_date_formats, get_partial_date_formats, ugettext as _
207 from django.utils.encoding import smart_unicode, smart_str, force_unicode
208 from django.template import Library
209@@ -79,9 +79,9 @@
210             # attribute "short_description". If that doesn't exist, fall back
211             # to the method name. And __str__ and __unicode__ are special-cases.
212             if field_name == '__unicode__':
213-                header = force_unicode(lookup_opts.verbose_name)
214+                header = force_unicode(uncapfirst(lookup_opts.verbose_name))
215             elif field_name == '__str__':
216-                header = smart_str(lookup_opts.verbose_name)
217+                header = smart_str(uncapfirst(lookup_opts.verbose_name))
218             else:
219                 attr = getattr(cl.model, field_name) # Let AttributeErrors propagate.
220                 try:
221@@ -99,10 +99,11 @@
222             # after the else clause.
223         else:
224             if isinstance(f.rel, models.ManyToOneRel) and f.null:
225-                yield {"text": f.verbose_name}
226+                yield {"text": uncapfirst(f.verbose_name)}
227                 continue
228             else:
229-                header = f.verbose_name
230+                header = uncapfirst(f.verbose_name)
231+
232 
233         th_classes = []
234         new_order_type = 'asc'
235
236=== modified file 'django/contrib/admin/util.py'
237--- django/contrib/admin/util.py        2007-11-13 02:21:19 +0000
238+++ django/contrib/admin/util.py        2007-11-13 02:16:19 +0000
239@@ -1,7 +1,7 @@
240 from django.core.exceptions import ObjectDoesNotExist
241 from django.db import models
242 from django.utils.html import escape
243-from django.utils.text import capfirst
244+from django.utils.text import capfirst, uncapfirst
245 from django.utils.encoding import force_unicode
246 
247 def _nest_help(obj, depth, val):
248@@ -83,11 +83,11 @@
249                     # Don't display link to edit, because it either has no
250                     # admin or is edited inline.
251                     nh(deleted_objects, current_depth, [_('One or more %(fieldname)s in %(name)s: %(obj)s') % \
252-                        {'fieldname': force_unicode(related.field.verbose_name), 'name': force_unicode(related.opts.verbose_name), 'obj': escape(sub_obj)}, []])
253+                        {'fieldname': force_unicode(uncapfirst(related.field.verbose_name)), 'name': force_unicode(uncapfirst(related.opts.verbose_name)), 'obj': escape(sub_obj)}, []])
254                 else:
255                     # Display a link to the admin page.
256                     nh(deleted_objects, current_depth, [
257-                        (_('One or more %(fieldname)s in %(name)s:') % {'fieldname': force_unicode(related.field.verbose_name), 'name': force_unicode(related.opts.verbose_name)}) + \
258+                        (_('One or more %(fieldname)s in %(name)s:') % {'fieldname': force_unicode(uncapfirst(related.field.verbose_name)), 'name': force_unicode(uncapfirst(related.opts.verbose_name))}) + \
259                         (u' <a href="../../../../%s/%s/%s/">%s</a>' % \
260                             (related.opts.app_label, related.opts.module_name, sub_obj._get_pk_val(), escape(sub_obj))), []])
261         # If there were related objects, and the user doesn't have
262
263=== modified file 'django/contrib/admin/views/main.py'
264--- django/contrib/admin/views/main.py  2007-11-13 02:21:19 +0000
265+++ django/contrib/admin/views/main.py  2007-11-13 02:16:19 +0000
266@@ -9,6 +9,7 @@
267 from django.db.models.query import handle_legacy_orderlist, QuerySet
268 from django.http import Http404
269 from django.utils.encoding import force_unicode, smart_str
270+from django.utils.text import uncapfirst
271 from django.utils.translation import ugettext
272 import operator
273 
274@@ -146,7 +147,7 @@
275         self.query = request.GET.get(SEARCH_VAR, '')
276         self.query_set = self.get_query_set()
277         self.get_results(request)
278-        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))
279+        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)))
280         self.filter_specs, self.has_filters = self.get_filters(request)
281         self.pk_attname = self.lookup_opts.pk.attname
282 
283