예제 #1
0
    def get_appy_context(self):
        context = super(SisReport, self).get_appy_context()
        context['date'] = datetime.date.today()
        students = context['objects']
        template = self.report_context.get('template')
        if template:
            self.date_end = self.report_context['date_end']
            context[
                'date_of_report'] = self.date_end  # backwards compatibility for templates
            if template.transcript:
                self.pass_score = float(
                    Configuration.get_or_default("Passing Grade", '70').value)
                self.pass_letters = Configuration.get_or_default(
                    "Letter Passing Grade", 'A,B,C,P').value
                for student in students:
                    self.get_student_transcript_data(student)
            if template.benchmark_report_card and \
                'ecwsp.benchmark_grade' in settings.INSTALLED_APPS:
                from ecwsp.benchmark_grade.report import get_benchmark_report_card_data
                get_benchmark_report_card_data(self.report_context, context,
                                               students)
            elif template.report_card:
                self.blank_grade = struct()
                self.blank_grade.comment = ""
                school_year = SchoolYear.objects.filter(
                    start_date__lte=self.report_context['date_end']).order_by(
                        '-start_date').first()
                context['year'] = school_year
                self.marking_periods = MarkingPeriod.objects.filter(
                    school_year=school_year, show_reports=True)
                context['marking_periods'] = self.marking_periods.order_by(
                    'start_date')
                for student in students:
                    self.get_student_report_card_data(student)
            if template.general_student:
                cal = Calendar()
                schedule_days = self.report_context.get('schedule_days', None)
                marking_periods = MarkingPeriod.objects.filter(
                    start_date__gte=self.report_context['date_end'],
                    end_date__lte=self.report_context['date_end']).order_by(
                        'start_date')
                if not marking_periods.count():
                    marking_periods = MarkingPeriod.objects.filter(
                        start_date__gte=self.report_context['date_begin']
                    ).order_by('start_date')
                current_mp = marking_periods[0]
                for student in students:
                    if current_mp:
                        student.schedule_days, student.periods = cal.build_schedule(
                            student, current_mp, schedule_days=schedule_days)
                    #student.discipline_records = student.studentdiscipline_set.filter(date__gte=begin_end_dates[0],
                    #    date__lte=begin_end_dates[1])
                    #for d in student.discipline_records:
                    #    d.date = d.date.strftime('%b %d, %Y')

        context['students'] = students
        return context
예제 #2
0
    def get_appy_context(self):
        context = super(SisReport, self).get_appy_context()
        context['date'] = datetime.date.today()
        students = context['objects']
        template = self.report_context.get('template')
        if template:
            self.date_end = self.report_context['date_end']
            context['date_of_report'] = self.date_end # backwards compatibility for templates
            if template.transcript:
                self.pass_score = float(Configuration.get_or_default("Passing Grade", '70').value)
                self.pass_letters = Configuration.get_or_default("Letter Passing Grade", 'A,B,C,P').value
                for student in students:
                    self.get_student_transcript_data(student)
            if template.benchmark_report_card and \
                'ecwsp.benchmark_grade' in settings.INSTALLED_APPS:
                from ecwsp.benchmark_grade.report import get_benchmark_report_card_data
                get_benchmark_report_card_data(self.report_context, context, students)
            elif template.report_card:
                self.blank_grade = struct()
                self.blank_grade.comment = ""
                school_year = SchoolYear.objects.filter(start_date__lte=self.report_context['date_end']
                        ).order_by('-start_date').first()
                context['year'] = school_year
                self.marking_periods = MarkingPeriod.objects.filter(
                    school_year=school_year, show_reports=True)
                context['marking_periods'] = self.marking_periods.order_by('start_date')
                for student in students:
                    self.get_student_report_card_data(student)
            if template.general_student:
                cal = Calendar()
                schedule_days = self.report_context.get('schedule_days', None)
                marking_periods = MarkingPeriod.objects.filter(start_date__gte=self.report_context['date_end'],
                    end_date__lte=self.report_context['date_end']).order_by('start_date')
                if not marking_periods.count():
                    marking_periods = MarkingPeriod.objects.filter(start_date__gte=self.report_context['date_begin']).order_by('start_date')
                current_mp = marking_periods[0]
                for student in students:
                    if current_mp:
                        student.schedule_days, student.periods = cal.build_schedule(student, current_mp,
                            schedule_days=schedule_days)
                    #student.discipline_records = student.studentdiscipline_set.filter(date__gte=begin_end_dates[0],
                    #    date__lte=begin_end_dates[1])
                    #for d in student.discipline_records:
                    #    d.date = d.date.strftime('%b %d, %Y')

        context['students'] = students
        return context
