Пример #1
0
 def get_context_data(self, **kwargs):
     context = super().get_context_data(**kwargs)
     user = self.request.user
     context["school_year"] = SchoolYear.get_current_year_for(user)
     context["roster"] = []
     for student in Student.objects.filter(school=user.school):
         context["roster"].append({
             "student":
             student,
             "is_enrolled":
             Enrollment.is_student_enrolled(student,
                                            context["school_year"]),
         })
     return context
Пример #2
0
 def get_context_data(self, **kwargs):
     context = super().get_context_data(**kwargs)
     user = self.request.user
     context["school_year"] = SchoolYear.get_current_year_for(user)
     context["roster"] = []
     for student in Student.objects.filter(school=user.school):
         context["roster"].append({
             "student":
             student,
             "enrollment":
             Enrollment.objects.filter(
                 student=student,
                 grade_level__school_year=context["school_year"]).
             select_related("grade_level").first(),
         })
     return context
Пример #3
0
    def get_form_kwargs(self):
        kwargs = super().get_form_kwargs()
        school_year_id = self.request.GET.get("school_year")

        school_year = None
        if school_year_id:
            school_year = SchoolYear.objects.filter(
                school__admin=self.request.user, id=school_year_id).first()

        if not school_year:
            school_year = SchoolYear.get_current_year_for(self.request.user)

        if not school_year:
            raise NoSchoolYearError()

        kwargs["school_year"] = school_year
        return kwargs
Пример #4
0
    def get_form_kwargs(self):
        kwargs = super().get_form_kwargs()
        school_year_uuid = self.request.GET.get("school_year")

        school_year = None
        if school_year_uuid:
            try:
                school_year = SchoolYear.objects.filter(
                    school__admin=self.request.user,
                    uuid=school_year_uuid).first()
            except ValidationError:
                # Bogus uuid. Let it slide.
                pass

        if not school_year:
            school_year = SchoolYear.get_current_year_for(self.request.user)

        if not school_year:
            raise NoSchoolYearError()

        kwargs["school_year"] = school_year
        return kwargs