コード例 #1
0
def proposition_dissertations_jury_new(request, pk):
    proposition = proposition_dissertation.find_by_id(pk)
    if proposition is None:
        return redirect('proposition_dissertations')
    count_proposition_role = PropositionRole.objects.filter(proposition_dissertation=proposition).count()
    adv = get_current_adviser(request)
    if proposition.author == adv or proposition.creator == adv.person:
        if request.method == "POST":
            form = ManagerPropositionRoleForm(request.POST)
            if form.is_valid():
                data = form.cleaned_data
                status = data['status']
                adv = data['adviser']
                prop = data['proposition_dissertation']
                if status == "PROMOTEUR":
                    proposition.set_author(adv)
                    proposition_role.delete(status, prop)
                    proposition_role.add(status, adv, prop)
                elif count_proposition_role < 4:
                    proposition_role.add(status, adv, prop)
                return redirect('proposition_dissertation_detail', pk=proposition.pk)
            else:
                form = ManagerPropositionRoleForm(initial={'proposition_dissertation': proposition})
        else:
            form = ManagerPropositionRoleForm(initial={'proposition_dissertation': proposition})
        return layout.render(request, 'proposition_dissertations_jury_edit.html', {'form': form})
    else:
        return redirect('proposition_dissertation_detail', pk=proposition.pk)
コード例 #2
0
def manager_proposition_dissertation_detail(request, pk):
    proposition = proposition_dissertation.find_by_id(pk)
    if proposition is None:
        return redirect('manager_proposition_dissertations')
    offer_propositions = proposition_offer.find_by_proposition_dissertation(proposition)
    person = mdl.person.find_by_user(request.user)
    adv = adviser.search_by_person(person)
    count_use = dissertation.count_by_proposition(proposition)
    percent = count_use * 100 / proposition.max_number_student if proposition.max_number_student else 0
    count_proposition_role = proposition_role.count_by_proposition(proposition)
    files = proposition_document_file.find_by_proposition(proposition)
    filename = ""
    for file in files:
        filename = file.document_file.file_name
    if count_proposition_role < 1:
        proposition_role.add('PROMOTEUR', proposition.author, proposition)
    proposition_roles = proposition_role.search_by_proposition(proposition)
    return layout.render(request, 'manager_proposition_dissertation_detail.html',
                         {'proposition_dissertation': proposition,
                          'offer_propositions': offer_propositions,
                          'adviser': adv,
                          'count_use': count_use,
                          'percent': round(percent, 2),
                          'proposition_roles': proposition_roles,
                          'count_proposition_role': count_proposition_role,
                          'filename': filename})
コード例 #3
0
def proposition_dissertation_detail(request, pk):
    subject = get_object_or_404(
        proposition_dissertation.PropositionDissertation, pk=pk)
    offer_propositions = proposition_offer.search_by_proposition_dissertation(
        subject)
    person = mdl.person.find_by_user(request.user)
    student = mdl.student.find_by_person(person)
    using = dissertation.count_by_proposition(subject)
    percent = using * 100 / subject.max_number_student if subject.max_number_student else 0
    count_proposition_role = proposition_role.count_by_proposition(subject)
    files = proposition_document_file.find_by_proposition(subject)
    filename = ""
    for file in files:
        filename = file.document_file.file_name
    if count_proposition_role < 1:
        proposition_role.add('PROMOTEUR', subject.author, subject)
    proposition_roles = proposition_role.search_by_proposition(subject)
    return layout.render(
        request, 'proposition_dissertation_detail.html', {
            'percent': round(percent, 2),
            'proposition_roles': proposition_roles,
            'proposition_dissertation': subject,
            'offer_propositions': offer_propositions,
            'student': student,
            'using': using,
            'filename': filename
        })
コード例 #4
0
def manager_proposition_dissertation_detail(request, pk):
    prefetch_propositions = return_prefetch_propositions()
    proposition = get_object_or_404(
        PropositionDissertation.objects.select_related(
            'author__person', 'creator').prefetch_related(
                prefetch_propositions,
                'offer_propositions__education_group__educationgroupyear_set',
                'propositionrole_set__adviser__person',
            ),
        pk=pk)
    adv = request.user.person.adviser
    count_use = dissertation.count_by_proposition(proposition)
    percent = count_use * 100 / proposition.max_number_student if proposition.max_number_student else 0
    count_proposition_role = proposition_role.count_by_proposition(proposition)
    files = proposition_document_file.find_by_proposition(proposition)
    filename = ""
    for file in files:
        filename = file.document_file.file_name
    if count_proposition_role < 1:
        proposition_role.add(dissertation_role_status.PROMOTEUR,
                             proposition.author, proposition)
    return render(
        request, 'manager_proposition_dissertation_detail.html', {
            'proposition_dissertation': proposition,
            'adviser': adv,
            'count_use': count_use,
            'percent': round(percent, 2),
            'count_proposition_role': count_proposition_role,
            'filename': filename
        })