예제 #3
0
파일: views.py 프로젝트: gladson/django-sis
def view_student(request, id=None):
    """ Lookup all student information
    """
    if request.method == "GET":
        if id and 'next' in request.GET or 'previous' in request.GET:
            current_student = get_object_or_404(Student, pk=id)
            found = False
            preference = UserPreference.objects.get_or_create(
                user=request.user)[0]
            if 'next' in request.GET:
                if preference.include_deleted_students:
                    students = Student.objects.order_by('lname', 'fname')
                else:
                    students = Student.objects.filter(inactive=False).order_by(
                        'lname', 'fname')
            elif 'previous' in request.GET:
                if preference.include_deleted_students:
                    students = Student.objects.order_by('-lname', '-fname')
                else:
                    students = Student.objects.filter(inactive=False).order_by(
                        '-lname', '-fname')
            for student in students:
                if found:
                    return HttpResponseRedirect('/sis/view_student/' +
                                                str(student.id))
                if student == current_student:
                    found = True

    if request.method == 'POST':
        form = StudentLookupForm(request.POST)
        if form.is_valid():
            return HttpResponseRedirect('/sis/view_student/' +
                                        str(form.cleaned_data['student'].id))

    profile = UserPreference.objects.get_or_create(user=request.user)[0]

    if id:
        student = get_object_or_404(Student, pk=id)
    else:
        messages.warning(request, 'No Student Selected')
        return render_to_response(
            'sis/view_student.html',
            {
                'include_inactive': profile.include_deleted_students,
            },
            RequestContext(request, {}),
        )

    today = date.today()
    emergency_contacts = student.emergency_contacts.all()
    siblings = student.siblings.all()
    numbers = student.studentnumber_set.all()

    # Schedule
    cal = Calendar()
    try:
        location = cal.find_student(student)
    except:
        location = None
        print >> sys.stderr, str(sys.exc_info()[0])
    # Guess the mp desired (current or next coming)
    schedule_days = None
    periods = None
    # look for the current mp first
    current_mp = MarkingPeriod.objects.filter(
        start_date__lte=today, end_date__gte=today).order_by('-start_date')
    # nada? get the next mp (soonest-starting mp ending today or in the future)
    if not current_mp:
        current_mp = MarkingPeriod.objects.filter(
            end_date__gte=today).order_by('start_date')
    if current_mp:
        current_mp = current_mp[0]
        schedule_days, periods = cal.build_schedule(student,
                                                    current_mp,
                                                    include_asp=True)
    else:
        schedule_days = None
        periods = None

    # Discipline
    if 'ecwsp.discipline' in settings.INSTALLED_APPS:
        disciplines = student.studentdiscipline_set.all()
    else:
        disciplines = None

    #### CWSP related
    try:
        clientvisits = student.studentworker.clientvisit_set.all()
    except:
        clientvisits = None
    try:
        company_histories = student.studentworker.companyhistory_set.all()
    except:
        company_histories = None
    try:
        timesheets = student.studentworker.timesheet_set.exclude(
            Q(performance__isnull=True) | Q(performance__exact=''))
    except:
        timesheets = None
    try:
        if request.user.has_perm("sis.view_mentor_student"):
            student_interactions = student.studentworker.studentinteraction_set.all(
            )
        else:
            student_interactions = None
    except:
        student_interactions = None
    try:
        supervisors = student.studentworker.placement.contacts.all()
    except:
        supervisors = None
    ########################################################################

    #Grades
    years = SchoolYear.objects.filter(
        markingperiod__course__courseenrollment__user=student).distinct()
    from ecwsp.grades.models import Grade
    for year in years:
        year.mps = MarkingPeriod.objects.filter(
            course__courseenrollment__user=student,
            school_year=year).distinct().order_by("start_date")
        year.courses = Course.objects.filter(
            courseenrollment__user=student,
            graded=True,
            marking_period__school_year=year).distinct()
        for course in year.courses:
            # Too much logic for the template here, so just generate html.
            course.grade_html = ""
            for marking_period in year.mps:
                try:
                    course.grade_html += '<td> %s </td>' % (Grade.objects.get(
                        student=student,
                        course=course,
                        marking_period=marking_period).get_grade(), )
                except:
                    course.grade_html += '<td> </td>'
            course.grade_html += '<td> %s </td>' % (unicode(
                course.get_final_grade(student)), )

        # Attendance
        if 'ecwsp.attendance' in settings.INSTALLED_APPS:
            attendances = student.student_attn.filter(
                date__range=(year.start_date, year.end_date))
            year.attendances = attendances
            year.attendance_tardy = attendances.filter(
                status__tardy=True).count()
            year.attendance_absense = attendances.filter(
                status__absent=True).count()
            year.attendance_absense_with_half = year.attendance_absense + float(
                attendances.filter(status__half=True).count()) / 2
            year.total = year.get_number_days()
            year.present = year.total - year.attendance_tardy - year.attendance_absense_with_half

    #Standard Tests
    from ecwsp.administration.models import Configuration
    if 'ecwsp.standard_test' in settings.INSTALLED_APPS:
        from ecwsp.standard_test.models import StandardCategory, StandardCategoryGrade, StandardTest, StandardTestResult
        standard_tests = StandardTestResult.objects.filter(student=student)
    else:
        standard_tests = None

    return render_to_response(
        'sis/view_student.html',
        {
            'date': today,
            'student': student,
            'emergency_contacts': emergency_contacts,
            'siblings': siblings,
            'numbers': numbers,
            'location': location,
            'disciplines': disciplines,
            'student_interactions': student_interactions,
            'clientvisits': clientvisits,
            'supervisors': supervisors,
            'company_histories': company_histories,
            'timesheets': timesheets,
            'years': years,
            'current_mp': current_mp,
            'schedule_days': schedule_days,
            'periods': periods,
            'include_inactive': profile.include_deleted_students,
            'tests': standard_tests
        },
        RequestContext(request, {}),
    )
