Changeset dc17b01


Ignore:
Timestamp:
Mar 28, 2010, 6:35:41 AM (15 years ago)
Author:
Alex Dehnert <adehnert@…>
Branches:
master, client
Children:
a75ed9b
Parents:
3111c8a
git-author:
Alex Dehnert <adehnert@…> (03/28/10 06:35:41)
git-committer:
Alex Dehnert <adehnert@…> (03/28/10 06:35:41)
Message:

WIP WIP WIP: Start of doc upload

Location:
remit
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • remit/remit_templates/vouchers/ReimbursementRequest_review.html

    re8550be rdc17b01  
    5555</tr>
    5656<tr>
     57    <th>Documentation</th>
     58    <td>{{rr.documentation}}</td>
     59</tr>
     60<tr>
    5761    <th>Request Time</th>
    5862    <td>{{rr.request_time}}</td>
     
    6771</tr>
    6872</table>
     73
     74{% if doc_form %}
     75<h3>(Optional) Upload Documentation</h3>
     76
     77<p>If you ordered online, you may wish to upload documentation instead of providing a physical copy.</p>
     78
     79<form enctype="multipart/form-data" method="post" action="">
     80<table class='pretty-table'>
     81{{ doc_form.as_table }}
     82<tr><th colspan='2'><input type='submit' value='Upload Documentation' /></th></tr>
     83</table>
     84</form>
     85{% endif %}
    6986
    7087{% if new %}
  • remit/vouchers/models.py

    rc020a3b rdc17b01  
    3131    name = models.CharField(max_length=50, verbose_name='short description', )
    3232    description = models.TextField(blank=True, verbose_name='long description', )
     33    documentation = models.ForeignKey('Documentation', null=True, )
    3334
    3435    class Meta:
     
    9293    gl = models.IntegerField()
    9394    processed = models.BooleanField()
     95    documentation = models.ForeignKey('Documentation', null=True, )
    9496
    9597    def mailing_addr_lines(self):
     
    116118            ('generate_vouchers', 'Can generate vouchers',),
    117119        )
     120
     121
     122class Documentation(models.Model):
     123    backing_file = models.FileField(upload_to='documentation', verbose_name='File', help_text='PDF files only', )
     124    label = models.CharField(max_length=50, )
     125    submitter = models.CharField(max_length=10) # MIT username of submitter
     126    upload_time = models.DateTimeField(default=datetime.datetime.now)
    118127
    119128
  • remit/vouchers/views.py

    r37c15c4 rdc17b01  
    11import vouchers.models
    2 from vouchers.models import ReimbursementRequest
     2from vouchers.models import ReimbursementRequest, Documentation
    33from finance_core.models import BudgetTerm, BudgetArea
    44
     
    5252    term = ModelChoiceField(queryset = BudgetTerm.objects.all())
    5353
     54class DocUploadForm(ModelForm):
     55    class Meta:
     56        model = Documentation
     57        fields = (
     58            'label',
     59            'backing_file',
     60        )
     61
     62
    5463@user_passes_test(lambda u: u.is_authenticated())
    5564def select_request_basics(http_request, ):
     
    111120        form.fields['budget_area'] = CommitteeBudgetAreasField(comm_obj)
    112121        form.fields['expense_area'] = ExpenseAreasField()
     122
    113123        if form.is_valid(): # All validation rules pass
    114124            request_obj = form.save()
     
    165175            new = False
    166176
     177    # DOCUMENTATION #
     178    if request_obj.documentation:
     179        doc_upload_form = None
     180    else:
     181        new_docs = Documentation()
     182        new_docs.submitter = http_request.user.username
     183        if http_request.method == 'POST': # If the form has been submitted...
     184            doc_upload_form = DocUploadForm(http_request.POST, http_request.FILES, instance=new_docs) # A form bound to the POST data
     185
     186            if doc_upload_form.is_valid(): # All validation rules pass
     187                new_docs = doc_upload_form.save()
     188
     189                return HttpResponseRedirect(reverse(review_request, args=[object_id],)) # Redirect after POST
     190        else:
     191            doc_upload_form = DocUploadForm(instance=new_docs, ) # An unbound form
     192
     193    # SEND EMAILS
    167194    show_email = http_request.user.has_perm('vouchers.can_email')
    168195    if show_email:
     
    181208                })
    182209
     210    # APPROVE VOUCHERS
    183211    show_approve = (http_request.user.has_perm('vouchers.can_approve')
    184212        and request_obj.approval_status == vouchers.models.APPROVAL_STATE_PENDING)
     
    229257        'pagename':'request_reimbursement',
    230258        'new': new,
     259        'doc_form': doc_upload_form,
    231260    }
    232261    if show_approve:
Note: See TracChangeset for help on using the changeset viewer.