app/soc/views/helper/lists.py
changeset 2363 9046c80a9137
parent 2358 e5821b87f6e3
child 2855 ec2ed1571e3a
equal deleted inserted replaced
2362:f211b75922ac 2363:9046c80a9137
   196 
   196 
   197   base_params = dict(i for i in request.GET.iteritems() if
   197   base_params = dict(i for i in request.GET.iteritems() if
   198                      i[0].startswith('offset_') or i[0].startswith('limit_'))
   198                      i[0].startswith('offset_') or i[0].startswith('limit_'))
   199 
   199 
   200   if params.get('list_key_order'):
   200   if params.get('list_key_order'):
   201     export_link = generateLinkForRequest(request, base_params, {'export' : idx})
   201     export_link = generateLinkForRequest(request, base_params, {'export': idx})
   202 
   202 
   203   if more:
   203   if more:
   204     # TODO(dbentley): here we need to implement a new field "last_key"
   204     # TODO(dbentley): here we need to implement a new field "last_key"
   205     next = generateLinkForRequest(request, base_params, {offset_key : offset+limit,
   205     next = generateLinkForRequest(request, base_params, 
   206                                                          limit_key : limit})
   206                                   {offset_key: offset + limit,
       
   207                                    limit_key: limit})
   207 
   208 
   208   if offset > 0:
   209   if offset > 0:
   209     # TODO(dbentley): here we need to implement previous in the good way.
   210     # TODO(dbentley): here we need to implement previous in the good way.
   210     prev = generateLinkForRequest(request, base_params,
   211     prev = generateLinkForRequest(request, base_params,
   211                                   { offset_key : max(0, offset-limit),
   212                                   {offset_key: max(0, offset-limit),
   212                                     limit_key : limit })
   213                                    limit_key: limit})
   213 
   214 
   214   if offset > limit:
   215   if offset > limit:
   215     # Having a link to the first doesn't make sense on the first page (we're on
   216     # Having a link to the first doesn't make sense on the first page (we're on
   216     # it).  It also doesn't make sense on the second page (because the first
   217     # it).  It also doesn't make sense on the second page (because the first
   217     # page is the previous page).
   218     # page is the previous page).
   218 
   219 
   219     # NOTE(dbentley): I personally disagree that it's simpler to do that way,
   220     # NOTE(dbentley): I personally disagree that it's simpler to do that way,
   220     # because sometimes you want to go to the first page without having to
   221     # because sometimes you want to go to the first page without having to
   221     # consider what page you're on now.
   222     # consider what page you're on now.
   222     newest = generateLinkForGetArgs(request, base_params, {offset_key : 0,
   223     newest = generateLinkForRequest(request, base_params, {offset_key: 0,
   223                                                            limit_key : limit})
   224                                                            limit_key: limit})
   224 
   225 
   225   content = {
   226   content = {
   226       'idx': idx,
   227       'idx': idx,
   227       'data': data,
   228       'data': data,
   228       'export': export_link,
   229       'export': export_link,