def edit_POST(self,id=0): item = None form = ServiceForm(QueryDict(self.request.arguments)) if form.validate(): if form.id.data and int(form.id.data) == 0: item = Service(site_id=self.user.site_id, name=sanitize(form.name.data)) item.owner_id = self.user.id elif self.user.issysadmin: item = Service.get(-1,int(form.id.data)) else: item = Service.get(site_id,int(form.id.data)) item.name = sanitize(form.name.data) item.key = sanitize(form.real_permalink.data) item.description = sanitize(form.description.data) item.format = sanitize(form.format.data) item.method_url = sanitize(form.method_url.data) if hasattr(form,'list_public'): item.list_public = int(form.list_public.data) if hasattr(form,'app'): item.app_id = form.app.data if item.id > 0: item.save() else: item.save() self.add_alert('Service Added') return self.index()
def service_edit_post(self,id=0): if self.form_result['service_id'] == "0": item = Service(site_id=c.site_id, name=sanitize(self.form_result['name'])) item.owner_id = c.user.id elif c.user.issysadmin: item = Service.get(-1,int(self.form_result['service_id'])) else: item = Service.get(c.site_id,int(self.form_result['service_id'])) item.name = sanitize(self.form_result['name']) item.key = sanitize(self.form_result['real_permalink']) item.description = sanitize(self.form_result['description']) item.format = sanitize(self.form_result['format']) item.method_url = sanitize(self.form_result['method_url']) if 'list_public' in self.form_result: item.list_public = int(self.form_result['list_public']) if 'app' in self.form_result: item.app_id = self.form_result['app'] if item.id > 0: item.save() else: item.save() h.add_alert('Service Added') return self.index()
def edit(self,id=0): log.info('what the heck, in service edit %s' % id) site = Site.get(-1,c.site_id) c.app_list = [['%s' % app.id,app.name] for app in site.apps] if id == 0 or id == None: c.item = App() c.service = Service() log.info('hm, id == 0') else: c.service = Service.get(c.user.site_id,id) if not c.service and not c.user.issysadmin: h.add_alert('No permission to this service') return self.index() elif c.user.issysadmin: c.service = Service.get(-1,id) c.item = c.service.app return render('/service/service_edit.html')
def edit(self,id=0): log.info('what the heck, in service edit id=%s' % id) site = Site.get(-1,self.user.site_id) app_list = [['%s' % app.id,app.name] for app in site.apps] if id == 0 or id == None or id=='': app = App() service = Service() log.info('hm, id == 0') else: service = Service.get(self.user.site_id,id) if not service and not self.user.issysadmin: self.add_alert('No permission to this service') return self.index() elif self.user.issysadmin: service = Service.get(-1,id) if service: app = service.app self.render('/service/service_edit.html',site=site,app_list=app_list, app=app,serviceitem=service)
def view(self,id=0): item = Service.get(-1,id) self.render('service/service.html',item=item)
def view(self,id=0): c.item = Service.get(-1,id) return render('/service/service.html')