예제 #1
0
파일: views.py 프로젝트: MechanisM/froide
def follow(request, slug):
    foirequest = get_object_or_404(FoiRequest, slug=slug)
    form = FollowRequestForm(foirequest, request.user, request.POST)
    if form.is_valid():
        followed = form.save()
        if request.user.is_authenticated():
            if followed:
                messages.add_message(request, messages.SUCCESS,
                        _("You are now following this request."))
            else:
                messages.add_message(request, messages.INFO,
                        _("You are not following this request anymore."))
        else:
            if followed is None:
                messages.add_message(request, messages.INFO,
                        _("You have not yet confirmed that you want to follow this request. Click the link in the mail that was sent to you."))
            elif followed:
                messages.add_message(request, messages.SUCCESS,
                        _("Check your emails and click the confirmation link in order to follow this request."))
            else:
                messages.add_message(request, messages.INFO,
                        _("You are following this request. If you want to unfollow it, click the unfollow link in the emails you received."))


        return HttpResponseRedirect(foirequest.get_absolute_url())
    else:
        return show(request, slug, context={"followform": form}, status=400)
예제 #2
0
def followrequest(context, foirequest, user, name):
    form = FollowRequestForm(foirequest, user)
    following = False
    if user.is_authenticated():
        if foirequest.followed_by(user):
            following = True
    form.following = following
    context[name] = form
    return ""