Exemplo n.º 1
0
def send_message(request, slug):
    foirequest = get_object_or_404(FoiRequest, slug=slug)
    if not request.user.is_authenticated():
        return render_403(request)
    if request.user != foirequest.user:
        return render_403(request)
    form = SendMessageForm(foirequest, request.POST)
    if form.is_valid():
        form.save(request.user)
        messages.add_message(request, messages.SUCCESS,
                _('Your Message has been sent.'))
        return HttpResponseRedirect(foirequest.get_absolute_url())
    else:
        return show(request, slug, context={"send_message_form": form}, status=400)
Exemplo n.º 2
0
def send_message(request, slug):
    foirequest = get_object_or_404(FoiRequest, slug=slug)
    if not request.user.is_authenticated():
        return render_403(request)
    if request.user != foirequest.user:
        return render_403(request)
    form = SendMessageForm(request.POST)
    if form.is_valid() and foirequest.replyable():
        foirequest.add_message(request.user, **form.cleaned_data)
        messages.add_message(request, messages.SUCCESS,
                _('Your Message has been sent.'))
        return HttpResponseRedirect(foirequest.get_absolute_url())
    else:
        return render_400(request)