예제 #4
0
파일: views.py 프로젝트: Sateanu/django-sis
def view_student(request, id=None):
    """ Lookup all student information
    """
    if request.method == "GET":
        if id and 'next' in request.GET or 'previous' in request.GET:
            current_student = get_object_or_404(Student, pk=id)
            found = False
            preference = UserPreference.objects.get_or_create(user=request.user)[0]
            if 'next' in request.GET:
                if preference.include_deleted_students:
                    students = Student.objects.order_by('last_name','first_name')
                else:
                    students = Student.objects.filter(is_active=True).order_by('last_name','first_name')
            elif 'previous' in request.GET:
                if preference.include_deleted_students:
                    students = Student.objects.order_by('-last_name','-first_name')
                else:
                    students = Student.objects.filter(is_active=True).order_by('-last_name','-first_name')
            for student in students:
                if found:
                    return HttpResponseRedirect('/sis/view_student/' + str(student.id))
                if student == current_student:
                    found = True
                    
    if request.method == 'POST':
        form = StudentLookupForm(request.POST)
        if form.is_valid():
            return HttpResponseRedirect('/sis/view_student/' + str(form.cleaned_data['student'].id))
            
    profile = UserPreference.objects.get_or_create(user=request.user)[0]
    
    if id:
        student = get_object_or_404(Student, pk=id)
    else:
        messages.warning(request, 'No Student Selected')
        return render_to_response('sis/view_student.html', {
            'include_inactive': profile.include_deleted_students,
        }, RequestContext(request, {}),)
    
    today = date.today()
    emergency_contacts = student.emergency_contacts.all()
    siblings = student.siblings.all()
    numbers = student.studentnumber_set.all()
    
    # Schedule
    cal = Calendar()
    try:
        location = cal.find_student(student)
    except:
        location = None
        print >> sys.stderr, str(sys.exc_info()[0])
    # Guess the mp desired (current or next coming)
    schedule_days = None
    periods = None
    # look for the current mp first
    current_mp = MarkingPeriod.objects.filter(start_date__lte=today, end_date__gte=today).order_by('-start_date')
    # nada? get the next mp (soonest-starting mp ending today or in the future)
    if not current_mp:
        current_mp = MarkingPeriod.objects.filter(end_date__gte=today).order_by('start_date')
    if current_mp:
        current_mp = current_mp[0]
        schedule_days, periods = cal.build_schedule(student, current_mp, include_asp=True)
    else:
        schedule_days = None
        periods = None
    
    # Discipline
    if 'ecwsp.discipline' in settings.INSTALLED_APPS:
        disciplines = student.studentdiscipline_set.all()
    else:
        disciplines = None
    
    #### CWSP related
    try:
        clientvisits = student.studentworker.clientvisit_set.all()
    except:
        clientvisits = None
    try:
        company_histories = student.studentworker.companyhistory_set.all()
    except:
        company_histories = None
    try:
        timesheets = student.studentworker.timesheet_set.exclude(Q(performance__isnull=True) | Q(performance__exact=''))
    except:
        timesheets = None
    try:
        if request.user.has_perm("sis.view_mentor_student"):
            student_interactions = student.studentworker.studentinteraction_set.all()
        else:
            student_interactions = None
    except:
        student_interactions = None
    try:
        supervisors = student.studentworker.placement.contacts.all()
    except:
        supervisors = None
    ########################################################################
    
    #Grades
    years = SchoolYear.objects.filter(markingperiod__course__courseenrollment__user=student).distinct()
    from ecwsp.grades.models import Grade
    for year in years:
        year.mps = MarkingPeriod.objects.filter(course__courseenrollment__user=student, school_year=year).distinct().order_by("start_date")
        year.courses = Course.objects.filter(courseenrollment__user=student, graded=True, marking_period__school_year=year).distinct()
        for course in year.courses:
            # Too much logic for the template here, so just generate html.
            course.grade_html = ""
            for marking_period in year.mps:
                try:
                    course.grade_html += '<td> %s </td>' % (
                        Grade.objects.get(student=student, course=course, marking_period=marking_period).get_grade(),)
                except:
                    course.grade_html += '<td> </td>'
            course.grade_html += '<td> %s </td>' % (unicode(course.get_final_grade(student)),)
        
        # Attendance
        if 'ecwsp.attendance' in settings.INSTALLED_APPS:
            attendances = student.student_attn.filter(date__range=(year.start_date, year.end_date))
            year.attendances = attendances
            year.attendance_tardy = attendances.filter(status__tardy=True).count()
            year.attendance_absense = attendances.filter(status__absent=True).count()
            year.attendance_absense_with_half = year.attendance_absense + float(attendances.filter(status__half=True).count()) / 2
            year.total = year.get_number_days()
            year.present = year.total - year.attendance_tardy - year.attendance_absense_with_half
    
    #Standard Tests
    from ecwsp.administration.models import Configuration
    if 'ecwsp.standard_test' in settings.INSTALLED_APPS:
        from ecwsp.standard_test.models import StandardCategory, StandardCategoryGrade, StandardTest, StandardTestResult
        standard_tests = StandardTestResult.objects.filter(student=student)
    else:
        standard_tests = None
    
    return render_to_response('sis/view_student.html', {
        'date':today,
        'student':student,
        'emergency_contacts': emergency_contacts,
        'siblings': siblings,
        'numbers':numbers,
        'location':location,
        'disciplines':disciplines,
        'student_interactions': student_interactions,
        'clientvisits':clientvisits,
        'supervisors':supervisors,
        'company_histories':company_histories,
        'timesheets':timesheets,
        'years': years,
        'current_mp': current_mp,
        'schedule_days':schedule_days,
        'periods': periods,
        'include_inactive': profile.include_deleted_students,
        'tests': standard_tests
    }, RequestContext(request, {}),)
