Ejemplo n.º 1
0
 def test_manager_dissert_jury_new_by_ajax1(self):
     self.client.force_login(self.manager.person.user)
     dissert_role_count = dissertation_role.count_by_dissertation(
         self.dissertation_1)
     response = self.client.post(
         '/dissertation/manager_dissertations_jury_new_ajax/',
         {'pk_dissertation': str(self.dissertation_1.id)})
     self.assertEqual(response.status_code, ERROR_405_BAD_REQUEST)
     response = self.client.get(
         '/dissertation/manager_dissertations_jury_new_ajax/',
         {'pk_dissertation': str(self.dissertation_1.id)})
     self.assertEqual(response.status_code, ERROR_405_BAD_REQUEST)
     response = self.client.post(
         '/dissertation/manager_dissertations_jury_new_ajax/', {
             'pk_dissertation': str(self.dissertation_1.id),
             'status_choice': 'READER'
         })
     self.assertEqual(response.status_code, ERROR_405_BAD_REQUEST)
     response = self.client.post(
         '/dissertation/manager_dissertations_jury_new_ajax/', {
             'pk_dissertation': str(self.dissertation_1.id),
             'status_choice': 'READER',
             'adviser_pk': str(self.teacher.id)
         })
     self.assertEqual(response.status_code, HTTP_OK)
     self.assertEqual(
         dissert_role_count + 1,
         dissertation_role.count_by_dissertation(self.dissertation_1))
Ejemplo n.º 2
0
 def test_manager_dissert_jury_del_by_ajax(self):
     self.client.force_login(self.manager.person.user)
     response = self.client.post('/dissertation/manager_dissertations_jury_new_ajax/',
                                 {'pk_dissertation': str(self.dissertation_1.id),
                                  'status_choice': 'READER',
                                  'adviser_pk': str(self.teacher.id)})
     self.assertEqual(response.status_code, HTTP_OK)
     liste_dissert_roles = dissertation_role.search_by_dissertation_and_role(self.dissertation_1, 'READER')
     self.assertNotEqual(len(liste_dissert_roles),0)
     for element in liste_dissert_roles:
         dissert_role_count = dissertation_role.count_by_dissertation(self.dissertation_1)
         url = "/dissertation/manager_dissertations_role_delete_by_ajax/{role}"
         response2 = self.client.get(url.format(role=str(element.id)))
         self.assertEqual(response2.status_code, HTTP_OK)
         self.assertEqual(dissertation_role.count_by_dissertation(self.dissertation_1), dissert_role_count-1)
Ejemplo n.º 3
0
def manager_dissertations_jury_new_ajax(request):
    pk_dissert = request.POST.get("pk_dissertation", '')
    status_choice = request.POST.get("status_choice", '')
    id_adviser_of_dissert_role = request.POST.get("adviser_pk", '')
    if not id_adviser_of_dissert_role or not status_choice or not pk_dissert:
        return HttpResponse(status=status.HTTP_405_METHOD_NOT_ALLOWED)
    else:
        dissert = dissertation.find_by_id(pk_dissert)
        adviser_of_dissert_role = adviser.get_by_id(
            int(id_adviser_of_dissert_role))
        count_dissertation_role = dissertation_role.count_by_dissertation(
            dissert)
        person = mdl.person.find_by_user(request.user)
        adv_manager = adviser.search_by_person(person)
        if adviser_can_manage(dissert, adv_manager) \
                and count_dissertation_role < MAX_DISSERTATION_ROLE_FOR_ONE_DISSERTATION and dissert.status != 'DRAFT' \
                and adviser_of_dissert_role is not None and dissert is not None:
            justification = "%s %s %s" % (_("Manager add jury"), status_choice,
                                          adviser_of_dissert_role)
            dissertation_update.add(request,
                                    dissert,
                                    dissert.status,
                                    justification=justification)
            dissertation_role.add(status_choice, adviser_of_dissert_role,
                                  dissert)
            return HttpResponse(status=status.HTTP_200_OK)
        else:
            return HttpResponse(status=status.HTTP_403_FORBIDDEN)
