def manager_dissertations_jury_new(request, pk): dissert = dissertation.find_by_id(pk) if dissert is None: return redirect('manager_dissertations_list') count_dissertation_role = dissertation_role.count_by_dissertation(dissert) person = mdl.person.find_by_user(request.user) adv = adviser.search_by_person(person) if adviser_can_manage(dissert,adv): if count_dissertation_role < 4 and dissert.status != 'DRAFT': if request.method == "POST": form = ManagerDissertationRoleForm(request.POST) if form.is_valid(): data = form.cleaned_data status = data['status'] adv = data['adviser'] diss = data['dissertation'] justification = "%s %s %s" % ("manager_add_jury", str(status), str(adv)) dissertation_update.add(request, dissert, dissert.status, justification=justification) dissertation_role.add(status, adv, diss) return redirect('manager_dissertations_detail', pk=dissert.pk) else: form = ManagerDissertationRoleForm(initial={'dissertation': dissert}) else: form = ManagerDissertationRoleForm(initial={'dissertation': dissert}) return layout.render(request, 'manager_dissertations_jury_edit.html', {'form': form, 'dissert': dissert}) else: return redirect('manager_dissertations_detail', pk=dissert.pk) else: return redirect('manager_dissertations_list')
def dissertations_jury_new(request, pk): dissert = dissertation.find_by_id(pk) if dissert is None: return redirect('dissertations_list') person = mdl.person.find_by_user(request.user) adv = adviser.search_by_person(person) offer_prop = offer_proposition.get_by_dissertation(dissert) if offer_prop is not None and teacher_is_promotor(adv, dissert): count_dissertation_role = dissertation_role.count_by_dissertation(dissert) if count_dissertation_role < 4 and offer_prop.adviser_can_suggest_reader: if request.method == "POST": form = ManagerDissertationRoleForm(request.POST) if form.is_valid(): data = form.cleaned_data status = data['status'] adv = data['adviser'] diss = data['dissertation'] justification = "%s %s %s" % ("teacher_add_jury", str(status), str(adv)) dissertation_update.add(request, dissert, dissert.status, justification=justification) dissertation_role.add(status, adv, diss) return redirect('dissertations_detail', pk=dissert.pk) else: form = ManagerDissertationRoleForm(initial={'dissertation': dissert}) else: form = ManagerDissertationRoleForm(initial={'dissertation': dissert}) return layout.render(request, 'dissertations_jury_edit.html', {'form': form, 'dissert': dissert}) return redirect('dissertations_detail', pk=dissert.pk)
def manager_dissertations_jury_edit(request, pk): dissert_role = dissertation_role.find_by_id(pk) if dissert_role is None: return redirect('dissertations_list') if request.method == "POST": form = ManagerDissertationRoleForm(request.POST, instance=dissert_role) if form.is_valid(): form.save() return redirect('manager_dissertations_detail', pk=dissert_role.dissertation.pk) else: form = ManagerDissertationRoleForm(instance=dissert_role) return render(request, 'manager_dissertations_jury_edit.html', {'form': form})
def manager_dissertations_jury_edit(request, pk): dissert_role = dissertation_role.find_by_id(pk) redirect_if_none(dissert_role,'manager_dissertations_list') person = mdl.person.find_by_user(request.user) adv = adviser.search_by_person(person) if adviser_can_manage(dissert_role.dissertation,adv): if request.method == "POST": form = ManagerDissertationRoleForm(request.POST, instance=dissert_role) if form.is_valid(): form.save() return redirect('manager_dissertations_detail', pk=dissert_role.dissertation.pk) else: form = ManagerDissertationRoleForm(instance=dissert_role) return layout.render(request, 'manager_dissertations_jury_edit.html', {'form': form}) else: return redirect('manager_dissertations_list')