Example #1
0
    def get(self, request):
        if "iped" in request.GET and request.GET["iped"]:
            iped = request.GET["iped"]
            school = get_school(iped)
            if not school or not school.operating:
                error = "No active school could be found for iped ID {0}".format(iped)
                return HttpResponseBadRequest(error)
            if "oid" in request.GET:
                OID = request.GET["oid"]
            else:
                OID = ""
            if OID and validate_oid(OID) is False:
                return HttpResponseBadRequest(
                    "Offer ID has illegal characters;\
                    only 0-9 and a-f are allowed."
                )
            program_data = json.dumps({})
            program = ""
            if "pid" in request.GET and request.GET["pid"]:
                program_code = request.GET["pid"]
                programs = Program.objects.filter(program_code=request.GET["pid"], institution=school).order_by("-pk")
                if programs:
                    program = programs[0]
                    program_data = program.as_json()
            national_stats = nat_stats.get_prepped_stats(program_length=get_program_length(program, school))
            BLS_stats = nat_stats.get_bls_stats()
            if BLS_stats:
                categories = BLS_stats.keys()
                categories.remove("Year")
                if get_region(school):
                    region = get_region(school)
                    national_stats["region"] = REGION_NAMES[region]
                    for category in categories:
                        national_stats["regional{0}".format(category)] = BLS_stats[category][region]
                else:
                    national_stats["region"] = "Not available"
                    for category in categories:
                        national_stats["national{0}".format(category)] = BLS_stats[category]["average_annual"]

            return render_to_response(
                "worksheet.html",
                {
                    "data_js": "0",
                    "school": school,
                    "schoolData": school.as_json(),
                    "program": program,
                    "programData": program_data,
                    "nationalData": json.dumps(national_stats),
                    "oid": OID,
                    "base_template": BASE_TEMPLATE,
                    "url_root": URL_ROOT,
                },
                context_instance=RequestContext(request),
            )
        else:
            return HttpResponseBadRequest("URL doesn't contain a school ID")
Example #2
0
    def get(self, request):
        if 'iped' in request.GET and request.GET['iped']:
            iped = request.GET['iped']
            school = get_school(iped)
            if not school or not school.operating:
                error = "No active school could be found for iped ID {0}".format(iped)
                return HttpResponseBadRequest(error)
            if 'oid' in request.GET:
                OID = request.GET['oid']
            else:
                OID = ''
            if OID and validate_oid(OID) is False:
                return HttpResponseBadRequest("Offer ID has illegal characters;\
                    only 0-9 and a-f are allowed.")
            program_data = json.dumps({})
            program = ''
            if 'pid' in request.GET and request.GET['pid']:
                program_code = request.GET['pid']
                programs = Program.objects.filter(program_code=request.GET['pid'],
                                                     institution=school).order_by('-pk')
                if programs:
                    program = programs[0]
                    program_data = program.as_json()
            national_stats = nat_stats.get_prepped_stats(program_length=get_program_length(program, school))
            BLS_stats = nat_stats.get_bls_stats()
            if BLS_stats:
                categories = BLS_stats.keys()
                categories.remove('Year')
                if get_region(school):
                    region = get_region(school)
                    national_stats['region'] = REGION_NAMES[region]
                    for category in categories:
                        national_stats['regional{0}'.format(category)] = BLS_stats[category][region]
                else:
                    national_stats['region'] = "Not available"
                    for category in categories:
                        national_stats['national{0}'.format(category)] = BLS_stats[category]["average_annual"]


            return render_to_response('worksheet.html',
                                      {'data_js': "0",
                                       'school': school,
                                       'schoolData': school.as_json(),
                                       'program': program,
                                       'programData': program_data,
                                       'nationalData': json.dumps(national_stats),
                                       'oid': OID,
                                       'base_template': BASE_TEMPLATE,
                                       'url_root': URL_ROOT},
                                      context_instance=RequestContext(request))
        else:
            return HttpResponseBadRequest("URL doesn't contain a school ID")
