def update(self, **argv): self.dname = argv.get('dessert_name', self.dname) self.type_id = argv.get('type', self.type_id) self.des = argv.get('des', self.des) self.num = argv.get('num', self.num) self.price = argv.get('price', self.price) session.commit()
def change_perms(self, d_perms=None, a_perms=None): if d_perms: for perm in d_perms: self.perms.remove(perm) if a_perms: for perm in a_perms: self.perms.append(perm) session.commit()
def update(self, **argv): from models.perm import Permission self.rolename = argv.get('rolename', self.rolename) if 'perms' in argv: perms_to_add = argv['perms']['add'] and Permission.get_mul(argv['perms']['add']) or None perms_to_remove = argv['perms']['remove'] and Permission.get_mul(argv['perms']['remove']) or None self.change_perms(perms_to_remove, perms_to_add) session.commit()
def change_roles(self, d_roles=None, a_roles=None): if d_roles: for role in d_roles: self.roles.remove(role) if a_roles: for role in a_roles: self.roles.append(role) session.commit()
def update(self, **argv): from models.perm import Permission self.rolename = argv.get('rolename', self.rolename) if 'perms' in argv: perms_to_add = argv['perms']['add'] and Permission.get_mul( argv['perms']['add']) or None perms_to_remove = argv['perms']['remove'] and Permission.get_mul( argv['perms']['remove']) or None self.change_perms(perms_to_remove, perms_to_add) session.commit()
def register(**argv): user = session.query(User).filter_by(username=argv["username"]).first() if user: return False, "username exist" user = User(username=argv["username"], password=argv["password"]) session.add(user) session.commit() s = request.environ.get('beaker.session') s['user'] = user.id return True, "success"
def random_order_g(): global order_buffer global oi_buffer start_date = dt(2012, 1, 1) end_date = dt(2012, 4, 2) for i, single_date in enumerate(daterange(start_date, end_date)): for num in range(random.randint(i+20, i+40)): random_order(single_date) for num in range(random.randint(i+10, i+40)): random_res(single_date) print single_date session.add_all(order_buffer) session.add_all(oi_buffer) session.commit()
def random_order_g(): global order_buffer global oi_buffer start_date = dt(2012, 1, 1) end_date = dt(2012, 4, 2) for i, single_date in enumerate(daterange(start_date, end_date)): for num in range(random.randint(i + 20, i + 40)): random_order(single_date) for num in range(random.randint(i + 10, i + 40)): random_res(single_date) print single_date session.add_all(order_buffer) session.add_all(oi_buffer) session.commit()
def update(self, **argv): from models.role import Role self.username = argv.get('username', self.username) self.password = argv.get('password', self.password) self.type_id = argv.get('type', self.type_id) self.age = argv.get('age', self.age) self.address = argv.get('address', self.address) self.email = argv.get('email', self.email) self.gender = argv.get('gender', self.gender) if 'roles' in argv: roles_to_add = argv['roles']['add'] and Role.get_mul(argv['roles']['add']) or None roles_to_remove = argv['roles']['remove'] and Role.get_mul(argv['roles']['remove']) or None self.change_roles(roles_to_remove, roles_to_add) if 'recharge' in argv: self.recharge(argv['recharge']) session.commit()
def update(self, **argv): self.user_id = argv.get('user', self.user_id) self.discount = argv.get('discount', self.discount) self.is_complete = argv.get('is_complete', self.is_complete) self.is_order = argv.get('is_order', self.is_order) self.is_confirmed = argv.get('is_confirmed', self.is_confirmed) confirm_date = argv.get('confirm_date', None) send_date = argv.get('send_date', None) if send_date: self.send_date = str2date(send_date) if confirm_date: self.confirm_date = str2date(confirm_date) if self.is_order: self.send_date = self.confirm_date self.is_complete = self.is_confirmed session.commit()
def delete(self): session.delete(self) session.commit()
def add(self): session.add(self) session.commit()
def update(self, **argv): self.num = argv.get('num', self.num) self.dessert_id = argv.get('dessert', self.dessert_id) self.order_id = argv.get('order', self.order_id) self.price = argv.get('price', self.price) session.commit()
def deactivate(self): self.is_active = False session.commit()
def update(self, **argv): self.content = argv.get("content", self.content) self.title = argv.get("title", self.title) session.commit()
def update(self, **argv): self.permname = argv.get('permname', self.permname) session.commit()
def update(self, **argv): self.typename = argv.get('typename', self.typename) self.discount = argv.get('discount', self.discount) self.fee = argv.get('fee', self.fee) session.commit()
def update(self, **argv): self.typename = argv.get('typename', self.typename) session.commit()
def recharge(self, d=1): self.expire_time += td(365 * d) session.commit()
def activate(self): self.is_active = True session.commit()
def update(self, **argv): self.content = argv.get('content', self.content) self.title = argv.get('title', self.title) session.commit()