Exemplo n.º 1
0
 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()
Exemplo n.º 2
0
 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()