def save(self): inputParams= self.getInput() try: current_user = Users.get(Users.name == self.isLogin()) inputParams['longitude'] = inputParams['longitude'] if inputParams['longitude'] else 116.397428 inputParams['latitude'] = inputParams['latitude'] if inputParams['latitude'] else 39.90923 Groups.create( name = inputParams['name'], owner = current_user, address = inputParams['address'], phoneno = inputParams['phoneno'], cellphone = inputParams['cellphone'], faxno = inputParams['faxno'], postcode = inputParams['postcode'], contact = inputParams['contact'], description = self.htmlunquote(inputParams['description']), thumbnail = int(inputParams['thumbnail']), team_description = self.htmlunquote(inputParams['team_description']), regions = inputParams['regions'], service_modes = inputParams['service_modes'], specials = inputParams['specials'], swipeshow_album = int(inputParams['swipeshow_album']), groups_album = int(inputParams['groups_album']), price1 = float(inputParams['price1']), price2 = float(inputParams['price2']), longitude = float(inputParams['longitude']), latitude = float(inputParams['latitude']), category = int(inputParams['category']), ) except Exception, e: return self.error(msg = '新增公司失败: %s' % e, url=self.makeUrl('/admin/groups/list'))
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 list(self): inputParams = self.getInput() page = int(inputParams['page']) if inputParams.has_key('page') else 1 count = config.COUNT_PER_PAGE groupsList = Groups.select() current_user = Users.get(Users.name == self.isLogin()) if not self.isAdmin(): groupsList = groupsList.where(Groups.owner == current_user) groupsList = groupsList.order_by(Groups.id.desc()) pageString = self.getPageStr('/admin/groups/list', page, count, groupsList.count()) self.privData['GROUPS_LIST'] = groupsList.paginate(page, count) self.privData['PAGE_STRING'] = pageString categoriesList = Categories().select() self.privData['CATEGORIES_LIST'] = categoriesList return self.display('groupsList')
from models.groups import Groups g = Groups()
def addGroup(self, id, name, members): group = Groups() group.setId(id) group.setName(name) group.setMembers(members) return group
def _get_trade_info(self, inputs, from_mobile): try: group = Groups.get(Groups.id == inputs.get("id",0)) except Exception, e: raise e