示例#1
0
文件: views.py 项目: clvrobj/ninemit
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}
示例#2
0
文件: views.py 项目: clvrobj/ninemit
def logout(request):
    from usr import logout
    logout(request)
    return HttpResponseRedirect("/login")