예제 #1
0
    def activate_user(user):
        user.activate = User.ACTIVATE.YES
        db_session.commit()

        login_user(user, remember=True)

        return USER_ACTIVATE_OK
예제 #2
0
파일: user.py 프로젝트: momada/daixie-admin
    def register(user):
        if UserBiz.get_user_by_email(user.email):
            raise DaixieError(USER_DUPLICATE)
        db_session.add(user)
        db_session.commit()

        return USER_REGISTER_OK
예제 #3
0
 def add_solver(solver):
     if AdminBiz.get_admin_by_email(solver.email):
         raise DaixieError(USER_DUPLICATE)
     solver.type = Admin.ADMIN_TYPE.SOLVER
     db_session.add(solver)
     db_session.commit()
     return CS_ADD_OK
예제 #4
0
 def register(user):
     if UserBiz.get_user_by_email(user.email):
         raise DaixieError(USER_DUPLICATE)
     db_session.add(user)
     db_session.commit()
     
     return USER_REGISTER_OK
예제 #5
0
파일: user.py 프로젝트: momada/daixie-admin
    def activate_user(user):
        user.activate = User.ACTIVATE.YES
        db_session.commit()

        login_user(user, remember=True)

        return USER_ACTIVATE_OK
예제 #6
0
 def add_solver(solver):
     if AdminBiz.get_admin_by_email(solver.email):
         raise DaixieError(USER_DUPLICATE)
     solver.type = Admin.ADMIN_TYPE.SOLVER
     db_session.add(solver)
     db_session.commit()
     return CS_ADD_OK
예제 #7
0
	def edit_order(order):
		o = OrderBiz.get_order_by_id(order.id).first()
		user = UserBiz.get_user_by_id(order.user_id)

		if o is None:
			raise DaixieError(ORDER_NOT_EXIST)

		if o.status >= '1' and order.actual_order_price != 0:
			try:
				amount = float(o.expect_order_price)-float(order.actual_order_price)
				if amount>0:
					UserBiz.refund(o.user_id, abs(amount), type=Transaction.TYPE.REFUND, description=u'订单最终价格调整')
				else:
					if user.account < abs(amount):
						raise DaixieError(u'用户的余额不足,无法填写订单实际价格,修改失败')
					UserBiz.recharge(o.user_id, abs(amount), type=Transaction.TYPE.PAY, description=u'订单最终价格调整')
			except DaixieError as e:
				raise e

		try:
			db_session.add(order)
			db_session.commit()
		except:
			raise DaixieError(EDIT_ORDER_FAIL)
		return EDIT_ORDER_OK
예제 #8
0
파일: user.py 프로젝트: momada/daixie-admin
 def edit_user_profile(user):
     try:
         db_session.add(user)
         db_session.commit()
         login_user(user, remember=True)
     except:
         raise DaixieError(EDIT_USER_PROFILE_FAIL)
     return EDIT_USER_PROFILE_OK
예제 #9
0
 def edit_user_profile(user):
     try:
         db_session.add(user)
         db_session.commit()
         login_user(user, remember=True)
     except:
         raise DaixieError(EDIT_USER_PROFILE_FAIL)
     return EDIT_USER_PROFILE_OK
예제 #10
0
 def solver_commit_update(solver):
     try:
         solver.passwd = md5(solver.passwd).hexdigest()
         db_session.merge(solver)
         db_session.commit()
     except:
         db_session.rollback()
         raise
     return SOLVER_UPDATE_OK
예제 #11
0
 def cs_commit_update(cs):
     try:
         cs.passwd = md5(cs.passwd).hexdigest()
         db_session.merge(cs)
         db_session.commit()
     except:
         db_session.rollback()
         raise
     return CS_UPDATE_OK
예제 #12
0
파일: user.py 프로젝트: momada/daixie-admin
 def solver_commit_update(solver):
     try:
         solver.passwd = md5(solver.passwd).hexdigest()
         db_session.merge(solver)
         db_session.commit()
     except:
         db_session.rollback()
         raise
     return SOLVER_UPDATE_OK
