Beispiel #1
0
def reports(request):
    report_form = ReportForm()
    if request.POST:
        report_form = ReportForm(request.POST)
        if report_form.is_valid():
            year = report_form.cleaned_data['school_year']
            if 'applicants_to_students' in request.POST:
                return HttpResponseRedirect(
                    reverse(applicants_to_students, args=[year[0].id]))
            elif 'funnel' in request.POST:
                year_ids = ''
                for year_item in year.values('id'):
                    year_ids += str(year_item['id']) + ','
                if year_ids:
                    year_ids = year_ids[:-1]
                return HttpResponseRedirect(
                    reverse(funnel) + '?year_ids=%s' % (year_ids))
            return report_process_statistics(year)

    return render_to_response(
        'admissions/report.html',
        {
            'report_form': report_form,
        },
        RequestContext(request, {}),
    )
Beispiel #2
0
def reports(request):
    report_form = ReportForm()
    template_form = TemplateReportForm()
    if request.POST:
        if 'template_report' in request.POST:
            form = TemplateReportForm(request.POST)
            if form.is_valid():
                data = form.cleaned_data
                template = data['template'].file
                # Use students variable for consistency in template
                students = Applicant.objects.all()
                if data['school_year']:
                    students = students.filter(
                        school_year__in=data['school_year'])
                if data['level']:
                    students = students.filter(level__in=data['level'])
                if data['ready_for_export']:
                    students = students.filter(
                        ready_for_export=data['ready_for_export'])
                report = AdmissionsTemplateReport(user=request.user)
                report.data['students'] = students
                try:
                    return report.pod_save(template)
                except zipfile.BadZipfile:
                    return HttpResponse('Invalid template file')
                except ValueError:
                    return HttpResponse('Report template does not exist')

        else:
            report_form = ReportForm(request.POST)
            if report_form.is_valid():
                year = report_form.cleaned_data['school_year']
                if 'applicants_to_students' in request.POST:
                    return HttpResponseRedirect(
                        reverse(applicants_to_students, args=[year[0].id]))
                elif 'funnel' in request.POST:
                    year_ids = ''
                    for year_item in year.values('id'):
                        year_ids += str(year_item['id']) + ','
                    if year_ids:
                        year_ids = year_ids[:-1]
                    return HttpResponseRedirect(
                        reverse(funnel) + '?year_ids=%s' % (year_ids))
                return report_process_statistics(year)

    return render_to_response(
        'admissions/report.html',
        {
            'report_form': report_form,
            'template_form': template_form,
        },
        RequestContext(request, {}),
    )
Beispiel #3
0
def reports(request):
    report_form = ReportForm()
    template_form = TemplateReportForm()
    if request.POST:
        if 'template_report' in request.POST:
            form = TemplateReportForm(request.POST)
            if form.is_valid():
                data = form.cleaned_data
                template = data['template'].file
                # Use students variable for consistency in template
                students = Applicant.objects.all()
                if data['school_year']:
                    students = students.filter(school_year__in=data['school_year'])
                if data['level']:
                    students = students.filter(level__in=data['level'])
                if data['ready_for_export']:
                    students = students.filter(ready_for_export=data['ready_for_export'])
                report = AdmissionsTemplateReport(user=request.user)
                report.data['students'] = students
                try:
                    return report.pod_save(template)
                except zipfile.BadZipfile:
                    return HttpResponse('Invalid template file')
                except ValueError:
                    return HttpResponse('Report template does not exist')

        else:
            report_form = ReportForm(request.POST)
            if report_form.is_valid():
                year = report_form.cleaned_data['school_year']
                if 'applicants_to_students' in request.POST:
                    return HttpResponseRedirect(reverse(applicants_to_students, args=[year[0].id]))
                elif 'funnel' in request.POST:
                    year_ids = ''
                    for year_item in year.values('id'):
                        year_ids += str(year_item['id']) + ','
                    if year_ids:
                        year_ids = year_ids[:-1]
                    return HttpResponseRedirect(reverse(funnel) + '?year_ids=%s' % (year_ids))
                return report_process_statistics(year)


    return render_to_response('admissions/report.html', {
            'report_form': report_form,
            'template_form': template_form,
        },
        RequestContext(request, {}),
    )
Beispiel #4
0
def reports(request):
    report_form = ReportForm()
    template_form = TemplateReportForm()
    if request.POST:
        if "template_report" in request.POST:
            form = TemplateReportForm(request.POST)
            if form.is_valid():
                data = form.cleaned_data
                template = data["template"].file
                # Use students variable for consistency in template
                students = Applicant.objects.all()
                if data["school_year"]:
                    students = students.filter(school_year__in=data["school_year"])
                if data["level"]:
                    students = students.filter(level__in=data["level"])
                if data["ready_for_export"]:
                    students = students.filter(ready_for_export=data["ready_for_export"])
                report = AdmissionsTemplateReport(user=request.user)
                report.data["students"] = students
                try:
                    return report.pod_save(template)
                except zipfile.BadZipfile:
                    return HttpResponse("Invalid template file")

        else:
            report_form = ReportForm(request.POST)
            if report_form.is_valid():
                year = report_form.cleaned_data["school_year"]
                if "applicants_to_students" in request.POST:
                    return HttpResponseRedirect(reverse(applicants_to_students, args=[year[0].id]))
                elif "funnel" in request.POST:
                    year_ids = ""
                    for year_item in year.values("id"):
                        year_ids += str(year_item["id"]) + ","
                    if year_ids:
                        year_ids = year_ids[:-1]
                    return HttpResponseRedirect(reverse(funnel) + "?year_ids=%s" % (year_ids))
                return report_process_statistics(year)

    return render_to_response(
        "admissions/report.html",
        {"report_form": report_form, "template_form": template_form},
        RequestContext(request, {}),
    )
Beispiel #5
0
def reports(request):
    report_form = ReportForm()
    if request.POST:
        report_form = ReportForm(request.POST)
        if report_form.is_valid():
            year = report_form.cleaned_data['school_year']
            if 'applicants_to_students' in request.POST:
                return HttpResponseRedirect(reverse(applicants_to_students, args=[year[0].id]))
            elif 'funnel' in request.POST:
                year_ids = ''
                for year_item in year.values('id'):
                    year_ids += str(year_item['id']) + ','
                if year_ids:
                    year_ids = year_ids[:-1]
                return HttpResponseRedirect(reverse(funnel) + '?year_ids=%s' % (year_ids))
            return report_process_statistics(year)
    
    return render_to_response('admissions/report.html', {
            'report_form': report_form,
        },
        RequestContext(request, {}),
    )