예제 #5
0
파일: views.py 프로젝트: Sateanu/django-sis
def school_report_builder_view(request):
    """ sis report builder view
    """
    from ecwsp.sis.pdf_reports import student_thumbnail
    if request.method == 'POST':
        if 'thumbs_fresh' in request.POST:
            return student_thumbnail(request, GradeLevel.objects.get(id=9))
        elif 'thumbs_soph' in request.POST:
            return student_thumbnail(request, GradeLevel.objects.get(id=10))
        elif 'thumbs_jun' in request.POST:
            return student_thumbnail(request, GradeLevel.objects.get(id=11))
        elif 'thumbs_sen' in request.POST:
            return student_thumbnail(request, GradeLevel.objects.get(id=12))
        elif 'p_attendance' in request.POST:
            format = UserPreference.objects.get_or_create(user=request.user)[0].get_format(type="document")
            if request.POST['p_attendance'] == "Monday":
                day = "1"
            if request.POST['p_attendance'] == "Tuesday":
                day = "2"
            if request.POST['p_attendance'] == "Wednesday":
                day = "3"
            if request.POST['p_attendance'] == "Thursday":
                day = "4"
            if request.POST['p_attendance'] == "Friday":
                day = "5"
            
            template = Template.objects.get_or_create(name="Paper Attendance")[0].file
            if not template:
                result = False
            else:
                from ecwsp.schedule.models import CourseMeet
                cm = CourseMeet.objects.filter(day=day)
                courses = Course.objects.filter(coursemeet__in=cm, homeroom=True).distinct()
                report = TemplateReport(request.user)
                report.data['courses'] = courses
                result = report.pod_save(template)
            
            if result:
                return result
            else:
                messages.error(request, 'Problem making paper attendance, does the template exist?')
        elif 'pod_report' in request.POST:
            form = StudentReportWriterForm(request.POST, request.FILES)
            if form.is_valid():
                data = form.cleaned_data
                begin_end_dates = form.get_dates()
                if data['template']:
                    # use selected template
                    template = data['template']
                    template = template.get_template_path(request)
                    if not template:
                        return render_to_response('sis/reportBuilder.html', {'request':request, 'form':form}, RequestContext(request, {}))
                else:
                    # or use uploaded template, saving it to temp file
                    template = request.FILES['upload_template']
                    tmpfile = mkstemp()[1]
                    f = open(tmpfile, 'wb')
                    f.write(template.read())
                    f.close()
                    template = tmpfile
                
                report = TemplateReport(request.user)
                students=form.get_students(data)
                cal = Calendar()

                if data['marking_period']:
                    marking_periods = data['marking_period'].order_by('start_date')
                else:
                    marking_periods = MarkingPeriod.objects.filter(start_date__gte=begin_end_dates[0],
                        end_date__lte=begin_end_dates[1]).order_by('start_date')
                    if not marking_periods.count():
                        # range doesn't include a full MP; relax the end date
                        marking_periods = MarkingPeriod.objects.filter(start_date__gte=begin_end_dates[0]).order_by('start_date')
                if marking_periods:
                    current_mp = marking_periods.order_by('-start_date')[0]
                else:
                    current_mp = None

                schedule_days = data['schedule_days']
                if not len(schedule_days):
                    schedule_days = None

                for student in students:
                    if current_mp:
                        student.schedule_days, student.periods = cal.build_schedule(student, current_mp,
                            schedule_days=schedule_days)
                    student.discipline_records = student.studentdiscipline_set.filter(date__gte=begin_end_dates[0],
                        date__lte=begin_end_dates[1])
                    # TODO: put some method in TemplateReport to format dates nicely
                    # also would be nice to have a formatted list maker to replace '; '.join() values_list() nastiness in the template
                    for d in student.discipline_records:
                        d.date = d.date.strftime('%b %d, %Y')

                report.data['students'] = students
                report.data['marking_periods'] = marking_periods 
                report.data['begin_date'] = begin_end_dates[0].strftime('%b %d, %Y') # also gross
                report.data['end_date'] = begin_end_dates[1].strftime('%b %d, %Y')
                return report.pod_save(template)
            else:
                return render_to_response('sis/reportBuilder.html', {'request':request, 'form':form})
    form = StudentReportWriterForm()
    form.fields['template'].queryset = Template.objects.filter(general_student=True)
    return render_to_response('sis/reportBuilder.html', {'request':request, 'form':form}, RequestContext(request, {}))
