def register(request):
    classes_list = mongodb_options.find_classes(db)
    brands_list = mongodb_options.find_brands(db)
    brands_list_design = []
    for brand in brands_list:
        if brand['isdesign'] == u'是':
            brands_list_design.append(brand)
    client_id = uuid.uuid1()
    email = request.POST['email']
    username = request.POST['username']
    
    gender = request.POST['gender']
    date = request.POST['date']
    date_list = date.split('-')
    day = date_list[2]
    month = date_list[1]
    year = date_list[0]
    age = str(client_util_functions.get_age(year, month, day))
    phone_num = request.POST['phonenum']
    password = request.POST['paw1']
    user = mongodb_options.find_client_by_username(db, username)
    if not user:
	smtp_to_user(username,email)
        mongodb_options.insert_client(db, client_id, username, password, gender, age, date, email, phone_num,1,'false')
        return render(request, 'client/client_register_success.html',
                      {'classes_list': classes_list, 'brands_list': brands_list,
                       'brands_list_design': brands_list_design,'message':'<script type="text/javascript">alert("恭喜您,注册成功!您的账户处于待激活状态,请到邮箱点击激活链接进行激活!!");</script>'})
    else:
        return render(request, 'client/client_register_error.html',
                      {'classes_list': classes_list, 'brands_list': brands_list,
                       'brands_list_design': brands_list_design})
Beispiel #2
0
def modify_client(request):
    if "username" in request.session:
        login_user = request.session['username']
    client_id = request.POST['client_id']
    original_username = request.POST['original_username']
    username = request.POST['username']
    if not username == original_username:
        client = mongodb_options.find_client_by_username(db, username)
        if not client:
            password = request.POST['password']
            gender = request.POST['gender']
            date = request.POST['date']
	    date_list = date.split('-')
	    day = date_list[2]
	    month = date_list[1]
	    year = date_list[0]
	    age = str(client_util_functions.get_age(year, month, day))
            email = request.POST['email']
            phone_num = request.POST['phone_num']
            mongodb_options.update_client(db, client_id, username, password, gender, age, date, email, phone_num)
            return HttpResponseRedirect('/manage/req_client/')
        else:
            return render(request, 'manage_modify_client.html', {'login_user': login_user, 'flag': True, 'message': '该用户名已经存在了'})
    else:
        password = request.POST['password']
        gender = request.POST['gender']
        date = request.POST['date']
        date_list = date.split('-')
        day = date_list[2]
        month = date_list[1]
        year = date_list[0]
        age = str(client_util_functions.get_age(year, month, day))
        email = request.POST['email']
        phone_num = request.POST['phone_num']
        mongodb_options.update_client(db, client_id, username, password, gender, age, date, email, phone_num)
        return HttpResponseRedirect('/manage/req_client/')
Beispiel #3
0
def add_client(request):
    if "username" in request.session:
        login_user = request.session['username']
    client_id = uuid.uuid1()
    username = request.POST['username']
    password = request.POST['password']
    gender = request.POST['gender']
    date = request.POST['date']
    date_list = date.split('-')
    day = date_list[2]
    month = date_list[1]
    year = date_list[0]
    age = str(client_util_functions.get_age(year, month, day))
    email = request.POST['email']
    phone_num = request.POST['phone_num']
    client = mongodb_options.find_client_by_username(db, username)
    if not client:
	smtp_to_user(username,email)
        mongodb_options.insert_client(db, client_id, username, password, gender, age, date, email, phone_num,'false')
       # return HttpResponseRedirect('/manage/req_client/')
	return render(request, 'manage_client_register.html', {'message':'<script type="text/javascript">alert("恭喜您,注册成功!您的账户处于待激活状态,请到邮箱点击激活链接进行激活!!");</script>'})
    else:
        return render(request, 'manage_client_register.html', {'login_user': login_user, 'flag': True, 'message': '用户名已被注册了'})