def extra(request, edulevel_code): valid_form = True if request.method == "POST": form = ExtraForm(request.POST) if form.is_valid(): data = utils.expand_choices(form) request.session["extra"] = json.dumps(data) return HttpResponseRedirect( reverse("summary", args=[edulevel_code])) else: valid_form = False else: if request.session["extra"]: form = ExtraForm(json.loads(request.session["extra"])) elif settings.DEBUG: form = ExtraForm(EXTRA_DATA) else: form = ExtraForm() breadcrumbs, request.session["breadcrumbs"] = utils.add_breadcrumb( "Extra", reverse("extra", args=[edulevel_code]), request.session["breadcrumbs"]) return render( request, "form.html", { "title": "Otra información de interés", "form": form, "edulevel": EduLevel.objects.get(code=edulevel_code), "valid_form": valid_form, "breadcrumbs": breadcrumbs })
def auth_exit(request, edulevel_code): valid_form = True edulevel = EduLevel.objects.get(code=edulevel_code) if request.method == "POST": form = ExitAuthForm(edulevel.is_mandatory(), request.POST) if form.is_valid(): data = utils.expand_choices(form) request.session["auth_exit"] = json.dumps(data) return HttpResponseRedirect(reverse("extra", args=[edulevel_code])) else: valid_form = False else: if request.session["auth_exit"]: form = ExitAuthForm(edulevel.is_mandatory(), json.loads(request.session["auth_exit"])) else: form = ExitAuthForm(edulevel.is_mandatory()) breadcrumbs, request.session["breadcrumbs"] = utils.add_breadcrumb( "Salida", reverse("auth_exit", args=[edulevel_code]), request.session["breadcrumbs"]) return render( request, "form.html", { "title": "Autorizaciones de salida", "form": form, "edulevel": edulevel, "valid_form": valid_form, "breadcrumbs": breadcrumbs })
def academic(request, edulevel_code): AcademicForm = get_formclass(edulevel_code) valid_form = True if request.method == "POST": form = AcademicForm(request.POST) if form.is_valid(): training_itinerary = form.cleaned_data.get("training_itinerary") data = utils.expand_choices(form) request.session["academic"] = json.dumps(data) if training_itinerary: return HttpResponseRedirect( reverse("itinerary", args=[edulevel_code, training_itinerary])) elif json.loads(request.session["student"])["adult"]: return HttpResponseRedirect( reverse("extra", args=[edulevel_code])) else: return HttpResponseRedirect( reverse("family", args=[edulevel_code, 1])) else: valid_form = False else: if request.session["academic"]: form = AcademicForm(json.loads(request.session["academic"])) elif settings.DEBUG: form = AcademicForm(ACADEMIC_DATA[edulevel_code]["global"]) else: form = AcademicForm() breadcrumbs, request.session["breadcrumbs"] = utils.add_breadcrumb( "Académico", reverse("academic", args=[edulevel_code]), request.session["breadcrumbs"]) edulevel = EduLevel.objects.get(code=edulevel_code) if edulevel.is_vocational_training(): description = None else: description = """ Queremos aclarar que las elecciones de materias no son definitivas, y por lo tanto, pueden cambiar, en función de la disponibilidad asignada por la Dirección General de Personal ó de las ratios del alumnado, entre otros factores. """ return render( request, "form.html", { "title": "Información académica", "form": form, "edulevel": EduLevel.objects.get(code=edulevel_code), "valid_form": valid_form, "breadcrumbs": breadcrumbs, "description": description })
def summary(request, edulevel_code): config = Config.objects.first() data = utils.load_session_data(request.session, SECTIONS) breadcrumbs, request.session["breadcrumbs"] = utils.add_breadcrumb( "Resumen", reverse("summary", args=[edulevel_code]), request.session["breadcrumbs"]) return render( request, "summary.html", { "edulevel": EduLevel.objects.get(code=edulevel_code), "data": data, "breadcrumbs": breadcrumbs, "edulevels": EduLevel.objects.all(), "cancel_btn_msg": "Comenzar nueva matrícula", 'config': config })
def family(request, edulevel_code, responsible_id): valid_form = True key = "responsible{}".format(responsible_id) ResponsibleForm = get_formclass("R" + responsible_id) if request.method == "POST": form = ResponsibleForm(request.POST) if form.is_valid(): if form.cleaned_data.get("ignore_info"): data = {"ignore_info": True} else: data = utils.expand_choices(form) data = utils.add_fields_to_responsible(data) data["id"] = responsible_id request.session[key] = json.dumps(data, default=utils.json_dump_handler) if responsible_id == "1": return HttpResponseRedirect( reverse("family", args=[edulevel_code, 2])) elif responsible_id == "2": return HttpResponseRedirect( reverse("auth_pick", args=[edulevel_code])) else: valid_form = False else: if request.session[key]: form = ResponsibleForm(json.loads(request.session[key])) elif settings.DEBUG: form = ResponsibleForm(RESPONSIBLE_DATA[responsible_id]) else: form = ResponsibleForm() breadcrumbs, request.session["breadcrumbs"] = utils.add_breadcrumb( "Responsable " + responsible_id, reverse("family", args=[edulevel_code, responsible_id]), request.session["breadcrumbs"]) return render( request, "form.html", { "title": "Datos del responsable {}".format(responsible_id), "form": form, "edulevel": EduLevel.objects.get(code=edulevel_code), "valid_form": valid_form, "breadcrumbs": breadcrumbs })
def auth_pick(request, edulevel_code): valid_form = True responsibles_ids = utils.get_responsibles_ids(request.session) if request.method == "POST": form = PickAuthForm(responsibles_ids, request.POST) if form.is_valid(): data = utils.expand_choices(form) request.session["auth_pick"] = json.dumps(data) return HttpResponseRedirect( reverse("auth_exit", args=[edulevel_code])) else: valid_form = False else: if request.session["auth_pick"]: form = PickAuthForm(responsibles_ids, json.loads(request.session["auth_pick"])) elif settings.DEBUG: form = PickAuthForm(responsibles_ids, AUTH_DATA["pick"]) else: form = PickAuthForm(responsibles_ids) breadcrumbs, request.session["breadcrumbs"] = utils.add_breadcrumb( "Recogida", reverse("auth_pick", args=[edulevel_code]), request.session["breadcrumbs"]) return render( request, "form.html", { "title": "Personas autorizadas a recoger al alumno/a", "description": """ El alumnado menor de edad no puede salir del centro durante el período lectivo. En caso de que hubiera necesidad de recogerlo por algún motivo, sólo lo podrían hacer padre/madre/tutores legales, ó bien aquellas personas mayores de edad que fueran autorizadas en el siguiente formulario. Máximo de 4 personas. (No incluir aquí a los responsables). """, "form": form, "edulevel": EduLevel.objects.get(code=edulevel_code), "valid_form": valid_form, "breadcrumbs": breadcrumbs })
def student(request, edulevel_code): valid_form = True edulevel = EduLevel.objects.get(code=edulevel_code) if request.method == "POST": form = StudentForm(request.POST) if form.is_valid(): data = utils.expand_choices(form) data = utils.add_fields_to_student(data) request.session["student"] = json.dumps( data, default=utils.json_dump_handler) return HttpResponseRedirect( reverse("academic", args=[edulevel_code])) else: valid_form = False else: if request.session["student"]: form = StudentForm(json.loads(request.session["student"])) elif settings.DEBUG: form = StudentForm(STUDENT_DATA) else: form = StudentForm(edulevel=edulevel) breadcrumbs, request.session["breadcrumbs"] = utils.add_breadcrumb( "Alumno/a", reverse("student", args=[edulevel_code]), request.session["breadcrumbs"], ) return render( request, "form.html", { "title": "Datos personales del alumno/a", "form": form, "edulevel": edulevel, "valid_form": valid_form, "breadcrumbs": breadcrumbs })