app/soc/views/helper/lists.py
changeset 632 1f20cfb91e11
parent 572 1b3e7280743a
child 651 ef6e22d463cb
equal deleted inserted replaced
631:3763d36bcebc 632:1f20cfb91e11
    22   '"Pawel Solyga" <pawel.solyga@gmail.com>',
    22   '"Pawel Solyga" <pawel.solyga@gmail.com>',
    23   ]
    23   ]
    24 
    24 
    25 
    25 
    26 from soc.logic import dicts
    26 from soc.logic import dicts
    27 from soc.views import helper
       
    28 
    27 
    29 import soc.views.helper.forms
    28 import soc.views.helper.forms
    30 
    29 
    31 
    30 
    32 DEF_PAGINATION = 10
    31 DEF_PAGINATION = 10
   165   return content
   164   return content
   166 
   165 
   167 
   166 
   168 def makePaginationForm(
   167 def makePaginationForm(
   169   request, limit, arg_name, choices=DEF_PAGINATION_CHOICES,
   168   request, limit, arg_name, choices=DEF_PAGINATION_CHOICES,
   170   field_name_fmt=helper.forms.DEF_SELECT_QUERY_ARG_FIELD_NAME_FMT):
   169   field_name_fmt=soc.views.helper.forms.DEF_SELECT_QUERY_ARG_FIELD_NAME_FMT):
   171   """Returns a customized pagination limit selection form.
   170   """Returns a customized pagination limit selection form.
   172   
   171   
   173   Args:
   172   Args:
   174     request: the standard Django HTTP request object
   173     request: the standard Django HTTP request object
   175     limit: the initial value of the selection control
   174     limit: the initial value of the selection control
   176     arg_name: see helper.forms.makeSelectQueryArgForm(); default is 'limit'
   175     arg_name: see soc.views.helper.forms.makeSelectQueryArgForm(); default is 'limit'
   177     choices: see helper.forms.makeSelectQueryArgForm(); default is
   176     choices: see soc.views.helper.forms.makeSelectQueryArgForm(); default is
   178       DEF_PAGINATION_CHOICES
   177       DEF_PAGINATION_CHOICES
   179     field_name_fmt: see helper.forms.makeSelectQueryArgForm()
   178     field_name_fmt: see soc.views.helper.forms.makeSelectQueryArgForm()
   180   """
   179   """
   181   choices = makeNewPaginationChoices(limit=limit, choices=choices)
   180   choices = makeNewPaginationChoices(limit=limit, choices=choices)
   182   
   181   
   183   return helper.forms.makeSelectQueryArgForm(
   182   return soc.views.helper.forms.makeSelectQueryArgForm(
   184       request, arg_name, limit, choices)
   183       request, arg_name, limit, choices)
   185 
   184 
   186 
   185 
   187 def makeNewPaginationChoices(limit=DEF_PAGINATION,
   186 def makeNewPaginationChoices(limit=DEF_PAGINATION,
   188                              choices=DEF_PAGINATION_CHOICES):
   187                              choices=DEF_PAGINATION_CHOICES):
   189   """Updates the pagination limit selection form.
   188   """Updates the pagination limit selection form.
   190 
   189 
   191   Args:
   190   Args:
   192     limit: the initial value of the selection control;
   191     limit: the initial value of the selection control;
   193       default is DEF_PAGINATION
   192       default is DEF_PAGINATION
   194     choices: see helper.forms.makeSelectQueryArgForm();
   193     choices: see soc.views.helper.forms.makeSelectQueryArgForm();
   195       default is DEF_PAGINATION_CHOICES
   194       default is DEF_PAGINATION_CHOICES
   196 
   195 
   197   Returns:
   196   Returns:
   198     a new pagination choices list if limit is not in
   197     a new pagination choices list if limit is not in
   199     DEF_PAGINATION_CHOICES, or DEF_PAGINATION_CHOICES otherwise
   198     DEF_PAGINATION_CHOICES, or DEF_PAGINATION_CHOICES otherwise