Changeset f52f909 for remit/vouchers


Ignore:
Timestamp:
May 31, 2010, 5:17:26 AM (15 years ago)
Author:
Alex Dehnert <adehnert@…>
Branches:
master, client
Children:
5e6ab71
Parents:
6e43384
git-author:
Alex Dehnert <adehnert@…> (05/31/10 05:08:25)
git-committer:
Alex Dehnert <adehnert@…> (05/31/10 05:17:26)
Message:

Allow sorting requests (Trac: #39)

Location:
remit/vouchers
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • remit/vouchers/models.py

    rb1e217a rf52f909  
    4040            ('can_email', 'Can send mail about requests',),
    4141        )
     42        ordering = ['id', ]
    4243
    4344    def __unicode__(self, ):
  • remit/vouchers/views.py

    r6e43384 rf52f909  
    344344    return Q(submitter=user.username) | Q(check_to_email=user.email)
    345345
     346request_list_orders = (
     347#   Name            Label               Columns
     348    ('default',     'Default',          ()),
     349    ('id',          'ID',               ('id', )),
     350    ('state',       'Approval Status',  ('approval_status', )),
     351    ('stateamount', 'Approval Status, then amount',  ('approval_status', 'amount', )),
     352    ('stateto',     'Approval Status, then recipient',  ('approval_status', 'check_to_first_name', 'check_to_last_name', )),
     353    ('statesubmit', 'Approval Status, then submitter',  ('approval_status', 'submitter', )),
     354    ('name',        'Request Name',     ('name', )),
     355    ('amount',      'Amount',           ('amount', )),
     356    ('check_to',    'Check Recipient',  ('check_to_first_name', 'check_to_last_name', )),
     357    ('submitter',   'Submitter',        ('submitter', )),
     358)
     359
    346360@login_required
    347361def show_requests(request, ):
     
    353367        useronly = True
    354368
     369    if 'order' in request.REQUEST:
     370        order_row = [row for row in request_list_orders if row[0] == request.REQUEST['order']]
     371        if order_row:
     372            order, label, cols = order_row[0]
     373            qs = qs.order_by(*cols)
     374        else:
     375            raise Http404('Order by constraint not known')
     376    else:
     377        order = 'default'
     378
     379
    355380    return list_detail.object_list(
    356381        request,
     
    358383        extra_context={
    359384            'useronly': useronly,
     385            'order'   : order,
     386            'orders'  : request_list_orders,
    360387            'pagename': 'list_requests',
    361388        },
Note: See TracChangeset for help on using the changeset viewer.