def class_teacher_subjectroom_chart_get(request, classteacher_id, classroom_id): statsd.increment('core.hits.chart.class_teacher_subjectroom') try: classteacher = get_object_or_404(User, pk=classteacher_id) except Http404, e: return Json404Response(e)
def single_focus_student_chart_get(request, student_id, focusroom_id): statsd.increment('core.hits.chart.single_focus_student') try: student = get_object_or_404(User, pk=student_id) except Http404, e: return Json404Response(e)
def subject_teacher_subjectroom_chart_get(request, subjectteacher_id): statsd.increment('core.hits.chart.subject_teacher_subjectroom') try: subjectteacher = get_object_or_404(User, pk=subjectteacher_id) except Http404, e: return Json404Response(e)
def teacher_endpoint(self): if (is_student_classteacher_relationship( self.student, self.user)) or (self.subjectroom.teacher == self.user): return HWCentralJsonResponse( StudentEdgeData(self.student, self.subjectroom)) return Json404Response()
def standard_assignment_chart_get(request, assignment_id): statsd.increment('core.hits.chart.standard_assignment') try: assignment = get_object_or_404(Assignment, pk=assignment_id) if is_student_assignment(assignment): raise Http404 except Http404, e: return Json404Response(e)
def student_id_get(request, student_id, subjectroom_id): statsd.increment('edge.hits.get.student_id') try: student = get_object_or_404(User, pk=student_id) if student.userinfo.group != HWCentralGroup.refs.STUDENT and student.userinfo.group != HWCentralGroup.refs.OPEN_STUDENT: raise Http404 subjectroom = get_object_or_404(SubjectRoom, pk=subjectroom_id) if not is_subjectroom_student_relationship(subjectroom, student): raise Http404 except Http404, e: return Json404Response(e)
def assignment_chart_get(request, assignment_id): statsd.increment('core.hits.chart.assignment') try: assignment = get_object_or_404(Assignment, pk=assignment_id) if is_practice_assignment(assignment): raise Http404 # allow for open assignments if they are corrected elif is_open_assignment(assignment): if not is_corrected_open_assignment(assignment): raise Http404 else: # non-student assignment: only allow for corrected assignments if not is_assignment_corrected(assignment): raise Http404 except Http404, e: return Json404Response(e)
def admin_endpoint(self): # validation - the logged in admin should only see the focusroom chart if focusroom belongs to same school if self.user.userinfo.school != self.focusroom.subjectRoom.classRoom.school: return Json404Response() return self.single_focusroom_data()
def open_student_chart_data(self): return Json404Response()
def subject_id_get(request, subjectroom_id): statsd.increment('edge.hits.get.subject_id') try: subjectroom = get_object_or_404(SubjectRoom, pk=subjectroom_id) except Http404, e: return Json404Response(e)
def focusroom_chart_get(request, focusroom_id): statsd.increment('core.hits.chart.focusroom') try: focusroom = get_object_or_404(FocusRoom, pk=focusroom_id) except Http404, e: return Json404Response(e)
raise Http404 else: raise InvalidHWCentralAssignmentTypeError(assignment_type) @login_required @statsd.timed('core.chart.student') def student_chart_get(request, student_id): statsd.increment('core.hits.chart.student') try: student = get_object_or_404(User, pk=student_id) except Http404, e: return Json404Response(e) if student.userinfo.group != HWCentralGroup.refs.STUDENT and student.userinfo.group != HWCentralGroup.refs.OPEN_STUDENT: return Json404Response() return StudentChartGet(request, student).handle() @login_required @statsd.timed('core.chart.single_subject_student') def single_subject_student_chart_get(request, student_id, subjectroom_id): statsd.increment('core.hits.chart.single_subject_student') try: student = get_object_or_404(User, pk=student_id) except Http404, e: return Json404Response(e) try: subjectroom = get_object_or_404(SubjectRoom, pk=subjectroom_id)
def parent_endpoint(self): if not is_parent_child_relationship(self.user, self.student): return Json404Response() return HWCentralJsonResponse( StudentEdgeData(self.student, self.subjectroom))
def student_endpoint(self): if self.user != self.student: return Json404Response() return HWCentralJsonResponse( StudentEdgeData(self.student, self.subjectroom))