def logout(): ''' 注销 ''' try: UserBiz.user_logout() except DaixieError as e: fail(e) return redirect(url_for('.index'))
def send_activate_email(id, email): ''' 发送验证邮件 ''' try: ret = UserBiz.send_activate_email(id, email) success(ret) except DaixieError as e: fail(e) return render_template('general/wait_for_activate.html', id=id, email=email)
def check_is_activated(id, flash_msg=False): try: user = UserBiz.get_user_by_id(id) ret = UserBiz.check_is_activated(user) except DaixieError as e: fail(e) UserBiz.user_logout() return redirect(url_for('.send_activate_email', id=user.id, email=user.email)) if flash_msg: success(ret) return redirect(url_for('user.home'))
def pay(order_id): ''' 订单付款 ''' try: ret = OrderBiz.pay(order_id) except DaixieError as e: fail(e) return j_err(e) success(ret) return render_template('user/recharge_result.html', order_id=order_id, cuser=current_user, result=ret)
def more_info(id): ''' 查看订单的详细信息 ''' order = OrderBiz.get_order_by_id(id) if not order.user_id == current_user.id: fail(u'非法操作') return redirect(url_for('user.home')) if current_user.type == User.USER_TYPE.USER: return render_template('order/more_info_for_user.html', cuser=current_user, order=order, nav_order='active') else: return render_template('order/more_info_for_solver.html', cuser=current_user, order=order, nav_order='active')
def j_pay(): ''' 订单付款 ''' order_id = request.form['order_id'] try: ret = OrderBiz.pay(order_id) except DaixieError as e: fail(e) return j_err(e) success(ret) return j_ok(ret)
def profile(): """ 个人信息 """ form = ProfileForm(obj=current_user) if not form.validate_on_submit(): return render_template("user/setting.html", form=form, nav_profile="active") user = current_user form.populate_obj(user) # 修改个人信息 try: ret = UserBiz.edit_user_profile(user) success(ret) except DaixieError as e: fail(e) return redirect(url_for(".profile"))
def register(): ''' 注册成为普通用户 ''' form = RegisterForm() if not form.validate_on_submit(): print form.errors return render_template('general/register.html', form=form, nav_register='active') user = User(form.email.data, form.passwd.data) try: ret = UserBiz.register(user) except DaixieError as e: fail(e) return render_template('general/register.html', form=form, nav_register='active') success(ret) return redirect(url_for('user.profile'))
def profile(): ''' 个人信息 ''' form = ProfileForm(obj=current_user) if not form.validate_on_submit(): return render_template('user/setting.html', cuser= current_user, form=form, nav_profile='active') user = current_user form.populate_obj(user) #修改个人信息 try: ret = UserBiz.edit_user_profile(user) success(ret) except DaixieError as e: fail(e) return redirect(url_for('.profile'))
def login(): ''' 登录 ''' form = LoginForm() if not form.validate_on_submit(): return render_template('general/login.html', form=form, nav_login='******') email = form.email.data passwd = form.passwd.data #auto = form.auto.data auto = True user = User(email, passwd) try: ret = UserBiz.user_login(user, auto) except DaixieError as e: fail(e) return render_template('general/login.html', form=form, nav_login='******') success(ret) return redirect(url_for('.check_is_activated', id=user.id))