Ejemplo n.º 4
0
def dissertation_jury_new(request, pk):
    dissert = get_object_or_404(dissertation.Dissertation, pk=pk)
    if dissert.author_is_logged_student(request):
        count_dissertation_role = dissertation_role.count_by_dissertation(
            dissert)
        count_reader = dissertation_role.count_reader_by_dissertation(dissert)
        offer_pro = offer_proposition.search_by_offer(
            dissert.offer_year_start.offer)
        if offer_pro.student_can_manage_readers and count_dissertation_role < 5 and count_reader < 3:
            if request.method == "POST":
                form = DissertationRoleForm(request.POST)
                if form.is_valid():
                    data = form.cleaned_data
                    if not dissertation_role.count_by_status_student_dissertation(
                            data['status'], data['adviser'],
                            data['dissertation']):
                        form.save()
                        justification = "%s %s" % ("student_add_reader",
                                                   data['adviser'])
                        dissertation_update.add(request,
                                                dissert,
                                                dissert.status,
                                                justification=justification)
                return redirect('dissertation_detail', pk=dissert.pk)
            else:
                form = DissertationRoleForm(initial={
                    'status': "READER",
                    'dissertation': dissert
                })
                return layout.render(request, 'dissertation_reader_edit.html',
                                     {'form': form})
        else:
            return redirect('dissertation_detail', pk=dissert.pk)
    else:
        return redirect('dissertations')
Ejemplo n.º 5
0
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)
Ejemplo n.º 6
0
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')
Ejemplo n.º 7
0
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')
Ejemplo n.º 8
0
def dissertation_jury_new(request, pk):
    dissert = get_object_or_404(dissertation.Dissertation, pk=pk)
    if dissert.author_is_logged_student(request):
        count_dissertation_role = dissertation_role.count_by_dissertation(dissert)
        count_reader = dissertation_role.count_reader_by_dissertation(dissert)
        offer_pro = offer_proposition.search_by_offer(dissert.offer_year_start.offer)
        if offer_pro.student_can_manage_readers and count_dissertation_role < 5 and count_reader < 3:
            if request.method == "POST":
                form = DissertationRoleForm(request.POST)
                if form.is_valid():
                    data = form.cleaned_data
                    if not dissertation_role.count_by_status_student_dissertation(data['status'],
                                                                                  data['adviser'],
                                                                                  data['dissertation']):
                        form.save()
                        justification = "%s %s" % ("student_add_reader", data['adviser'])
                        dissertation_update.add(request, dissert, dissert.status, justification=justification)
                return redirect('dissertation_detail', pk=dissert.pk)
            else:
                form = DissertationRoleForm(initial={'status': "READER", 'dissertation': dissert})
                return layout.render(request, 'dissertation_reader_edit.html', {'form': form})
        else:
            return redirect('dissertation_detail', pk=dissert.pk)
    else:
        return redirect('dissertations')
Ejemplo n.º 9
0
def manager_dissertations_jury_new_ajax(request):
    pk_dissert = request.POST.get("pk_dissertation", '')
    status_choice = request.POST.get("status_choice", '')
    id_adviser_of_dissert_role = request.POST.get("adviser_pk", '')
    if not id_adviser_of_dissert_role or not status_choice or not pk_dissert:
        return HttpResponse(status=ERROR_405_BAD_REQUEST)
    else:
        dissert = dissertation.find_by_id(pk_dissert)
        adviser_of_dissert_role = adviser.get_by_id(
            int(id_adviser_of_dissert_role))
        count_dissertation_role = dissertation_role.count_by_dissertation(
            dissert)
        person = mdl.person.find_by_user(request.user)
        adv_manager = adviser.search_by_person(person)
        if adviser_can_manage(dissert, adv_manager) and count_dissertation_role < 4 and dissert.status != 'DRAFT' \
                and adviser_of_dissert_role is not None and dissert is not None:
            justification = "%s %s %s" % ("manager_add_jury", status_choice,
                                          adviser_of_dissert_role)
            dissertation_update.add(request,
                                    dissert,
                                    dissert.status,
                                    justification=justification)
            dissertation_role.add(status_choice, adviser_of_dissert_role,
                                  dissert)
            return HttpResponse(status=HTTP_OK)
        else:
            return HttpResponse(status=ERROR_403_NOT_FORBIDDEN)
 def test_func(self):
     dissert = self.dissertation
     count_dissertation_role = dissertation_role.count_by_dissertation(
         dissert)
     count_reader = dissertation_role.count_reader_by_dissertation(dissert)
     offer_pro = offer_proposition.get_by_education_group(
         dissert.education_group_year.education_group)
     return offer_pro.student_can_manage_readers and count_dissertation_role < 5 and count_reader < 3
