Ejemplo n.º 1
0
def proposition_dissertation_edit(request, pk):
    proposition = proposition_dissertation.find_by_id(pk)
    if proposition is None:
        return redirect('proposition_dissertations')
    adv = get_current_adviser(request)
    offer_propositions = offer_proposition.find_all_ordered_by_acronym()
    offer_propositions_group = offer_proposition_group.find_all_ordered_by_name_short()
    offer_propositions_error = None
    proposition_offers = proposition_offer.find_by_proposition_dissertation(proposition)
    if proposition.author == adv or proposition.creator == adv.person:
        if request.method == "POST":
            form = PropositionDissertationForm(request.POST, instance=proposition)
            if is_valid(request, form):
                proposition = edit_proposition(form, proposition_offers, request)
                return redirect('proposition_dissertation_detail', pk=proposition.pk)
            if not detect_in_request(request, 'txt_checkbox_', 'on'):
                offer_propositions_error = 'select_at_least_one_item'
                proposition_offers = None

        form = PropositionDissertationForm(instance=proposition)
        return layout.render(request, 'proposition_dissertation_edit.html',
                             {'prop_dissert': proposition,
                              'form': form,
                              'types_choices': PropositionDissertation.TYPES_CHOICES,
                              'levels_choices': PropositionDissertation.LEVELS_CHOICES,
                              'collaborations_choices': PropositionDissertation.COLLABORATION_CHOICES,
                              'offer_propositions': offer_propositions,
                              'offer_propositions_error': offer_propositions_error,
                              'proposition_offers': proposition_offers,
                              'offer_proposition_group': offer_propositions_group
                              })
    else:
        return redirect('proposition_dissertation_detail', pk=proposition.pk)
Ejemplo n.º 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})