Ticket #6037: month_detail.diff
File month_detail.diff, 4.8 KB (added by , 17 years ago) |
---|
-
django/views/generic/date_based.py
123 123 model = queryset.model 124 124 now = datetime.datetime.now() 125 125 126 lookup_kwargs = {'%s__month' % date_field: date.month} 127 date_list = queryset.filter(**lookup_kwargs).dates(date_field, 'day') 126 128 # Calculate first and last day of month, for use in a date-range lookup. 127 129 first_day = date.replace(day=1) 128 130 if first_day.month == 12: … … 150 152 template_name = "%s/%s_archive_month.html" % (model._meta.app_label, model._meta.object_name.lower()) 151 153 t = template_loader.get_template(template_name) 152 154 c = RequestContext(request, { 155 'date_list': date_list, 153 156 '%s_list' % template_object_name: object_list, 154 157 'month': date, 155 158 'next_month': next_month, -
django/contrib/databrowse/templates/databrowse/calendar_month.html
6 6 7 7 <div id="breadcrumbs"><a href="{{ root_url }}">Home</a> / <a href="{{ model.url }}">{{ model.verbose_name_plural|capfirst }}</a> / <a href="../../../">Calendars</a> / <a href="../../">By {{ field.verbose_name }}</a> / <a href="../">{{ month.year }}</a> / {{ month|date:"F" }}</div> 8 8 9 <h1>{{ object_list.count }} {% if object_list.count|pluralize %}{{ model.verbose_name_plural|escape }}{% else %}{{ model.verbose_name|escape }}{% endif %} with {{ field.verbose_name }} on {{ day|date:"F Y" }}</h1>9 <h1>{{ object_list.count }} {% if object_list.count|pluralize %}{{ model.verbose_name_plural|escape }}{% else %}{{ model.verbose_name|escape }}{% endif %} with {{ field.verbose_name }} on {{ month|date:"F Y" }}</h1> 10 10 11 11 <ul class="objectlist"> 12 {% for object in object_list %}13 <li class="{% cycle 'odd' 'even' %}"><a href="{{ object.url }}">{{ object|escape }}</a></li>12 {% for day in date_list %} 13 <li class="{% cycle 'odd' 'even' %}"><a href="{{ day|date:"d"|lower }}/">{{ day|date }}</a></li> 14 14 {% endfor %} 15 15 </ul> 16 16 -
tests/regressiontests/views/tests/generic/date_based.py
67 67 article.save() 68 68 response = self.client.get('/views/date_based/archive_month/2004/02/') 69 69 self.assertEqual(response.status_code, 404) 70 71 72 No newline at end of file 70 71 class DayArchiveTest(TestCase): 72 def test_archive_month_contains_day(self): 73 author = Author(name="Petryk Pyatochkin") 74 author.save() 75 76 article = Article(title="example", author=author) 77 article.date_created = datetime(2007, 11, 27, 0, 0, 1) 78 article.save() 79 80 response = self.client.get('/views/date_based/archive_month/2007/11/') 81 self.assertEqual(response.status_code, 200) 82 83 response = self.client.get('/views/date_based/archive_month/2007/12/') 84 self.assertEqual(response.status_code, 404) 85 86 def test_if_day_available(self): 87 author = Author(name="Mykola Salo") 88 author.save() 89 90 article = Article(title="example", author=author) 91 article.date_created = datetime(2007, 11, 27, 0, 0, 1) 92 article.save() 93 94 response = self.client.get('/views/date_based/archive_day/2007/11/27/') 95 self.assertEqual(response.status_code, 200) 96 97 response = self.client.get('/views/date_based/archive_day/2007/11/28/') 98 self.assertEqual(response.status_code, 404) -
tests/regressiontests/views/urls.py
35 35 # Static views 36 36 (r'^site_media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': media_dir}), 37 37 38 38 # Date-based generic views 39 39 (r'^date_based/object_detail/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/(?P<slug>[-\w]+)/$', 40 40 'django.views.generic.date_based.object_detail', 41 41 dict(slug_field='slug', **date_based_info_dict)), … … 45 45 (r'^date_based/archive_month/(?P<year>\d{4})/(?P<month>\d{1,2})/$', 46 46 'django.views.generic.date_based.archive_month', 47 47 date_based_info_dict), 48 (r'^date_based/archive_day/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/$', 49 'django.views.generic.date_based.archive_day', 50 date_based_info_dict), 48 51 )