Exemple #1
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"
            result = pod_report_paper_attendance(day, format=format)
            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
                format = UserPreference.objects.get_or_create(user=request.user)[0].get_format(type="document")
                return pod_report_all(template, options=data, students=form.get_students(data), format=format)
            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, {}))
Exemple #2
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
                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, {}))
Exemple #3
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, {}))
Exemple #4
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, {}))