Beispiel #1
0
def sign(request, petition_id, stance):

    p = get_object_or_404(Petition, pk=petition_id)

    show_public = int(request.GET.get('show_public', 0))

    params = {
        'path':
        reverse('sign', args=(petition_id, stance)) +
        '?show_public=%d' % show_public
    }
    auth_url = settings.AUTH_URL % urlencode(params)
    ret = authenticate(request, auth_url)
    if isinstance(ret, HttpResponse):
        return ret
    else:
        auth = ret

    if Signature.objects.filter(user=auth.user, petition=p).count():
        Signature.objects.filter(user=auth.user, petition=p).delete()
    s = Signature(user=auth.user,
                  petition=p,
                  show_public=show_public,
                  authentication=auth,
                  stance=stance)
    s.save()

    if not request.user.email:
        return HttpResponseRedirect(reverse('email', args=(petition_id, )))

    return HttpResponseRedirect(reverse('sign_receipt', args=(petition_id, )))
Beispiel #2
0
def login_view(request):

    params = {'path': reverse('login')}
    auth_url = settings.AUTH_URL % urlencode(params)
    ret = authenticate(request, auth_url)
    if isinstance(ret, HttpResponse):
        return ret

    return HttpResponseRedirect(reverse('popular', current_app='petition'))
Beispiel #3
0
def login_view(request):

    params = {'path': reverse('login')}
    auth_url = settings.AUTH_URL % urlencode(params)
    ret = authenticate(request, auth_url)
    if isinstance(ret, HttpResponse):
        return ret

    return HttpResponseRedirect(reverse('popular', current_app='petition'))
Beispiel #4
0
def sign(request, petition_id, stance):

    p = get_object_or_404(Petition, pk=petition_id)

    show_public = int(request.GET.get('show_public', 0))

    params = {'path': reverse('sign', args=(petition_id, stance)) + '?show_public=%d' % show_public}
    auth_url = settings.AUTH_URL % urlencode(params)
    ret = authenticate(request, auth_url)
    if isinstance(ret, HttpResponse):
        return ret
    else:
        auth = ret

    if Signature.objects.filter(user=auth.user, petition=p).count():
        Signature.objects.filter(user=auth.user, petition=p).delete()
    s = Signature(user=auth.user, petition=p, show_public=show_public, authentication=auth, stance=stance)
    s.save()

    if not request.user.email:
        return HttpResponseRedirect(reverse('email', args=(petition_id, )))

    return HttpResponseRedirect(reverse('sign_receipt', args=(petition_id, )))