示例#1
0
def exportFile(request,eventId):
    event = get_object_or_404(Event,pk=eventId)

    #try:
    csv_processor = StandardStudentCSVProcessor()
    attendance = AttendanceProcessor(event)
    admit_list = [attendance.processStudent(student) for student in csv_processor.studentRecords()]
    exporter = ScannerDATFile(event,csv_processor.data_date)
    exporter.writeStudents(admit_list)

    #except Exception as e:
     #   return render_to_response('scanner/manage/exportError.html',{'event': event, 'error': e}, context_instance=RequestContext(request))


    filename =  exporter.getFilename()

    #response = HttpResponse()
    response = HttpResponse(mimetype='application/octet-stream')
    response['Content-Disposition'] = 'attachment; filename=%s' % filename
    response.write(exporter.getExport())

    return response
示例#2
0
def testStudents(request,eventId):
    """
    Enormous hack, it's 1 AM :(
    """

    event = get_object_or_404(Event,pk=eventId)
    errors = {}
    record_errors = []

    invited_students = set([student.sunetid for student in event.eventattendanceperson_set.all()])

    # from SUNetID to student record
    csv_processor = StandardStudentCSVProcessor()
    invited_records = []
    for student in csv_processor.studentRecords():
        if student.sunetid in invited_students:
            invited_records.append(student)
            invited_students.remove(student.sunetid)

    # Any students who didn't have records are a problem
    for sunetid in invited_students:
        record_errors.append(sunetid)

    # Check allowed access
    attendance = AttendanceProcessor(event)

    for record in invited_records:
        if not attendance.studentIsPermittedByRules(record):
            # if not permitted, and no record was permitted, deny
            errors[record.barcode_id] = (record,False)
        elif attendance.studentIsPermittedByRules(record):
            # if permitted, add the permitted record
            errors[record.barcode_id] = (record,True)
        else:
            pass

    return render_to_response('scanner/manage/check_list.html',{'errors': errors.values(), 'record_errors': record_errors, 'event': event}, context_instance=RequestContext(request))