def dissertations_detail(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) if teacher_can_see_dissertation(adv, dissert): count_dissertation_role = dissertation_role.count_by_dissertation(dissert) offer_prop = offer_proposition.get_by_dissertation(dissert) if offer_prop is None: return redirect('dissertations_list') promotors_count = dissertation_role.count_by_status_dissertation('PROMOTEUR', dissert) files = dissertation_document_file.find_by_dissertation(dissert) filename = "" for file in files: filename = file.document_file.file_name dissertation_roles = dissertation_role.search_by_dissertation(dissert) return layout.render(request, 'dissertations_detail.html', {'dissertation': dissert, 'adviser': adv, 'dissertation_roles': dissertation_roles, 'count_dissertation_role': count_dissertation_role, 'offer_prop': offer_prop, 'promotors_count': promotors_count, 'teacher_is_promotor': teacher_is_promotor(adv, dissert), 'filename': filename}) else: return redirect('dissertations_list')
def dissertation_detail(request, pk): memory = get_object_or_404(dissertation.Dissertation, pk=pk) person = mdl.person.find_by_user(request.user) student = mdl.student.find_by_person(person) if memory.author_is_logged_student(request): off = memory.offer_year_start.offer offer_pro = offer_proposition.search_by_offer(off) offer_propositions = proposition_offer.search_by_proposition_dissertation( memory.proposition_dissertation) count = dissertation.count_submit_by_user(student, off) files = dissertation_document_file.find_by_dissertation(memory) filename = "" for file in files: filename = file.document_file.file_name count_dissertation_role = dissertation_role.count_by_dissertation( memory) count_reader = dissertation_role.count_reader_by_dissertation(memory) count_proposition_role = proposition_role.count_by_dissertation(memory) proposition_roles = proposition_role.search_by_dissertation(memory) jury_visibility = offer_pro.start_jury_visibility <= timezone.now( ).date() <= offer_pro.end_jury_visibility check_edit = offer_pro.start_edit_title <= timezone.now().date( ) <= offer_pro.end_edit_title if count_dissertation_role == 0: if count_proposition_role == 0: dissertation_role.add('PROMOTEUR', memory.proposition_dissertation.author, memory) else: for role in proposition_roles: dissertation_role.add(role.status, role.adviser, memory) dissertation_roles = dissertation_role.search_by_dissertation(memory) return layout.render( request, 'dissertation_detail.html', { 'check_edit': check_edit, 'count': count, 'count_reader': count_reader, 'count_dissertation_role': count_dissertation_role, 'dissertation': memory, 'dissertation_roles': dissertation_roles, 'jury_visibility': jury_visibility, 'manage_readers': offer_pro.student_can_manage_readers, 'filename': filename, 'offer_propositions': offer_propositions }) else: return redirect('dissertations')
def dissertation_detail(request, pk): memory = get_object_or_404(dissertation.Dissertation, pk=pk) person = mdl.person.find_by_user(request.user) student = mdl.student.find_by_person(person) if memory.author_is_logged_student(request): off = memory.offer_year_start.offer offer_pro = offer_proposition.search_by_offer(off) offer_propositions = proposition_offer.search_by_proposition_dissertation(memory.proposition_dissertation) count = dissertation.count_submit_by_user(student, off) files = dissertation_document_file.find_by_dissertation(memory) filename = "" for file in files: filename = file.document_file.file_name count_dissertation_role = dissertation_role.count_by_dissertation(memory) count_reader = dissertation_role.count_reader_by_dissertation(memory) count_proposition_role = proposition_role.count_by_dissertation(memory) proposition_roles = proposition_role.search_by_dissertation(memory) jury_visibility = offer_pro.start_jury_visibility <= timezone.now().date() <= offer_pro.end_jury_visibility check_edit = offer_pro.start_edit_title <= timezone.now().date() <= offer_pro.end_edit_title if count_dissertation_role == 0: if count_proposition_role == 0: dissertation_role.add('PROMOTEUR', memory.proposition_dissertation.author, memory) else: for role in proposition_roles: dissertation_role.add(role.status, role.adviser, memory) dissertation_roles = dissertation_role.search_by_dissertation(memory) return layout.render(request, 'dissertation_detail.html', {'check_edit': check_edit, 'count': count, 'count_reader': count_reader, 'count_dissertation_role': count_dissertation_role, 'dissertation': memory, 'dissertation_roles': dissertation_roles, 'jury_visibility': jury_visibility, 'manage_readers': offer_pro.student_can_manage_readers, 'filename': filename, 'offer_propositions': offer_propositions}) else: return redirect('dissertations')
def manager_dissertations_detail(request, pk): dissert = dissertation.find_by_id(pk) if dissert is None: return redirect('manager_dissertations_list') person = mdl.person.find_by_user(request.user) adv = adviser.search_by_person(person) count_dissertation_role = dissertation_role.count_by_dissertation(dissert) count_proposition_role = proposition_role.count_by_dissertation(dissert) proposition_roles = proposition_role.search_by_dissertation(dissert) offer_prop = offer_proposition.get_by_dissertation(dissert) if offer_prop is None: return redirect('manager_dissertations_list') files = dissertation_document_file.find_by_dissertation(dissert) filename = files.last().document_file.file_name if files else "" if count_proposition_role == 0 and count_dissertation_role == 0: justification = "%s %s %s" % ( _("Auto add jury"), dissertation_role_status.PROMOTEUR, str(dissert.proposition_dissertation.author)) dissertation_update.add(request, dissert, dissert.status, justification=justification) dissertation_role.add(dissertation_role_status.PROMOTEUR, dissert.proposition_dissertation.author, dissert) elif count_dissertation_role == 0: for role in proposition_roles: justification = "%s %s %s" % (_("Auto add jury"), role.status, str(role.adviser)) dissertation_update.add(request, dissert, dissert.status, justification=justification) dissertation_role.add(role.status, role.adviser, dissert) if dissert.status == dissertation_status.DRAFT: jury_manager_visibility = True jury_manager_can_edit = False jury_manager_message = _( "Dissertation status is draft, managers can't edit jury.") jury_teacher_visibility = False jury_teacher_can_edit = False jury_teacher_message = _( "Dissertation status is draft, teachers can't edit jury.") jury_student_visibility = True jury_student_can_edit = offer_prop.student_can_manage_readers if jury_student_can_edit: jury_student_message = _( 'Dissertation status is draft, student can manage readers') else: jury_student_message = _( "Dissertation status is draft, student can't manage readers") else: jury_manager_visibility = True jury_manager_can_edit = True jury_manager_message = _('Managers can see and edit jury.') jury_teacher_visibility = True jury_teacher_can_edit = offer_prop.adviser_can_suggest_reader if jury_teacher_can_edit: jury_teacher_message = _('Teachers can see and edit jury.') else: jury_teacher_message = _('Teachers can see jury but not edit it.') jury_student_visibility = offer_prop.in_periode_jury_visibility jury_student_can_edit = False if jury_student_visibility: jury_student_message = _( 'Jury is currently visible for the student') else: jury_student_message = _( 'Jury is currently invisible for the student') dissertation_roles = dissertation_role.search_by_dissertation(dissert) promotors_count = dissertation_role.count_by_status_dissertation( dissertation_role_status.PROMOTEUR, dissert) return render( request, 'manager_dissertations_detail.html', { 'dissertation': dissert, 'adviser': adv, 'dissertation_roles': dissertation_roles, 'count_dissertation_role': count_dissertation_role, 'jury_manager_visibility': jury_manager_visibility, 'jury_manager_can_edit': jury_manager_can_edit, 'jury_manager_message': jury_manager_message, 'jury_teacher_visibility': jury_teacher_visibility, 'jury_teacher_can_edit': jury_teacher_can_edit, 'jury_teacher_message': jury_teacher_message, 'jury_student_visibility': jury_student_visibility, 'jury_student_can_edit': jury_student_can_edit, 'jury_student_message': jury_student_message, 'promotors_count': promotors_count, 'filename': filename })
def manager_dissertations_detail(request, pk): dissert = dissertation.find_by_id(pk) if dissert is None: return redirect('manager_dissertations_list') person = mdl.person.find_by_user(request.user) adv = adviser.search_by_person(person) if adviser_can_manage(dissert,adv): count_dissertation_role = dissertation_role.count_by_dissertation(dissert) count_proposition_role = proposition_role.count_by_dissertation(dissert) proposition_roles = proposition_role.search_by_dissertation(dissert) offer_prop = offer_proposition.get_by_dissertation(dissert) if offer_prop is None: return redirect('manager_dissertations_list') files = dissertation_document_file.find_by_dissertation(dissert) filename = "" for file in files: filename = file.document_file.file_name if count_proposition_role == 0: if count_dissertation_role == 0: justification = "%s %s %s" % ("auto_add_jury", 'PROMOTEUR', str(dissert.proposition_dissertation.author)) dissertation_update.add(request, dissert, dissert.status, justification=justification) dissertation_role.add('PROMOTEUR', dissert.proposition_dissertation.author, dissert) else: if count_dissertation_role == 0: for role in proposition_roles: justification = "%s %s %s" % ("auto_add_jury", role.status, str(role.adviser)) dissertation_update.add(request, dissert, dissert.status, justification=justification) dissertation_role.add(role.status, role.adviser, dissert) if dissert.status == "DRAFT": jury_manager_visibility = True jury_manager_can_edit = False jury_manager_message = 'manager_jury_draft' jury_teacher_visibility = False jury_teacher_can_edit = False jury_teacher_message = 'teacher_jury_draft' jury_student_visibility = True jury_student_can_edit = offer_prop.student_can_manage_readers if jury_student_can_edit: jury_student_message = 'student_jury_draft_can_edit_param' else: jury_student_message = 'student_jury_draft_no_edit_param' else: jury_manager_visibility = True jury_manager_can_edit = True jury_manager_message = 'manager_jury_editable' jury_teacher_visibility = True jury_teacher_can_edit = offer_prop.adviser_can_suggest_reader if jury_teacher_can_edit: jury_teacher_message = 'teacher_jury_visible_editable_parameter' else: jury_teacher_message = 'teacher_jury_visible_not_editable_parameter' jury_student_visibility = offer_prop.in_periode_jury_visibility jury_student_can_edit = False if jury_student_visibility: jury_student_message = 'student_jury_visible_dates' else: jury_student_message = 'student_jury_invisible_dates' dissertation_roles = dissertation_role.search_by_dissertation(dissert) promotors_count = dissertation_role.count_by_status_dissertation('PROMOTEUR', dissert) return layout.render(request, 'manager_dissertations_detail.html', {'dissertation': dissert, 'adviser': adv, 'dissertation_roles': dissertation_roles, 'count_dissertation_role': count_dissertation_role, 'jury_manager_visibility': jury_manager_visibility, 'jury_manager_can_edit': jury_manager_can_edit, 'jury_manager_message': jury_manager_message, 'jury_teacher_visibility': jury_teacher_visibility, 'jury_teacher_can_edit': jury_teacher_can_edit, 'jury_teacher_message': jury_teacher_message, 'jury_student_visibility': jury_student_visibility, 'jury_student_can_edit': jury_student_can_edit, 'jury_student_message': jury_student_message, 'promotors_count': promotors_count, 'filename': filename}) else: return redirect('manager_dissertations_list')