Ejemplo n.º 11
0
 def test_func(self):
     dissert = self.dissertation
     count_dissertation_role = dissertation_role.count_by_dissertation(
         dissert)
     offer_prop = offer_proposition.get_by_dissertation(dissert)
     if offer_prop is not None:
         if adviser.is_teacher(self.request.user):
             return offer_prop.adviser_can_suggest_reader \
                 and count_dissertation_role < MAX_DISSERTATION_ROLE_FOR_ONE_DISSERTATION
         if adviser.is_manager(self.request.user):
             return count_dissertation_role < MAX_DISSERTATION_ROLE_FOR_ONE_DISSERTATION \
                    and dissert.status != 'DRAFT'
Ejemplo n.º 12
0
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')
Ejemplo n.º 13
0
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')
Ejemplo n.º 14
0
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
        })
Ejemplo n.º 15
0
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')
def dissertation_detail(request, pk):
    person = request.user.person
    student = mdl.student.find_by_person(person)
    current_ac_year = academic_year.starting_academic_year()
    dissert = get_object_or_404(Dissertation.objects.select_related(
        'author', 'author__person', 'proposition_dissertation__author__person',
        'location').prefetch_related(
            'dissertationrole_set', 'dissertationrole_set__adviser__person',
            'proposition_dissertation__offer_propositions'),
                                pk=pk)
    if dissert.author_is_logged_student(request):
        student_offer_enrollments = OfferEnrollment.objects.filter(
            student=student,
            education_group_year__academic_year=current_ac_year,
            enrollment_state__in=[
                offer_enrollment_state.SUBSCRIBED,
                offer_enrollment_state.PROVISORY
            ]).values_list('id', flat=True)
        educ_group = dissert.education_group_year.education_group
        offer_pro = offer_proposition.get_by_education_group(educ_group)
        offer_propositions = dissert.proposition_dissertation.offer_propositions.filter(
            education_group__educationgroupyear__offerenrollment__id__in=
            student_offer_enrollments).annotate(last_acronym=Subquery(
                EducationGroupYear.objects.filter(
                    education_group__offer_proposition=OuterRef('pk'),
                    academic_year=current_ac_year).values('acronym')[:1]))
        count = dissertation.count_disser_submit_by_student_in_educ_group(
            student, educ_group)

        files = DissertationDocumentFile.objects.filter(dissertation=dissert)
        filename = ""
        for file in files:
            filename = file.document_file.file_name

        count_dissertation_role = dissertation_role.count_by_dissertation(
            dissert)
        count_reader = dissertation_role.count_reader_by_dissertation(dissert)
        count_proposition_role = PropositionRole.objects.filter(
            proposition_dissertation=dissert.proposition_dissertation).count()
        proposition_roles = PropositionRole.objects.filter(
            proposition_dissertation=dissert.proposition_dissertation)
        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(dissertation_role_status.PROMOTEUR,
                                      dissert.proposition_dissertation.author,
                                      dissert)
            else:
                for role in proposition_roles:
                    dissertation_role.add(role.status, role.adviser, dissert)
        dissertation_roles = dissert.dissertationrole_set.all()
        return render(
            request, 'dissertation_detail.html', {
                'check_edit': check_edit,
                'count': count,
                'count_reader': count_reader,
                'count_dissertation_role': count_dissertation_role,
                'dissertation': dissert,
                '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')