def update(self): inputParams= self.getInput() group = Groups.get(Groups.id == int(inputParams['id'])) current_user = Users.get(Users.name == self.isLogin()) if current_user.id != group.owner.id and not self.isAdmin() or not current_user.role.type < 100: return self.error(msg = '权限不足!', url=self.makeUrl('/admin/groups/list')) try: group.regions = inputParams['regions'] group.name = inputParams['name'] group.owner = current_user group.phoneno = inputParams['phoneno'] group.cellphone = inputParams['cellphone'] group.faxno = inputParams['faxno'] group.postcode = inputParams['postcode'] group.contact = inputParams['contact'] group.description = self.htmlunquote(inputParams['description']) group.thumbnail = int(inputParams['thumbnail']) group.team_description = self.htmlunquote(inputParams['team_description']) group.regions = inputParams['regions'] group.service_modes = inputParams['service_modes'] group.specials = inputParams['specials'] group.swipeshow_album = int(inputParams['swipeshow_album']) group.groups_album = int(inputParams['groups_album']) group.price1 = float(inputParams['price1']) group.price2 = float(inputParams['price2']) group.address = inputParams['address'] group.longitude = float(inputParams['longitude']) group.latitude = float(inputParams['latitude']) group.category = int(inputParams['category']) group.save() except Exception, e: return self.error(msg = '公司修改失败: %s' % e, url=self.makeUrl('/admin/groups/list'))
def delete(self): inputParams = self.getInput() group = Groups.get(Groups.id == int(inputParams['id'])) current_user = Users.get(Users.name == self.isLogin()) if current_user.id != group.owner.id and not self.isAdmin() or not current_user.role.type < 100: return self.error(msg = '权限不足!', url=self.makeUrl('/admin/groups/list')) try: group.delete_instance() except Exception, e: return self.success(msg='公司删除失败: %s' % e, url=self.makeUrl('/admin/groups/list'))
def _get_trade_info(self, inputs, from_mobile): try: group = Groups.get(Groups.id == inputs.get("id",0)) except Exception, e: raise e