예제 #13
0
 def cs_commit_update(cs):
     try:
         cs.passwd = md5(cs.passwd).hexdigest()
         db_session.merge(cs)
         db_session.commit()
     except:
         db_session.rollback()
         raise
     return CS_UPDATE_OK
예제 #14
0
	def create_order(order):
		try:
			db_session.add(order)
			db_session.commit()	
			order.id += 17394000
			db_session.add(order)
			db_session.commit()	 	
		except:
			raise DaixieError(CREATE_ORDER_FAIL)
		return CREATE_ORDER_OK
예제 #15
0
 def create(user_id, amount, account, type, description):
     try:
         transaction = Transaction(user_id, amount, account, type, description)
         db_session.add(transaction)
         db_session.commit()
         transaction.id += 23714000
         db_session.add(transaction)
         db_session.commit()
     except:
         raise DaixieError(u'生成交易记录失败')
예제 #16
0
 def create(user_id, amount, account, type, description):
     try:
         transaction = Transaction(user_id, amount, account, type,
                                   description)
         db_session.add(transaction)
         db_session.commit()
         transaction.id += 23714000
         db_session.add(transaction)
         db_session.commit()
     except:
         raise DaixieError(u'生成交易记录失败')
예제 #17
0
 def recharge(id, amount, type, description):
     user = UserBiz.get_user_by_id(id)
     if not user:
         raise DaixieError(USER_NOT_EXIST)
     try:
         user.account -= float(amount)
         db_session.add(user)
         db_session.commit()
         TransactionBiz.create(id, amount, user.account, type, description)
     except:
         raise DaixieError(REFUND_FAIL)
     return RECHARGE_SUCCESS
예제 #18
0
파일: user.py 프로젝트: momada/daixie-admin
 def recharge(id, amount, type, description):
     user = UserBiz.get_user_by_id(id)
     if not user:
         raise DaixieError(USER_NOT_EXIST)
     try:
         user.account -= float(amount)
         db_session.add(user)
         db_session.commit()
         TransactionBiz.create(id, amount, user.account, type, description)
     except:
         raise DaixieError(REFUND_FAIL)
     return RECHARGE_SUCCESS
예제 #19
0
 def add_CS(cs):
     if AdminBiz.get_admin_by_email(cs.email):
         raise DaixieError(USER_DUPLICATE)
     db_session.add(cs)
     db_session.commit()
     return CS_ADD_OK
예제 #20
0
 def delete_CS(cs):
     db_session.delete(cs)
     db_session.commit()
     return CS_DELETE_OK
예제 #21
0
파일: user.py 프로젝트: momada/daixie-admin
 def delete_solver(user):
     db_session.delete(user)
     db_session.commit()
     return SOLVER_DELETE_OK
예제 #22
0
파일: user.py 프로젝트: momada/daixie-admin
 def add_solver(user):
     if UserBiz.get_user_by_email(user.email):
         raise DaixieError(USER_DUPLICATE)
     db_session.add(user)
     db_session.commit()
     return SOLVER_ADD_OK
예제 #23
0
 def add_solver(user):
     if UserBiz.get_user_by_email(user.email):
         raise DaixieError(USER_DUPLICATE)
     db_session.add(user)
     db_session.commit()
     return SOLVER_ADD_OK
예제 #24
0
 def delete_CS(cs):
     db_session.delete(cs)
     db_session.commit()
     return CS_DELETE_OK
예제 #25
0
 def delete_solver(user):
     db_session.delete(user)
     db_session.commit()
     return SOLVER_DELETE_OK
예제 #26
0
 def add_CS(cs):
     if AdminBiz.get_admin_by_email(cs.email):
         raise DaixieError(USER_DUPLICATE)
     db_session.add(cs)
     db_session.commit()
     return CS_ADD_OK