예제 #6
0
def school_report_builder_view(request):
    """ sis report builder view
    """
    from ecwsp.sis.pdf_reports import student_thumbnail
    if request.method == 'POST':
        if 'thumbs_fresh' in request.POST:
            return student_thumbnail(request, GradeLevel.objects.get(id=9))
        elif 'thumbs_soph' in request.POST:
            return student_thumbnail(request, GradeLevel.objects.get(id=10))
        elif 'thumbs_jun' in request.POST:
            return student_thumbnail(request, GradeLevel.objects.get(id=11))
        elif 'thumbs_sen' in request.POST:
            return student_thumbnail(request, GradeLevel.objects.get(id=12))
        elif 'p_attendance' in request.POST:
            format = UserPreference.objects.get_or_create(user=request.user)[0].get_format(type="document")
            if request.POST['p_attendance'] == "Monday":
                day = "1"
            if request.POST['p_attendance'] == "Tuesday":
                day = "2"
            if request.POST['p_attendance'] == "Wednesday":
                day = "3"
            if request.POST['p_attendance'] == "Thursday":
                day = "4"
            if request.POST['p_attendance'] == "Friday":
                day = "5"
            
            template = Template.objects.get_or_create(name="Paper Attendance")[0].file
            if not template:
                result = False
            else:
                from ecwsp.schedule.models import CourseMeet
                cm = CourseMeet.objects.filter(day=day)
                courses = Course.objects.filter(coursemeet__in=cm, homeroom=True).distinct()
                report = TemplateReport(request.user)
                report.data['courses'] = courses
                result = report.pod_save(template)
            
            if result:
                return result
            else:
                messages.error(request, 'Problem making paper attendance, does the template exist?')
        elif 'pod_report' in request.POST:
            form = StudentReportWriterForm(request.POST, request.FILES)
            if form.is_valid():
                data = form.cleaned_data
                if data['template']:
                    # use selected template
                    template = data['template']
                    template = template.get_template_path(request)
                    if not template:
                        return render_to_response('sis/reportBuilder.html', {'request':request, 'form':form}, RequestContext(request, {}))
                else:
                    # or use uploaded template, saving it to temp file
                    template = request.FILES['upload_template']
                    tmpfile = mkstemp()[1]
                    f = open(tmpfile, 'wb')
                    f.write(template.read())
                    f.close()
                    template = tmpfile
                
                report = TemplateReport(request.user)
                students=form.get_students(data)
                cal = Calendar()
                current_mp = MarkingPeriod.objects.filter(end_date__gte=date.today()).order_by('-start_date')
                schedule_days = data['schedule_days']
                if not len(schedule_days):
                    schedule_days = None
                if current_mp:
                    for student in students:
                        student.schedule_days, student.periods = cal.build_schedule(student, current_mp[0],
                            schedule_days=schedule_days)
                report.data['students'] = students
                return report.pod_save(template)
            else:
                return render_to_response('sis/reportBuilder.html', {'request':request, 'form':form})
    form = StudentReportWriterForm()
    form.fields['template'].queryset = Template.objects.filter(general_student=True)
    return render_to_response('sis/reportBuilder.html', {'request':request, 'form':form}, RequestContext(request, {}))
