Пример #1
0
def _update_or_create_proposal(request, learning_unit_year, proposal=None):
    person = get_object_or_404(Person, user=request.user)
    proposal_base_form = ProposalBaseForm(request.POST or None, person,
                                          learning_unit_year, proposal)

    if request.method == 'POST':
        if proposal_base_form.is_valid():
            proposal = proposal_base_form.save()
            display_success_messages(
                request,
                _("You proposed a modification of type %(type)s for the learning unit %(acronym)s."
                  ) % {
                      'type': proposal.get_type_display(),
                      'acronym': learning_unit_year.acronym
                  })
            return redirect('learning_unit',
                            learning_unit_year_id=learning_unit_year.id)
        else:
            show_error_message_for_form_invalid(request)

    context = proposal_base_form.get_context()
    if proposal:
        return render(request,
                      'learning_unit/proposal/update_modification.html',
                      context)
    return render(request, 'learning_unit/proposal/create_modification.html',
                  context)
Пример #2
0
def _update_or_create_proposal(request, learning_unit_year, proposal=None):
    person = get_object_or_404(Person, user=request.user)

    proposal_base_form = ProposalBaseForm(request.POST or None, person,
                                          learning_unit_year, proposal)

    if proposal_base_form.is_valid():
        proposal = proposal_base_form.save()
        display_success_messages(
            request,
            _("You proposed a modification of type {} for the learning unit {}."
              ).format(_(proposal.type), learning_unit_year.acronym))
        return redirect('learning_unit',
                        learning_unit_year_id=learning_unit_year.id)

    context = proposal_base_form.get_context()
    if proposal:
        return render(request,
                      'learning_unit/proposal/update_modification.html',
                      context)
    return render(request, 'learning_unit/proposal/create_modification.html',
                  context)