Ignore:
Timestamp:
Apr 15, 2013, 4:21:26 AM (13 years ago)
Author:
Alex Dehnert <adehnert@…>
Branches:
master, space-access, stable, stage
Children:
52fb1d5
Parents:
a01934a
git-author:
Alex Dehnert <adehnert@…> (04/15/13 04:21:26)
git-committer:
Alex Dehnert <adehnert@…> (04/15/13 04:21:26)
Message:

Prevent 500'ing while uploading midway assignments

Add some documentation and improved error messages when uploading midway
assignments. (Fixes ASA-#224.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • asadb/forms/views.py

    r870992c r83759bf  
    630630
    631631class MidwayAssignmentsUploadForm(Form):
    632     assignments = FileField()
     632    def validate_csv_fields(upload_file):
     633        reader = csv.reader(upload_file)
     634        row = reader.next()
     635        for col in ('Group', 'officers', 'Table', ):
     636            if col not in row:
     637                raise ValidationError('Please upload a CSV file with (at least) columns "Group", "officers", and "Table". (Missing at least "%s".)' % (col, ))
     638
     639    assignments = FileField(validators=[validate_csv_fields])
    633640
    634641@permission_required('forms.add_midwayassignment')
Note: See TracChangeset for help on using the changeset viewer.