コード例 #5
0
def proposition_dissertation_detail(request, pk):
    current_academic_year = academic_year.current_academic_year()

    prefetch_disserts = Prefetch(
        "dissertations",
        queryset=Dissertation.objects.filter(active=True).filter(
            education_group_year__academic_year=current_academic_year).exclude(
                status__in=(dissertation_status.DRAFT,
                            dissertation_status.DIR_KO)))
    prefetch_offer_propositions = return_prefetch_propositions()

    proposition = get_object_or_404(
        PropositionDissertation.objects.select_related(
            'author__person', 'creator').prefetch_related(
                prefetch_offer_propositions, prefetch_disserts,
                'propositionrole_set__adviser__person'),
        pk=pk)
    check_authorisation_of_proposition = autorized_proposition_dissert_promotor_or_manager_or_author(
        request.user, proposition)
    offer_propositions = proposition.offer_propositions.all()
    count_use = proposition.dissertations.all().count()
    percent = count_use * 100 / proposition.max_number_student if proposition.max_number_student else 0
    count_proposition_role = proposition.propositionrole_set.all().count()
    files = proposition_document_file.find_by_proposition(proposition)
    filename = ""
    for file in files:
        filename = file.document_file.file_name
    if count_proposition_role < 1:
        proposition_role.add(dissertation_role_status.PROMOTEUR,
                             proposition.author, proposition)
    proposition_roles = PropositionRole.objects.filter(proposition_dissertation=proposition) \
        .select_related('adviser__person')
    return render(
        request, 'proposition_dissertation_detail.html', {
            'proposition_dissertation': proposition,
            'check_authorisation_of_proposition':
            check_authorisation_of_proposition,
            'offer_propositions': offer_propositions,
            'adviser': get_current_adviser(request),
            'count_use': count_use,
            'percent': round(percent, 2),
            'proposition_roles': proposition_roles,
            'count_proposition_role': count_proposition_role,
            'filename': filename
        })
コード例 #6
0
def proposition_dissertation_detail(request, pk):
    subject = get_object_or_404(proposition_dissertation.PropositionDissertation, pk=pk)
    offer_propositions = proposition_offer.search_by_proposition_dissertation(subject)
    person = mdl.person.find_by_user(request.user)
    student = mdl.student.find_by_person(person)
    using = dissertation.count_by_proposition(subject)
    percent = using * 100 / subject.max_number_student if subject.max_number_student else 0
    count_proposition_role = proposition_role.count_by_proposition(subject)
    files = proposition_document_file.find_by_proposition(subject)
    filename = ""
    for file in files:
        filename = file.document_file.file_name
    if count_proposition_role < 1:
        proposition_role.add('PROMOTEUR', subject.author, subject)
    proposition_roles = proposition_role.search_by_proposition(subject)
    return layout.render(request, 'proposition_dissertation_detail.html',
                         {'percent': round(percent, 2),
                          'proposition_roles': proposition_roles,
                          'proposition_dissertation': subject,
                          'offer_propositions': offer_propositions,
                          'student': student,
                          'using': using,
                          'filename': filename})
コード例 #7
0
def proposition_dissertation_detail(request, pk):
    person = mdl.person.find_by_user(request.user)
    starting_academic_year = academic_year.starting_academic_year()
    subject = get_object_or_404(PropositionDissertation.objects.select_related(
        'author', 'author__person').prefetch_related(
            'propositionrole_set', 'propositionrole_set__adviser__person',
            'offer_propositions'),
                                pk=pk)
    offer_propositions = subject.offer_propositions.all().annotate(
        last_acronym=Subquery(
            EducationGroupYear.objects.filter(
                education_group__offer_proposition=OuterRef('pk'),
                academic_year=starting_academic_year).values('acronym')[:1]))

    student = mdl.student.find_by_person(person)
    using = dissertation.count_by_proposition(subject)
    percent = using * 100 / subject.max_number_student if subject.max_number_student else 0
    count_proposition_role = PropositionRole.objects.filter(
        proposition_dissertation=subject).count()
    files = PropositionDocumentFile.objects.filter(proposition=subject)
    filename = ""
    for file in files:
        filename = file.document_file.file_name
    if count_proposition_role < 1:
        proposition_role.add('PROMOTEUR', subject.author, subject)
    proposition_roles = subject.propositionrole_set.all()
    return render(
        request, 'proposition_dissertation_detail.html', {
            'percent': round(percent, 2),
            'proposition_roles': proposition_roles,
            'proposition_dissertation': subject,
            'offer_propositions': offer_propositions,
            'student': student,
            'using': using,
            'filename': filename
        })