Ejemplo n.º 1
0
def signup(request):
    if request.is_ajax():
        if len(request.GET) > 0:
            form = SignupForm(request.GET, error_class=TextErrorList)
            for k in request.GET.keys():
                info = {'name': k}
                if form.errors.get(k):
                    info['msg'] = form.errors.get(k).as_text();
                    info['valid'] = False
                else:
                    info['msg'] = 'ok'
                    info['valid'] = True
                break
            return JsonResponse(info)
    elif request.method == 'POST':
        form = SignupForm(request.POST)
        if form.is_valid():
            form.save()
            logout(request)
            messages.success(request, 'Validation email has sent to %s, please check it.' % request.POST.get('email'))
            return HttpResponseRedirect("/")
    else:
        form = SignupForm()
    return {'form':form}
Ejemplo n.º 2
0
def logout(request):
    from usr import logout
    logout(request)
    return HttpResponseRedirect("/login")