Ticket #3152: number_per_page.diff
File number_per_page.diff, 16.6 KB (added by , 18 years ago) |
---|
-
django/conf/global_settings.py
205 205 206 206 # Default formatting for date objects. See all available format strings here: 207 207 # http://www.djangoproject.com/documentation/templates/#now 208 DATE_FORMAT = 'N j, Y' 208 #DATE_FORMAT = 'N j, Y' 209 DATE_FORMAT = 'j/m/y' 209 210 210 211 # Default formatting for datetime objects. See all available format strings here: 211 212 # http://www.djangoproject.com/documentation/templates/#now 212 DATETIME_FORMAT = 'N j, Y, P' 213 #DATETIME_FORMAT = 'N j, Y, P' 214 DATETIME_FORMAT = 'j/m/y H:i' 213 215 214 216 # Default formatting for time objects. See all available format strings here: 215 217 # http://www.djangoproject.com/documentation/templates/#now 216 TIME_FORMAT = 'P' 218 #TIME_FORMAT = 'P' 219 TIME_FORMAT = 'H:i' 217 220 218 221 # Default formatting for date objects when only the year and month are relevant. 219 222 # See all available format strings here: -
django/utils/translation/trans_real.py
359 359 one, the formats provided in the settings will be used. 360 360 """ 361 361 from django.conf import settings 362 print settings.DATETIME_FORMAT 362 363 date_format = _('DATE_FORMAT') 364 print date_format 363 365 datetime_format = _('DATETIME_FORMAT') 364 366 time_format = _('TIME_FORMAT') 365 367 if date_format == 'DATE_FORMAT': … … 368 370 datetime_format = settings.DATETIME_FORMAT 369 371 if time_format == 'TIME_FORMAT': 370 372 time_format = settings.TIME_FORMAT 371 return date_format, datetime_format, time_format 373 #HORRIBLE HACK!!!: 374 return settings.DATE_FORMAT, settings.DATETIME_FORMAT, settings.TIME_FORMAT 375 #return date_format, datetime_format, time_format 372 376 373 377 def get_partial_date_formats(): 374 378 """ -
django/contrib/admin/media/css/changelists.css
48 48 .paginator .end { border-width:2px !important; margin-right:6px; } 49 49 .paginator .this-page { padding:2px 6px; font-weight:bold; font-size:13px; vertical-align:top; } 50 50 .paginator a:hover { color:white; background:#5b80b2; border-color:#036; } 51 .paginator span#page_no { float:left; width: 60%; } 52 .paginator form { float:right; padding-right: 1em; } 53 -
django/contrib/admin/templatetags/admin_list.py
56 56 page_range.extend(range(page_num + 1, paginator.pages)) 57 57 58 58 need_show_all_link = cl.can_show_all and not cl.show_all and cl.multi_page 59 #Some extra logic to allow choosing the number per page 60 MIN = 20 61 MAX = 250 62 STEP = 10 59 63 return { 60 64 'cl': cl, 61 65 'pagination_required': pagination_required, 62 66 'show_all_url': need_show_all_link and cl.get_query_string({ALL_VAR: ''}), 63 67 'page_range': page_range, 68 'num_choices': range(MIN, MAX+STEP, STEP), 64 69 'ALL_VAR': ALL_VAR, 65 70 '1': 1, 66 71 } … … 87 92 # Non-field list_display values don't get ordering capability. 88 93 yield {"text": header} 89 94 else: 90 if isinstance(f.rel, models.ManyToOneRel) and f.null:91 yield {"text": f.verbose_name}92 else:93 94 95 96 97 95 #if isinstance(f.rel, models.ManyToOneRel) and f.null: 96 # yield {"text": f.verbose_name} 97 #else: 98 th_classes = [] 99 new_order_type = 'asc' 100 if field_name == cl.order_field: 101 th_classes.append('sorted %sending' % cl.order_type.lower()) 102 new_order_type = {'asc': 'desc', 'desc': 'asc'}[cl.order_type.lower()] 98 103 99 100 101 102 104 yield {"text": f.verbose_name, 105 "sortable": True, 106 "url": cl.get_query_string({ORDER_VAR: i, ORDER_TYPE_VAR: new_order_type}), 107 "class_attrib": (th_classes and ' class="%s"' % ' '.join(th_classes) or '')} 103 108 104 109 def items_for_result(cl, result): 105 110 first = True -
django/contrib/admin/views/main.py
30 30 ORDER_VAR = 'o' 31 31 ORDER_TYPE_VAR = 'ot' 32 32 PAGE_VAR = 'p' 33 NPP = 'npp' 33 34 SEARCH_VAR = 'q' 34 35 IS_POPUP_VAR = 'pop' 35 36 ERROR_FLAG = 'e' … … 550 551 self.lookup_opts = self.opts 551 552 self.manager = self.opts.admin.manager 552 553 554 #Number on page from query string 555 self.show_per_page = int(request.GET.get(NPP, self.opts.admin.list_per_page)) 556 553 557 # Get search parameters from the query string. 554 558 try: 555 559 self.page_num = int(request.GET.get(PAGE_VAR, 0)) … … 573 577 574 578 def get_filters(self, request): 575 579 filter_specs = [] 576 if self.lookup_opts.admin.list_filter and not self.opts.one_to_one_field:580 if self.lookup_opts.admin.list_filter: 577 581 filter_fields = [self.lookup_opts.get_field(field_name) \ 578 582 for field_name in self.lookup_opts.admin.list_filter] 579 583 for f in filter_fields: … … 598 602 return '?' + '&'.join(['%s=%s' % (k, v) for k, v in p.items()]).replace(' ', '%20') 599 603 600 604 def get_results(self, request): 601 paginator = ObjectPaginator(self.query_set, self. lookup_opts.admin.list_per_page)605 paginator = ObjectPaginator(self.query_set, self.show_per_page) 602 606 603 607 # Get the number of objects, with admin filters applied. 604 608 try: … … 620 624 full_result_count = self.manager.count() 621 625 622 626 can_show_all = result_count <= MAX_SHOW_ALL_ALLOWED 623 multi_page = result_count > self. lookup_opts.admin.list_per_page627 multi_page = result_count > self.show_per_page 624 628 625 629 # Get the list of objects to display on this page. 626 630 if (self.show_all and can_show_all) or not multi_page: … … 671 675 def get_query_set(self): 672 676 qs = self.manager.get_query_set() 673 677 lookup_params = self.params.copy() # a dictionary of the query string 674 for i in (ALL_VAR, ORDER_VAR, ORDER_TYPE_VAR, SEARCH_VAR, IS_POPUP_VAR ):678 for i in (ALL_VAR, ORDER_VAR, ORDER_TYPE_VAR, SEARCH_VAR, IS_POPUP_VAR, NPP): 675 679 if lookup_params.has_key(i): 676 680 del lookup_params[i] 677 681 … … 706 710 # For OneToOneFields, don't try to order by the related object's ordering criteria. 707 711 pass 708 712 elif isinstance(f.rel, models.ManyToOneRel): 709 rel_ordering = f.rel.to._meta.ordering and f.rel.to._meta.ordering[0] or f.rel.to._meta.pk.column 713 #Get round admin breaking with ordering on the related model being '-*' 714 if f.rel.to._meta.ordering: 715 o_field = f.rel.to._meta.ordering[0] 716 if o_field[0] == '-': 717 self.order_type = 'desc' 718 o_field = o_field[1:] 719 rel_ordering = f.rel.to._meta.ordering and o_field or f.rel.to._meta.pk.column 710 720 lookup_order_field = '%s.%s' % (f.rel.to._meta.db_table, rel_ordering) 711 721 712 722 # Set ordering. -
django/contrib/admin/templates/admin/change_list.html
1 1 {% extends "admin/base_site.html" %} 2 2 {% load adminmedia admin_list i18n %} 3 {% block stylesheet %} {% admin_media_prefix %}css/changelists.css{% endblock %}3 {% block stylesheet %}/media/css/changelists.css{% endblock %} 4 4 {% block bodyclass %}change-list{% endblock %} 5 5 {% block userlinks %}<a href="../../doc/">{% trans 'Documentation' %}</a> / <a href="../../password_change/">{% trans 'Change password' %}</a> / <a href="../../logout/">{% trans 'Log out' %}</a>{% endblock %} 6 {% if not is_popup %}{% block breadcrumbs %}<div class="breadcrumbs"><a href="../../">{% trans "Home" %}</a> › {{ cl.opts.verbose_name_plural|capfirst|escape }}</div>{% endblock %}{% endif %} 6 {% block breadcrumbs %} 7 {{ block.super }} › <li class='crumb'> {{ cl.opts.verbose_name_plural|capfirst|escape }} </li> 8 {% endblock %} 7 9 {% block coltype %}flex{% endblock %} 8 10 {% block content %} 9 11 <div id="content-main"> … … 12 14 {% endif %} 13 15 <div class="module{% if cl.has_filters %} filtered{% endif %}" id="changelist"> 14 16 {% block search %}{% search_form cl %}{% endblock %} 17 {% block pagination %}{% pagination cl %}{% endblock %} 15 18 {% block date_hierarchy %}{% date_hierarchy cl %}{% endblock %} 16 19 {% block filters %}{% filters cl %}{% endblock %} 17 20 {% block result_list %}{% result_list cl %}{% endblock %} 18 {% block pagination %}{% pagination cl %}{% endblock %}19 21 </div> 20 22 </div> 21 23 {% endblock %} -
django/contrib/admin/templates/admin/pagination.html
1 1 {% load admin_list %} 2 2 {% load i18n %} 3 3 <p class="paginator"> 4 <span id='page_no'> 4 5 {% if pagination_required %} 6 Page 5 7 {% for i in page_range %} 6 8 {% paginator_number cl i %} 7 9 {% endfor %} 8 10 {% endif %} 9 11 {{ cl.result_count }} {% ifequal cl.result_count 1 %}{{ cl.opts.verbose_name|escape }}{% else %}{{ cl.opts.verbose_name_plural|escape }}{% endifequal %} 10 12 {% if show_all_url %} <a href="{{ show_all_url }}" class="showall">{% trans 'Show all' %}</a>{% endif %} 13 </span> 14 <span id='npp'> 15 <form method='GET' action='.'> 16 <label for='npp'>Number Per Page</label> 17 <select name='npp'> 18 {% for c in num_choices %} 19 <option {% ifequal cl.show_per_page c %}selected{% endifequal %} id='{{ c }}'>{{ c }}</option> 20 {% endfor %} 21 </select> 22 <input type='submit' value='Change'/> 23 </form> 24 </span> 11 25 </p> -
django/contrib/admin/templates/admin/edit_inline_tabular.html
7 7 <th{{ fw.header_class_attribute }}>{{ fw.field.verbose_name|capfirst|escape }}</th> 8 8 {% endif %} 9 9 {% endfor %} 10 </tr></thead>11 10 {% for fcw in bound_related_object.form_field_collection_wrappers %} 12 11 {% if change %}{% if original_row_needed %} 13 12 {% if fcw.obj.original %} -
django/contrib/admin/templates/admin/base_site.html
1 {% extends " admin/base.html" %}1 {% extends "base.html" %} 2 2 {% load i18n %} 3 {% block breadcrumbs %} 4 {{ block.super }} ›<a href='/admin/'> {% trans 'Admin' %} </a> 5 {% endblock %} 6 {% block admin_active %}active{% endblock %} 3 7 4 8 {% block title %}{{ title|escape }} | {% trans 'Django site admin' %}{% endblock %} 5 9 6 {% block branding%}7 <h1 id="site- name">{% trans 'Django administration' %}</h1>10 {% block site_title %} 11 <h1 id="site-title">{% trans 'NMS Trouble Ticket Admin' %}</h1> 8 12 {% endblock %} 9 13 10 {% block nav-global %}{% endblock %} -
django/contrib/admin/templates/admin/index.html
1 1 {% extends "admin/base_site.html" %} 2 2 {% load i18n %} 3 4 {% block stylesheet %} {% load adminmedia %}{% admin_media_prefix %}css/dashboard.css{% endblock %}3 {% load adminmedia %} 4 {% block stylesheet %}/media/css/dashboard.css{% endblock %} 5 5 {% block coltype %}colMS{% endblock %} 6 6 {% block bodyclass %}dashboard{% endblock %} 7 {% block breadcrumbs %}{% endblock %}8 7 {% block content %} 9 8 <div id="content-main"> 10 9 -
django/contrib/admin/templates/admin/change_form.html
4 4 <script type="text/javascript" src="../../../jsi18n/"></script> 5 5 {% for js in javascript_imports %}{% include_admin_script js %}{% endfor %} 6 6 {% endblock %} 7 {% block stylesheet %} {% admin_media_prefix %}css/forms.css{% endblock %}7 {% block stylesheet %}/media/css/forms.css{% endblock %} 8 8 {% block coltype %}{% if ordered_objects %}colMS{% else %}colM{% endif %}{% endblock %} 9 9 {% block bodyclass %}{{ opts.app_label }}-{{ opts.object_name.lower }} change-form{% endblock %} 10 10 {% block userlinks %}<a href="../../../doc/">{% trans 'Documentation' %}</a> / <a href="../../../password_change/">{% trans 'Change password' %}</a> / <a href="../../../logout/">{% trans 'Log out' %}</a>{% endblock %} 11 {% block breadcrumbs %}{% if not is_popup %} 12 <div class="breadcrumbs"> 13 <a href="../../../">{% trans "Home" %}</a> › 14 <a href="../">{{ opts.verbose_name_plural|capfirst|escape }}</a> › 15 {% if add %}{% trans "Add" %} {{ opts.verbose_name|escape }}{% else %}{{ original|truncatewords:"18"|escape }}{% endif %} 11 {% block breadcrumbs %} 12 {{ block.super }} 13 ›<a href="../"> {{ opts.verbose_name_plural|capfirst|escape }} </a> › 14 {% if add %}{% trans "Add" %} {{ opts.verbose_name|escape }}{% else %}{{ original|truncatewords:"18"|escape }} 16 15 </div> 17 16 {% endif %}{% endblock %} 18 17 {% block content %}<div id="content-main"> … … 21 20 {% if has_absolute_url %}<li><a href="../../../r/{{ content_type_id }}/{{ object_id }}/" class="viewsitelink">{% trans "View on site" %}</a></li>{% endif%} 22 21 </ul> 23 22 {% endif %}{% endif %} 24 <form {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="{{ form_url }}" method="post" id="{{ opts.module_name }}_form">{% block form_top %}{% endblock %}23 <form {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="{{ form_url }}" method="post">{% block form_top %}{% endblock %} 25 24 <div> 26 25 {% if is_popup %}<input type="hidden" name="_popup" value="1" />{% endif %} 27 26 {% if opts.admin.save_on_top %}{% submit_row %}{% endif %} -
django/contrib/admin/templates/admin/login.html
1 1 {% extends "admin/base_site.html" %} 2 2 {% load i18n %} 3 4 {% block stylesheet %} {% load adminmedia %}{% admin_media_prefix %}css/login.css{% endblock %}3 {% load adminmedia %} 4 {% block stylesheet %}/media/css/login.css{% endblock %} 5 5 {% block bodyclass %}login{% endblock %} 6 6 {% block content_title %}{% endblock %} 7 7 {% block breadcrumbs %}{% endblock %} … … 19 19 <div class="form-row"> 20 20 <label for="id_password">{% trans 'Password:' %}</label> <input type="password" name="password" id="id_password" /> 21 21 <input type="hidden" name="this_is_the_login_form" value="1" /> 22 <input type="hidden" name="post_data" value="{{ post_data }}" /> { #<span class="help">{% trans 'Have you <a href="/password_reset/">forgotten your password</a>?' %}</span>#}22 <input type="hidden" name="post_data" value="{{ post_data }}" /> {% comment %}<span class="help">{% trans 'Have you <a href="/password_reset/">forgotten your password</a>?' %}</span>{% endcomment %} 23 23 </div> 24 24 <div class="submit-row"> 25 25 <label> </label><input type="submit" value="{% trans 'Log in' %}" />