예제 #1
0
파일: views.py 프로젝트: NolanZhao/Machine
def user_add(request):
    if request.method == "GET":
        return render_to_response('system/user_add.html', locals(), context_instance=RequestContext(request))
    else:
        username = request.POST.get('username', '')
        password = request.POST.get('password', '')
        real_name = request.POST.get('real_name')
        gender = request.POST.get('gender')
        mobile = request.POST.get('mobile')
        phone = request.POST.get('phone')
        email = request.POST.get('email')
        position = request.POST.get('position')

        # last_login = datetime.datetime.now(),
        # date_joined = datetime.datetime.now(),
        # updated_at = datetime.datetime.now(),
        # deleted_at = datetime.datetime.now(),

        User.create_user(
            username=username,
            password=make_password(password),
            real_name=real_name,
            gender=gender,
            position=position,

            email=email,
            phone=phone,
            mobile=mobile,

            # last_login=last_login,
            # date_joined=date_joined,
            # updated_at=updated_at,
            # deleted_at=deleted_at
            )
        return HttpResponseRedirect('/')
예제 #2
0
파일: views.py 프로젝트: NolanZhao/Machine
def register(request):
    if request.method == "GET":
        return render_to_response('system/register.html', locals(), context_instance=RequestContext(request))
    else:
        resp = {"success": False, "error": ""}
        username = request.POST.get('username')
        password = request.POST.get('password')
        password_again = request.POST.get('password_again')
        if password != password_again:
            resp["error"] = "出错!"
            return HttpResponse(json.dumps(resp), content_type="application/json")
        try:
            User.create_user(username=username, password=make_password(password))
            resp["success"] = True
            resp["error"] = "执行成功!"
        except:
            resp["success"] = True
            resp["error"] = "出错!"
        return HttpResponseRedirect('/')
예제 #3
0
파일: views.py 프로젝트: rzlmma/Machine
def register(request):
    if request.method == "GET":
        return render_to_response('system/register.html',
                                  locals(),
                                  context_instance=RequestContext(request))
    else:
        resp = {"success": False, "error": ""}
        username = request.POST.get('username')
        password = request.POST.get('password')
        password_again = request.POST.get('password_again')
        if password != password_again:
            resp["error"] = "出错!"
            return HttpResponse(json.dumps(resp),
                                content_type="application/json")
        try:
            User.create_user(username=username,
                             password=make_password(password))
            resp["success"] = True
            resp["error"] = "执行成功!"
        except:
            resp["success"] = True
            resp["error"] = "出错!"
        return HttpResponseRedirect('/')
예제 #4
0
파일: views.py 프로젝트: rzlmma/Machine
def user_add(request):
    if request.method == "GET":
        return render_to_response('system/user_add.html',
                                  locals(),
                                  context_instance=RequestContext(request))
    else:
        username = request.POST.get('username', '')
        password = request.POST.get('password', '')
        real_name = request.POST.get('real_name')
        gender = request.POST.get('gender')
        mobile = request.POST.get('mobile')
        phone = request.POST.get('phone')
        email = request.POST.get('email')
        position = request.POST.get('position')

        # last_login = datetime.datetime.now(),
        # date_joined = datetime.datetime.now(),
        # updated_at = datetime.datetime.now(),
        # deleted_at = datetime.datetime.now(),

        User.create_user(
            username=username,
            password=make_password(password),
            real_name=real_name,
            gender=gender,
            position=position,
            email=email,
            phone=phone,
            mobile=mobile,

            # last_login=last_login,
            # date_joined=date_joined,
            # updated_at=updated_at,
            # deleted_at=deleted_at
        )
        return HttpResponseRedirect('/')