Ticket #195: date_based_callable_context.patch
File date_based_callable_context.patch, 2.2 KB (added by , 19 years ago) |
---|
-
date_based.py
41 41 'date_list' : date_list, 42 42 'latest' : latest, 43 43 }) 44 if extra_context: 45 c.update(extra_context) 44 if extra_context: 45 for key, value in extra_context.items(): 46 if callable(value): 47 c[key] = value() 48 else: 49 c[key] = value 46 50 return HttpResponse(t.render(c)) 47 51 48 52 def archive_year(request, year, app_label, module_name, date_field, … … 75 79 'year': year, 76 80 }) 77 81 if extra_context: 78 c.update(extra_context) 82 for key, value in extra_context.items(): 83 if callable(value): 84 c[key] = value() 85 else: 86 c[key] = value 79 87 return HttpResponse(t.render(c)) 80 88 81 89 def archive_month(request, year, month, app_label, module_name, date_field, … … 122 130 'month': date, 123 131 }) 124 132 if extra_context: 125 c.update(extra_context) 133 for key, value in extra_context.items(): 134 if callable(value): 135 c[key] = value() 136 else: 137 c[key] = value 126 138 return HttpResponse(t.render(c)) 127 139 128 140 def archive_day(request, year, month, day, app_label, module_name, date_field, … … 168 180 'next_day': (date < datetime.date.today()) and (date + datetime.timedelta(days=1)) or None, 169 181 }) 170 182 if extra_context: 171 c.update(extra_context) 183 for key, value in extra_context.items(): 184 if callable(value): 185 c[key] = value() 186 else: 187 c[key] = value 172 188 return HttpResponse(t.render(c)) 173 189 174 190 def archive_today(request, **kwargs): … … 228 244 'object': object, 229 245 }) 230 246 if extra_context: 231 c.update(extra_context) 247 for key, value in extra_context.items(): 248 if callable(value): 249 c[key] = value() 250 else: 251 c[key] = value 232 252 response = HttpResponse(t.render(c)) 233 253 populate_xheaders(request, response, app_label, module_name, getattr(object, object._meta.pk.name)) 234 254 return response