Example #3
0
    def get(self, request):
        if 'iped' in request.GET and request.GET['iped']:
            try:
                school = School.objects.get(school_id=int(request.GET['iped']))
            except:
                error = "No school could be found for iped ID {0}".format(request.GET['iped'])
                return HttpResponseBadRequest(error)
            if 'oid' in request.GET:
                OID = request.GET['oid']
            else:
                OID = ''
            program_data = json.dumps({})
            program = ''
            if 'pid' in request.GET and request.GET['pid']:
                programs = Program.objects.filter(program_code=request.GET['pid'],
                                                     institution=school).order_by('-pk')
                if programs:
                    program = programs[0]
                    program_data = program.as_json()
            national_stats = nat_stats.get_prepped_stats(program_length=get_program_length(program, school))
            BLS_stats = nat_stats.get_bls_stats()
            if BLS_stats:
                categories = BLS_stats.keys()
                categories.remove('Year')
                if get_region(school):
                    region = get_region(school)
                    national_stats['region'] = REGION_NAMES[region]
                    for category in categories:
                        national_stats['regional{0}'.format(category)] = BLS_stats[category][region]
                else:
                    national_stats['region'] = "Not available"
                    for category in categories:
                        national_stats['national{0}'.format(category)] = BLS_stats[category]["average_annual"]


            return render_to_response('worksheet.html',
                                      {'data_js': "0",
                                       'school': school,
                                       'schoolData': school.as_json(),
                                       'program': program,
                                       'programData': program_data,
                                       'nationalData': json.dumps(national_stats),
                                       'oid': OID,
                                       'base_template': BASE_TEMPLATE,
                                       'url_root': URL_ROOT},
                                      context_instance=RequestContext(request))
        else:
            return HttpResponseBadRequest("URL doesn't contain a school ID")
Example #4
0
 def get_stats(self, school, programID):
     program = get_program(school, programID)
     national_stats = nat_stats.get_prepped_stats(program_length=get_program_length(program, school))
     BLS_stats = nat_stats.get_bls_stats()
     if BLS_stats:
         categories = BLS_stats.keys()
         categories.remove('Year')
         if get_region(school):
             region = get_region(school)
             national_stats['region'] = REGION_NAMES[region]
             for category in categories:
                 national_stats['regional{0}'.format(category)] = BLS_stats[category][region]
         else:
             national_stats['region'] = "Not available"
             for category in categories:
                 national_stats['national{0}'.format(category)] = BLS_stats[category]["average_annual"]
     return json.dumps(national_stats)
Example #5
0
 def get_stats(self, school, programID):
     program = get_program(school, programID)
     national_stats = nat_stats.get_prepped_stats(program_length=get_program_length(program, school))
     BLS_stats = nat_stats.get_bls_stats()
     if BLS_stats:
         categories = BLS_stats.keys()
         categories.remove("Year")
         if get_region(school):
             region = get_region(school)
             national_stats["region"] = REGION_NAMES[region]
             for category in categories:
                 national_stats["regional{0}".format(category)] = BLS_stats[category][region]
         else:
             national_stats["region"] = "Not available"
             for category in categories:
                 national_stats["national{0}".format(category)] = BLS_stats[category]["average_annual"]
     return json.dumps(national_stats)
Example #6
0
 def test_get_prepped_stats(self):
     stats = nat_stats.get_prepped_stats()
     self.assertTrue(stats['completionRateMedian'] <= 1)
Example #7
0
 def get_stats(self, school, programID):
     program = get_program(school, programID)
     national_stats = nat_stats.get_prepped_stats(
         program_length=get_program_length(program, school))
     return json.dumps(national_stats)
Example #8
0
 def get_stats(self, school, programID):
     program = get_program(school, programID)
     national_stats = nat_stats.get_prepped_stats(
         program_length=get_program_length(program, school)
     )
     return json.dumps(national_stats)
 def test_get_prepped_stats(self):
     stats = nat_stats.get_prepped_stats()
     self.assertTrue(stats['completionRateMedian'] <= 1)