Changeset 0a5a003 for remit/vouchers


Ignore:
Timestamp:
Mar 29, 2010, 4:37:59 AM (14 years ago)
Author:
Alex Dehnert <adehnert@…>
Branches:
master, client
Children:
80d1270
Parents:
f7dd5e7
git-author:
Alex Dehnert <adehnert@…> (03/29/10 04:37:59)
git-committer:
Alex Dehnert <adehnert@…> (03/29/10 04:37:59)
Message:

Validate as PDF-only

File:
1 edited

Legend:

Unmodified
Added
Removed
  • remit/vouchers/views.py

    rf7dd5e7 r0a5a003  
    5454
    5555class DocUploadForm(ModelForm):
     56    def clean_backing_file(self, ):
     57        f = self.cleaned_data['backing_file']
     58        ext = f.name.rsplit('.')[-1]
     59        contenttype = f.content_type
     60        if ext != 'pdf':
     61            raise django.forms.ValidationError("Only PDF files are accepted --- you submitted a .%s file" % (ext, ))
     62        elif contenttype != 'application/pdf':
     63            raise django.forms.ValidationError("Only PDF files are accepted --- you submitted a %s file" % (contenttype, ))
     64        else:
     65            return f
     66
    5667    class Meta:
    5768        model = Documentation
Note: See TracChangeset for help on using the changeset viewer.