diff -ruN dj-date-formats/django/contrib/admin/templatetags/admin_list.py dj-date-hierarchy-i18n/django/contrib/admin/templatetags/admin_list.py
|
old
|
new
|
|
| 8 | 8 | from django.utils import dateformat |
| 9 | 9 | from django.utils.html import escape |
| 10 | 10 | from django.utils.text import capfirst |
| 11 | | from django.utils.translation import get_date_formats |
| | 11 | from django.utils.translation import get_date_formats, get_partial_date_formats |
| 12 | 12 | from django.template import Library |
| | 13 | from datetime import MINYEAR, date |
| 13 | 14 | |
| 14 | 15 | register = Library() |
| 15 | 16 | |
| … |
… |
|
| 193 | 194 | year_lookup = cl.params.get(year_field) |
| 194 | 195 | month_lookup = cl.params.get(month_field) |
| 195 | 196 | day_lookup = cl.params.get(day_field) |
| | 197 | (year_month_format, month_day_format) = get_partial_date_formats() |
| 196 | 198 | |
| 197 | 199 | link = lambda d: cl.get_query_string(d, [field_generic]) |
| 198 | 200 | |
| 199 | 201 | if year_lookup and month_lookup and day_lookup: |
| 200 | | month_name = MONTHS[int(month_lookup)] |
| | 202 | day = date(int(year_lookup), int(month_lookup), int(day_lookup)) |
| 201 | 203 | return { |
| 202 | 204 | 'show': True, |
| 203 | 205 | 'back': { |
| 204 | 206 | 'link': link({year_field: year_lookup, month_field: month_lookup}), |
| 205 | | 'title': "%s %s" % (month_name, year_lookup) |
| | 207 | 'title': dateformat.format(day, year_month_format) |
| 206 | 208 | }, |
| 207 | | 'choices': [{'title': "%s %s" % (month_name, day_lookup)}] |
| | 209 | 'choices': [{'title': dateformat.format(day, month_day_format)}] |
| 208 | 210 | } |
| 209 | 211 | elif year_lookup and month_lookup: |
| 210 | 212 | days = cl.query_set.filter(**{year_field: year_lookup, month_field: month_lookup}).dates(field_name, 'day') |
| … |
… |
|
| 216 | 218 | }, |
| 217 | 219 | 'choices': [{ |
| 218 | 220 | 'link': link({year_field: year_lookup, month_field: month_lookup, day_field: day.day}), |
| 219 | | 'title': day.strftime('%B %d') |
| | 221 | 'title': dateformat.format(day, month_day_format) |
| 220 | 222 | } for day in days] |
| 221 | 223 | } |
| 222 | 224 | elif year_lookup: |
| … |
… |
|
| 229 | 231 | }, |
| 230 | 232 | 'choices': [{ |
| 231 | 233 | 'link': link({year_field: year_lookup, month_field: month.month}), |
| 232 | | 'title': "%s %s" % (month.strftime('%B'), month.year) |
| | 234 | 'title': dateformat.format(month, year_month_format) |
| 233 | 235 | } for month in months] |
| 234 | 236 | } |
| 235 | 237 | else: |