Changeset 638b547 for remit/vouchers


Ignore:
Timestamp:
Jul 7, 2014, 10:31:19 PM (11 years ago)
Author:
Alex Dehnert <adehnert@…>
Branches:
master
Children:
922e0e5
Parents:
56c7337
git-author:
Alex Dehnert <adehnert@…> (07/07/14 22:31:19)
git-committer:
Alex Dehnert <adehnert@…> (07/07/14 22:31:19)
Message:

Generate RFPs, not vouchers, and show better messages

File:
1 edited

Legend:

Unmodified
Added
Removed
  • remit/vouchers/views.py

    r56c7337 r638b547  
    262262        and request_obj.approval_status == vouchers.models.APPROVAL_STATE_PENDING)
    263263    post_approve = (http_request.method == 'POST' and 'approve' in http_request.REQUEST)
     264    approve_message = ''
     265    approve_level = ''
    264266    if show_approve:
    265         # Voucherize form
    266         # Prefill from certs / config
    267         initial = {}
    268         initial['name'] = '%s %s' % (http_request.user.first_name, http_request.user.last_name, )
    269         if settings.SIGNATORY_EMAIL:
    270             initial['email'] = settings.SIGNATORY_EMAIL
    271         else:
    272             initial['email'] = http_request.user.email
    273 
    274         approve_message = ''
    275         if post_approve:
    276             approve_form = VoucherizeForm(http_request.POST)
    277             if approve_form.is_valid():
    278                 request_obj.approve(
    279                     approver=http_request.user,
    280                     signatory_name=approve_form.cleaned_data['name'],
    281                     signatory_email=approve_form.cleaned_data['email'],
    282                 )
    283                 approve_message = 'Created new voucher from request'
    284         else:
    285             approve_form = VoucherizeForm(initial=initial)
     267        if not request_obj.documentation:
     268            approve_message = "Documentation must be uploaded (above) before approving RFPs."
     269            approve_level = 'warn'
     270        elif post_approve:
     271            request_obj.approve_as_rfp(approver=http_request.user)
     272            approve_message = 'Queued RFP from request.'
     273            approve_level = 'info'
     274    elif post_approve:
     275        approve_message = "You attempted to approve a reimbursement request that you could not approve. Most likely, either the voucher has already been approved, or you do not have adequate permissions."
     276        approve_level = 'error'
    286277
    287278    context = {
     
    290281        'new': new,
    291282        'doc_form': doc_upload_form,
     283        'show_approve': show_approve,
     284        'approve_message': approve_message,
     285        'approve_level': approve_level,
    292286    }
    293     if show_approve:
    294         context['approve_form'] = approve_form
    295         context['approve_message'] = approve_message
    296     elif post_approve:
    297         context['approve_error'] = "You attempted to approve a reimbursement request that you could not approve. Most likely, either the voucher has already been approved, or you do not have adequate permissions."
    298287    if show_email:
    299288        context['email_options'] = email_options
Note: See TracChangeset for help on using the changeset viewer.