Ticket #3152: number_per_page.diff

File number_per_page.diff, 16.6 KB (added by Ben Ford <ben.fordnz@…>, 18 years ago)
  • django/conf/global_settings.py

     
    205205
    206206# Default formatting for date objects. See all available format strings here:
    207207# http://www.djangoproject.com/documentation/templates/#now
    208 DATE_FORMAT = 'N j, Y'
     208#DATE_FORMAT = 'N j, Y'
     209DATE_FORMAT = 'j/m/y'
    209210
    210211# Default formatting for datetime objects. See all available format strings here:
    211212# http://www.djangoproject.com/documentation/templates/#now
    212 DATETIME_FORMAT = 'N j, Y, P'
     213#DATETIME_FORMAT = 'N j, Y, P'
     214DATETIME_FORMAT = 'j/m/y H:i'
    213215
    214216# Default formatting for time objects. See all available format strings here:
    215217# http://www.djangoproject.com/documentation/templates/#now
    216 TIME_FORMAT = 'P'
     218#TIME_FORMAT = 'P'
     219TIME_FORMAT = 'H:i'
    217220
    218221# Default formatting for date objects when only the year and month are relevant.
    219222# See all available format strings here:
  • django/utils/translation/trans_real.py

     
    359359    one, the formats provided in the settings will be used.
    360360    """
    361361    from django.conf import settings
     362    print settings.DATETIME_FORMAT
    362363    date_format = _('DATE_FORMAT')
     364    print date_format
    363365    datetime_format = _('DATETIME_FORMAT')
    364366    time_format = _('TIME_FORMAT')
    365367    if date_format == 'DATE_FORMAT':
     
    368370        datetime_format = settings.DATETIME_FORMAT
    369371    if time_format == 'TIME_FORMAT':
    370372        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
    372376
    373377def get_partial_date_formats():
    374378    """
  • django/contrib/admin/media/css/changelists.css

     
    4848.paginator .end { border-width:2px !important; margin-right:6px; }
    4949.paginator .this-page { padding:2px 6px; font-weight:bold; font-size:13px; vertical-align:top; }
    5050.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

     
    5656                page_range.extend(range(page_num + 1, paginator.pages))
    5757
    5858    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
    5963    return {
    6064        'cl': cl,
    6165        'pagination_required': pagination_required,
    6266        'show_all_url': need_show_all_link and cl.get_query_string({ALL_VAR: ''}),
    6367        'page_range': page_range,
     68        'num_choices': range(MIN, MAX+STEP, STEP),
    6469        'ALL_VAR': ALL_VAR,
    6570        '1': 1,
    6671    }
     
    8792            # Non-field list_display values don't get ordering capability.
    8893            yield {"text": header}
    8994        else:
    90             if isinstance(f.rel, models.ManyToOneRel) and f.null:
    91                 yield {"text": f.verbose_name}
    92             else:
    93                 th_classes = []
    94                 new_order_type = 'asc'
    95                 if field_name == cl.order_field:
    96                     th_classes.append('sorted %sending' % cl.order_type.lower())
    97                     new_order_type = {'asc': 'desc', 'desc': 'asc'}[cl.order_type.lower()]
     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()]
    98103
    99                 yield {"text": f.verbose_name,
    100                        "sortable": True,
    101                        "url": cl.get_query_string({ORDER_VAR: i, ORDER_TYPE_VAR: new_order_type}),
    102                        "class_attrib": (th_classes and ' class="%s"' % ' '.join(th_classes) or '')}
     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 '')}
    103108
    104109def items_for_result(cl, result):
    105110    first = True
  • django/contrib/admin/views/main.py

     
    3030ORDER_VAR = 'o'
    3131ORDER_TYPE_VAR = 'ot'
    3232PAGE_VAR = 'p'
     33NPP = 'npp'
    3334SEARCH_VAR = 'q'
    3435IS_POPUP_VAR = 'pop'
    3536ERROR_FLAG = 'e'
     
    550551        self.lookup_opts = self.opts
    551552        self.manager = self.opts.admin.manager
    552553
     554        #Number on page from query string
     555        self.show_per_page = int(request.GET.get(NPP, self.opts.admin.list_per_page))
     556
    553557        # Get search parameters from the query string.
    554558        try:
    555559            self.page_num = int(request.GET.get(PAGE_VAR, 0))
     
    573577
    574578    def get_filters(self, request):
    575579        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:
    577581            filter_fields = [self.lookup_opts.get_field(field_name) \
    578582                              for field_name in self.lookup_opts.admin.list_filter]
    579583            for f in filter_fields:
     
    598602        return '?' + '&amp;'.join(['%s=%s' % (k, v) for k, v in p.items()]).replace(' ', '%20')
    599603
    600604    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)
    602606
    603607        # Get the number of objects, with admin filters applied.
    604608        try:
     
    620624            full_result_count = self.manager.count()
    621625
    622626        can_show_all = result_count <= MAX_SHOW_ALL_ALLOWED
    623         multi_page = result_count > self.lookup_opts.admin.list_per_page
     627        multi_page = result_count > self.show_per_page
    624628
    625629        # Get the list of objects to display on this page.
    626630        if (self.show_all and can_show_all) or not multi_page:
     
    671675    def get_query_set(self):
    672676        qs = self.manager.get_query_set()
    673677        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):
    675679            if lookup_params.has_key(i):
    676680                del lookup_params[i]
    677681
     
    706710                # For OneToOneFields, don't try to order by the related object's ordering criteria.
    707711                pass
    708712            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
    710720                lookup_order_field = '%s.%s' % (f.rel.to._meta.db_table, rel_ordering)
    711721
    712722        # Set ordering.
  • django/contrib/admin/templates/admin/change_list.html

     
    11{% extends "admin/base_site.html" %}
    22{% load adminmedia admin_list i18n %}
    3 {% block stylesheet %}{% admin_media_prefix %}css/changelists.css{% endblock %}
     3{% block stylesheet %}/media/css/changelists.css{% endblock %}
    44{% block bodyclass %}change-list{% endblock %}
    55{% 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> &rsaquo; {{ cl.opts.verbose_name_plural|capfirst|escape }}</div>{% endblock %}{% endif %}
     6{% block breadcrumbs %}
     7    {{ block.super }} &rsaquo; <li class='crumb'> {{ cl.opts.verbose_name_plural|capfirst|escape }} </li>
     8{% endblock %}
    79{% block coltype %}flex{% endblock %}
    810{% block content %}
    911<div id="content-main">
     
    1214{% endif %}
    1315<div class="module{% if cl.has_filters %} filtered{% endif %}" id="changelist">
    1416{% block search %}{% search_form cl %}{% endblock %}
     17{% block pagination %}{% pagination cl %}{% endblock %}
    1518{% block date_hierarchy %}{% date_hierarchy cl %}{% endblock %}
    1619{% block filters %}{% filters cl %}{% endblock %}
    1720{% block result_list %}{% result_list cl %}{% endblock %}
    18 {% block pagination %}{% pagination cl %}{% endblock %}
    1921</div>
    2022</div>
    2123{% endblock %}
  • django/contrib/admin/templates/admin/pagination.html

     
    11{% load admin_list %}
    22{% load i18n %}
    33<p class="paginator">
     4<span id='page_no'>
    45{% if pagination_required %}
     6Page
    57{% for i in page_range %}
    68    {% paginator_number cl i %}
    79{% endfor %}
    810{% endif %}
    911{{ cl.result_count }} {% ifequal cl.result_count 1 %}{{ cl.opts.verbose_name|escape }}{% else %}{{ cl.opts.verbose_name_plural|escape }}{% endifequal %}
    1012{% if show_all_url %}&nbsp;&nbsp;<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>
    1125</p>
  • django/contrib/admin/templates/admin/edit_inline_tabular.html

     
    77         <th{{ fw.header_class_attribute }}>{{ fw.field.verbose_name|capfirst|escape }}</th>
    88      {% endif %}
    99   {% endfor %}
    10    </tr></thead>
    1110   {% for fcw in bound_related_object.form_field_collection_wrappers %}
    1211      {% if change %}{% if original_row_needed %}
    1312         {% if fcw.obj.original %}
  • django/contrib/admin/templates/admin/base_site.html

     
    1 {% extends "admin/base.html" %}
     1{% extends "base.html" %}
    22{% load i18n %}
     3{% block breadcrumbs %}
     4    {{ block.super }} &rsaquo;<a href='/admin/'> {% trans 'Admin' %} </a>
     5{% endblock %}
     6{% block admin_active %}active{% endblock %}
    37
    48{% block title %}{{ title|escape }} | {% trans 'Django site admin' %}{% endblock %}
    59
    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>
    812{% endblock %}
    913
    10 {% block nav-global %}{% endblock %}
  • django/contrib/admin/templates/admin/index.html

     
    11{% extends "admin/base_site.html" %}
    22{% 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 %}
    55{% block coltype %}colMS{% endblock %}
    66{% block bodyclass %}dashboard{% endblock %}
    7 {% block breadcrumbs %}{% endblock %}
    87{% block content %}
    98<div id="content-main">
    109
  • django/contrib/admin/templates/admin/change_form.html

     
    44<script type="text/javascript" src="../../../jsi18n/"></script>
    55{% for js in javascript_imports %}{% include_admin_script js %}{% endfor %}
    66{% endblock %}
    7 {% block stylesheet %}{% admin_media_prefix %}css/forms.css{% endblock %}
     7{% block stylesheet %}/media/css/forms.css{% endblock %}
    88{% block coltype %}{% if ordered_objects %}colMS{% else %}colM{% endif %}{% endblock %}
    99{% block bodyclass %}{{ opts.app_label }}-{{ opts.object_name.lower }} change-form{% endblock %}
    1010{% 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> &rsaquo;
    14      <a href="../">{{ opts.verbose_name_plural|capfirst|escape }}</a> &rsaquo;
    15      {% if add %}{% trans "Add" %} {{ opts.verbose_name|escape }}{% else %}{{ original|truncatewords:"18"|escape }}{% endif %}
     11{% block breadcrumbs %}
     12    {{ block.super }}
     13    &rsaquo;<a href="../"> {{ opts.verbose_name_plural|capfirst|escape }} </a> &rsaquo;
     14     {% if add %}{% trans "Add" %} {{ opts.verbose_name|escape }}{% else %}{{ original|truncatewords:"18"|escape }}
    1615</div>
    1716{% endif %}{% endblock %}
    1817{% block content %}<div id="content-main">
     
    2120  {% if has_absolute_url %}<li><a href="../../../r/{{ content_type_id }}/{{ object_id }}/" class="viewsitelink">{% trans "View on site" %}</a></li>{% endif%}
    2221  </ul>
    2322{% 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 %}
    2524<div>
    2625{% if is_popup %}<input type="hidden" name="_popup" value="1" />{% endif %}
    2726{% if opts.admin.save_on_top %}{% submit_row %}{% endif %}
  • django/contrib/admin/templates/admin/login.html

     
    11{% extends "admin/base_site.html" %}
    22{% 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 %}
    55{% block bodyclass %}login{% endblock %}
    66{% block content_title %}{% endblock %}
    77{% block breadcrumbs %}{% endblock %}
     
    1919  <div class="form-row">
    2020    <label for="id_password">{% trans 'Password:' %}</label> <input type="password" name="password" id="id_password" />
    2121    <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 %}
    2323  </div>
    2424  <div class="submit-row">
    2525    <label>&nbsp;</label><input type="submit" value="{% trans 'Log in' %}" />
Back to Top