def task_post(request, get_header=None): if request.method == "POST": if all_in_request(request.POST, ("task-type", "task-repeat-frequency", "task-assign-model")): __queryDataSet = request.POST __task_type_id = __queryDataSet["task-type"] __task_repeat_freq = __queryDataSet["task-repeat-frequency"] __task_assign_model = __queryDataSet["task-assign-model"] task_type = Task_Type.objects.get(id=__task_type_id) return wrapped_render_to_response( "task/post.html", { "IS_POSTBACK": True, "HEADER_MENU": get_header(session=request.session), "IS_LOGINED": get_is_logined(request), "TASK_TYPE": task_type, "REQUEST": {"task_repeat_freq": __task_repeat_freq, "task_assign_model": __task_assign_model}, }, ) else: return HttpResponse("wrong#") else: return wrapped_render_to_response( "task/post.html", { "IS_POSTBACK": False, "HEADER_MENU": get_header(session=request.session), "IS_LOGINED": get_is_logined(request), "TASK_TYPE": Task_Type.objects.get(id=3), # 默认任务类型为其他 }, )
def user_reg_post(request): if all_in_request(request.POST,('fname','lname','appe','email','password','idcard','mphone',)): _first_name = request.POST['fname'] _last_name = request.POST['lname'] _password = request.POST['password'] _appellation = request.POST['appe'] _email = request.POST['email'] _id_no = request.POST['idcard'] _mobile_phone = request.POST['mphone'] # validate user's info if that exist has_exist_any = Users.objects.exist_any(_email,_id_no,_mobile_phone) if not has_exist_any: #make a md5 password _password = _makemd5(_password) #make md5 END #init a new user obj new_user = Users( first_name=_first_name, last_name=_last_name, password=_password, appellation=_appellation, email=_email, id_no=_id_no, mobile_phone=_mobile_phone) # init new user obj END try: # try to save new user obj new_user.save() #record session set_session(request,'user_id',new_user.id) #向客户端响应包含新用户姓氏,称谓以及ID的HTML代码 return render_to_response( 'user/reg_success.html',{ 'U_FIRST_NAME':new_user.first_name, 'U_APPELLATION':new_user.appellation, 'U_ID':new_user.id } ) except Exception: import sys ex = sys.exc_info()[2].tb_frame.f_back writelog('**Exception:%s on line %s' %(ex.f_code.co_name,ex.f_lineno,)) return render_error_page( err_action='我们在提交注册申请时', err_msg=( '服务器访问量太大,暂时无法响应您的请求。', ), other_options=[('回到打杂兔网站首页','/',),('挺稍后再尝试注册','/user/reg/',)] ) else: return render_error_page( err_action='我们在提交注册申请时', err_msg=( '您提交的电子邮箱已经被注册。', '您提交的身份证件号码已经被注册。', '您提交的手机号码已经被注册。', ), other_options=[('回到打杂兔网站首页','/',),('重新注册','/user/reg/',)] ) else: return render_error_page( '您在访问本页时', ('您没有使用正确的浏览方式访问本页。',), [('回到打杂兔网站首页','/',)])