示例#1
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')
示例#2
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')
 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
示例#4
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')
示例#5
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')
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')