Beispiel #1
0
def invite_list(request,eventId):
    event = get_object_or_404(Event,pk=eventId)

    new_person = EventAttendancePerson()
    new_person.event = event
    new_person_form = NewEventPersonForm(instance=new_person)

    invite_list = event.eventattendanceperson_set.all()

    student_sunets = StandardStudentCSVProcessor.getStudentSunetIDs()

    student_annotated = []
    for student in invite_list:
        recognized = False
        if student.sunetid in student_sunets:
            recognized = True
        student_annotated.append((student,recognized))

    flag = ""
    if request.GET.get('flag'):
        flag = request.GET.get('flag')

    return render_to_response('scanner/manage/invite_list.html',{
        'event': event,
        'new_person_form': new_person_form,
        'invite_list': student_annotated,
        'flag': flag,
        },
        context_instance=RequestContext(request))
Beispiel #2
0
    def clean_sunets(self):
        sunetBlock = str(self.cleaned_data.get('sunets'))

        student_sunets = StandardStudentCSVProcessor.getStudentSunetIDs()

        errors = []
        sunets = []

        lines = sunetBlock.splitlines()
        for line in lines:
            individuals = line.split(',')

            for individual in individuals:
                individual = individual.lower().strip()
                individual = individual.replace("@stanford.edu","")
                if not self.sunet_is_valid_form(individual):
                    errors.append('%s is not proper form for a SUNetID' % individual)
                    continue
                if individual not in student_sunets:
                    errors.append('%s is not recognized as a SUNetID' % individual)
                    continue
                sunets.append(individual)

                # for now
#        ignore = self.cleaned_data.get('ignore')
#        print ignore
#        print "LOLOL"
#        if len(errors) > 0 and not ignore:
#            raise forms.ValidationError(errors)
        return sunets
Beispiel #3
0
def uploadSales(request,eventId):
    """
    THIS FUNCTION IS DEPRECATED
    Format:
    [0] barcode ID
    [1] admitted (TRUE / FALSE)
    [2] special codes (int)
    """
    event = get_object_or_404(Event,pk=eventId)

    form = ImportAdmitInfoForm()
    if request.method == 'POST':
        form = ImportAdmitInfoForm(request.POST,request.FILES)

    if not form.is_valid():
        return render_to_response('scanner/manage/upload.html',{'form': form,'event': event}, context_instance=RequestContext(request))

    csv_processor = StandardStudentCSVProcessor()
    student_dict = StandardStudentCSVProcessor.collectAsDict(csv_processor.studentRecords())
    
    try:
        admit_csv = request.FILES['admits']
        lines = []
        errors = []
        for chunk in admit_csv.chunks():
            lines += chunk.splitlines()
        reader = csv.reader(lines)

        for line in reader:
            if line[0] not in student_dict:
                errors.append("Barcode ID %s not in the student list. Student was not added." % line[0])
                continue

            attendance = EventAttendancePerson.objects.get_or_create(sunetid=student_dict[line[0]].sunetid,event=event)
            print "added attendee"
            
        return render_to_response('scanner/manage/upload_done.html',{'errors': errors, 'event': event}, context_instance=RequestContext(request))

    except Exception as e:
        return render_to_response('scanner/manage/upload_done.html',{'errors': [e], 'event': event}, context_instance=RequestContext(request))
Beispiel #4
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
Beispiel #5
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))