Exemple #1
0
def watchlist_action(request):
    if request.method != 'POST':
        return http.HttpResponseNotAllowed('POST request required')

    profile = get_profile(request)
    form = SubscriptionForm(user=profile, data=request.POST)

    if form.is_valid():
        action, post = form.process()

        return http.HttpResponseRedirect(request.REQUEST.get('next', reverse('turbion_watchlist')))
    return http.HttpResponseBadRequest('Post not found or bad action')
Exemple #2
0
def unsubscribe(request, user_id):
    profile = get_object_or_404(Profile, pk=user_id)

    form = SubscriptionForm(user=profile, data=request.GET)
    form.fields['code'].required=True

    if form.is_valid():
        form.process()

        return status_redirect(
            request,
            title=_("Unsubscribed"),
            section=_("Watchlist"),
            message=_("You've been unsubscribed from new comment notification"),
            next="/"
        )

    return http.HttpResponseBadRequest('Post not found or bad action or bad code')