예제 #7
0
def school_report_builder_view(request):
    """ sis report builder view
    """
    from ecwsp.sis.pdf_reports import student_thumbnail
    if request.method == 'POST':
        if 'thumbs_fresh' in request.POST:
            return student_thumbnail(request, GradeLevel.objects.get(id=9))
        elif 'thumbs_soph' in request.POST:
            return student_thumbnail(request, GradeLevel.objects.get(id=10))
        elif 'thumbs_jun' in request.POST:
            return student_thumbnail(request, GradeLevel.objects.get(id=11))
        elif 'thumbs_sen' in request.POST:
            return student_thumbnail(request, GradeLevel.objects.get(id=12))
        elif 'p_attendance' in request.POST:
            format = UserPreference.objects.get_or_create(user=request.user)[0].get_format(type="document")
            if request.POST['p_attendance'] == "Monday":
                day = "1"
            if request.POST['p_attendance'] == "Tuesday":
                day = "2"
            if request.POST['p_attendance'] == "Wednesday":
                day = "3"
            if request.POST['p_attendance'] == "Thursday":
                day = "4"
            if request.POST['p_attendance'] == "Friday":
                day = "5"
            
            template = Template.objects.get_or_create(name="Paper Attendance")[0].file
            if not template:
                result = False
            else:
                from ecwsp.schedule.models import CourseMeet
                cm = CourseMeet.objects.filter(day=day)
                courses = Course.objects.filter(coursemeet__in=cm, homeroom=True).distinct()
                report = TemplateReport(request.user)
                report.data['courses'] = courses
                result = report.pod_save(template)
            
            if result:
                return result
            else:
                messages.error(request, 'Problem making paper attendance, does the template exist?')
        elif 'pod_report' in request.POST:
            form = StudentReportWriterForm(request.POST, request.FILES)
            if form.is_valid():
                data = form.cleaned_data
                if data['template']:
                    # use selected template
                    template = data['template']
                    template = template.get_template_path(request)
                    if not template:
                        return render_to_response('sis/reportBuilder.html', {'request':request, 'form':form}, RequestContext(request, {}))
                else:
                    # or use uploaded template, saving it to temp file
                    template = request.FILES['upload_template']
                    tmpfile = mkstemp()[1]
                    f = open(tmpfile, 'wb')
                    f.write(template.read())
                    f.close()
                    template = tmpfile
                
                report = TemplateReport(request.user)
                students=form.get_students(data)
                cal = Calendar()
                current_mp = MarkingPeriod.objects.filter(end_date__gte=date.today()).order_by('-start_date')
                if current_mp:
                    for student in students:
                        student.schedule_days, student.periods = cal.build_schedule(student, current_mp[0])
                report.data['students'] = students
                return report.pod_save(template)
            else:
                return render_to_response('sis/reportBuilder.html', {'request':request, 'form':form})
    form = StudentReportWriterForm()
    form.fields['template'].queryset = Template.objects.filter(general_student=True)
    return render_to_response('sis/reportBuilder.html', {'request':request, 'form':form}, RequestContext(request, {}))