Ticket #4125: databrowse_fixes.4.patch
File databrowse_fixes.4.patch, 14.2 KB (added by , 17 years ago) |
---|
-
django/contrib/databrowse/datastructures.py
7 7 from django.utils import dateformat 8 8 from django.utils.text import capfirst 9 9 from django.utils.translation import get_date_formats 10 from django.db.models.query import QuerySet 10 11 11 12 EMPTY_VALUE = '(None)' 12 13 … … 29 30 return '%s%s/%s/' % (self.site.root_url, self.model._meta.app_label, self.model._meta.module_name) 30 31 31 32 def objects(self, **kwargs): 32 for obj in self.model._default_manager.filter(**kwargs): 33 yield EasyInstance(self, obj) 33 return self.get_query_set().filter(**kwargs) 34 34 35 def get_query_set(self): 36 easy_qs = self.model._default_manager.get_query_set()._clone(klass=EasyQuerySet) 37 easy_qs._easymodel = self 38 return easy_qs 39 35 40 def object_by_pk(self, pk): 36 41 return EasyInstance(self, self.model._default_manager.get(pk=pk)) 37 42 … … 190 195 else: 191 196 lst = [(self.values()[0], None)] 192 197 return lst 198 199 class EasyQuerySet(QuerySet): 200 """ 201 When creating (or cloning to) an `EasyQuerySet`, make sure to set the 202 `_easymodel` variable to the related `EasyModel`. 203 """ 204 def iterator(self, *args, **kwargs): 205 for obj in super(EasyQuerySet, self).iterator(*args, **kwargs): 206 yield EasyInstance(self._easymodel, obj) 207 208 def _clone(self, *args, **kwargs): 209 c = super(EasyQuerySet, self)._clone(*args, **kwargs) 210 c._easymodel = self._easymodel 211 return c -
django/contrib/databrowse/plugins/calendars.py
63 63 64 64 def calendar_view(self, request, field, year=None, month=None, day=None): 65 65 easy_model = EasyModel(self.site, self.model) 66 queryset = easy_model.get_query_set() 66 67 extra_context = {'root_url': self.site.root_url, 'model': easy_model, 'field': field} 67 68 if day is not None: 68 # TODO: The objects in this template should be EasyInstances 69 return date_based.archive_day(request, year, month, day, self.model.objects.all(), field.name, 69 return date_based.archive_day(request, year, month, day, queryset, field.name, 70 70 template_name='databrowse/calendar_day.html', allow_empty=False, allow_future=True, 71 71 extra_context=extra_context) 72 72 elif month is not None: 73 return date_based.archive_month(request, year, month, self.model.objects.all(), field.name,73 return date_based.archive_month(request, year, month, queryset, field.name, 74 74 template_name='databrowse/calendar_month.html', allow_empty=False, allow_future=True, 75 75 extra_context=extra_context) 76 76 elif year is not None: 77 return date_based.archive_year(request, year, self.model.objects.all(), field.name,77 return date_based.archive_year(request, year, queryset, field.name, 78 78 template_name='databrowse/calendar_year.html', allow_empty=False, allow_future=True, 79 79 extra_context=extra_context) 80 80 else: 81 return date_based.archive_index(request, self.model.objects.all(), field.name,81 return date_based.archive_index(request, queryset, field.name, 82 82 template_name='databrowse/calendar_main.html', allow_empty=True, allow_future=True, 83 83 extra_context=extra_context) 84 84 assert False, ('%s, %s, %s, %s' % (field, year, month, day)) -
django/contrib/databrowse/templates/databrowse/base.html
2 2 <html xmlns="http://www.w3.org/1999/xhtml" lang="{{ LANGUAGE_CODE }}" xml:lang="{{ LANGUAGE_CODE }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif %}> 3 3 <head> 4 4 <title>{% block title %}{% endblock %}</title> 5 {% block style %} 5 6 <style type="text/css"> 6 7 * { margin:0; padding:0; } 7 8 body { background:#eee; color:#333; font:76%/1.6 "Lucida Grande","Bitstream Vera Sans",Verdana,sans-serif; } … … 48 49 /* CONTENT */ 49 50 #content { background:#fff; border-bottom:1px solid #ddd; padding:0 20px; } 50 51 </style> 52 {% endblock %} 53 {% block extrahead %}{% endblock %} 51 54 </head> 52 55 <body id="{% block bodyid %}page{% endblock %}"> 53 <div id="header"><a href="{{ root_url }}"> Databrowse</a></div>56 <div id="header"><a href="{{ root_url }}">{% block databrowse_title %}Databrowse{% endblock %}</a></div> 54 57 <div id="content"> 55 58 {% block content %}{% endblock %} 56 59 </div> -
django/contrib/databrowse/templates/databrowse/base_site.html
1 {% extends "databrowse/base.html" %} -
django/contrib/databrowse/templates/databrowse/calendar_day.html
1 {% extends "databrowse/base .html" %}1 {% extends "databrowse/base_site.html" %} 2 2 3 3 {% block title %}{{ model.verbose_name_plural|capfirst }} with {{ field.verbose_name }} {{ day|date:"F j, Y" }}{% endblock %} 4 4 … … 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="../../">{{ day.year }}</a> / <a href="../">{{ day|date:"F" }}</a> / {{ day.day }}</div> 8 8 9 <h1>{{ model.verbose_name_plural|capfirst }} with {{ field.verbose_name }} on {{ day|date:"F j, 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 {{ day|date:"F j, Y" }}</h1> 10 10 11 11 <ul class="objectlist"> 12 12 {% for object in object_list %} 13 <li class="{% cycle odd,even %}"><a href="{{ object.url }}">{{ object }}</a></li>13 <li class="{% cycle odd,even %}"><a href="{{ object.url }}">{{ object|escape }}</a></li> 14 14 {% endfor %} 15 15 </ul> 16 16 -
django/contrib/databrowse/templates/databrowse/calendar_homepage.html
1 {% extends "databrowse/base .html" %}1 {% extends "databrowse/base_site.html" %} 2 2 3 3 {% block title %}Calendars{% endblock %} 4 4 -
django/contrib/databrowse/templates/databrowse/calendar_main.html
1 {% extends "databrowse/base .html" %}1 {% extends "databrowse/base_site.html" %} 2 2 3 3 {% block title %}{{ field.verbose_name|capfirst }} calendar{% endblock %} 4 4 -
django/contrib/databrowse/templates/databrowse/calendar_month.html
1 {% extends "databrowse/base .html" %}1 {% extends "databrowse/base_site.html" %} 2 2 3 3 {% block title %}{{ model.verbose_name_plural|capfirst }} with {{ field.verbose_name }} in {{ month|date:"F Y" }}{% endblock %} 4 4 … … 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>{{ model.verbose_name_plural|capfirst }} with {{ field.verbose_name }} in {{ month|date:"F Y" }}</h1>9 <h1>{{ object_list.count }} {% if object_list.count|pluralize %}{{ model.verbose_name_plural }}{% else %}{{ model.verbose_name }}{% endif %} with {{ field.verbose_name }} in {{ month|date:"F Y" }}</h1> 10 10 11 11 <ul class="objectlist"> 12 12 {% for object in object_list %} 13 <li class="{% cycle odd,even %}"><a href="{{ object.url }}">{{ object }}</a></li>13 <li class="{% cycle odd,even %}"><a href="{{ object.url }}">{{ object|escape }}</a></li> 14 14 {% endfor %} 15 15 </ul> 16 16 -
django/contrib/databrowse/templates/databrowse/calendar_year.html
1 {% extends "databrowse/base .html" %}1 {% extends "databrowse/base_site.html" %} 2 2 3 3 {% block title %}{{ model.verbose_name_plural|capfirst }} with {{ field.verbose_name }} in {{ year }}{% endblock %} 4 4 -
django/contrib/databrowse/templates/databrowse/choice_detail.html
1 {% extends "databrowse/base .html" %}1 {% extends "databrowse/base_site.html" %} 2 2 3 3 {% block title %}{{ model.verbose_name_plural|capfirst }} by {{ field.field.verbose_name }}: {{ value|escape }}{% endblock %} 4 4 -
django/contrib/databrowse/templates/databrowse/choice_list.html
1 {% extends "databrowse/base .html" %}1 {% extends "databrowse/base_site.html" %} 2 2 3 3 {% block title %}{{ model.verbose_name_plural|capfirst }} by {{ field.field.verbose_name }}{% endblock %} 4 4 -
django/contrib/databrowse/templates/databrowse/fieldchoice_detail.html
1 {% extends "databrowse/base .html" %}1 {% extends "databrowse/base_site.html" %} 2 2 3 3 {% block title %}{{ model.verbose_name_plural|capfirst|escape }} with {{ field.field.verbose_name|escape }} {{ value|escape }}{% endblock %} 4 4 … … 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="../../">Fields</a> / <a href="../">By {{ field.field.verbose_name|escape }}</a> / {{ value|escape }}</div> 8 8 9 <h1>{{ model.verbose_name_plural|capfirst|escape }} with {{ field.field.verbose_name|escape }} {{ value|escape }}</h1>9 <h1>{{ object_list.count }} {% if object_list.count|pluralize %}{{ model.verbose_name_plural|escape }}{% else %}{{ model.verbose_name|escape }}{% endif %} with {{ field.field.verbose_name|escape }} {{ value|escape }}</h1> 10 10 11 11 <ul class="objectlist"> 12 12 {% for object in object_list %} -
django/contrib/databrowse/templates/databrowse/fieldchoice_homepage.html
1 {% extends "databrowse/base .html" %}1 {% extends "databrowse/base_site.html" %} 2 2 3 3 {% block title %}Browsable fields in {{ model.verbose_name_plural|escape }}{% endblock %} 4 4 -
django/contrib/databrowse/templates/databrowse/fieldchoice_list.html
1 {% extends "databrowse/base .html" %}1 {% extends "databrowse/base_site.html" %} 2 2 3 3 {% block title %}{{ model.verbose_name_plural|capfirst|escape }} by {{ field.field.verbose_name|escape }}{% endblock %} 4 4 -
django/contrib/databrowse/templates/databrowse/homepage.html
1 {% extends "databrowse/base .html" %}1 {% extends "databrowse/base_site.html" %} 2 2 3 3 {% block title %}Databrowse{% endblock %} 4 4 -
django/contrib/databrowse/templates/databrowse/model_detail.html
1 {% extends "databrowse/base .html" %}1 {% extends "databrowse/base_site.html" %} 2 2 3 3 {% block title %}{{ model.verbose_name_plural|capfirst }}{% endblock %} 4 4 -
django/contrib/databrowse/templates/databrowse/object_detail.html
1 {% extends "databrowse/base .html" %}1 {% extends "databrowse/base_site.html" %} 2 2 3 3 {% block title %}{{ object.model.verbose_name|capfirst }}: {{ object }}{% endblock %} 4 4