Exemplo n.º 1
0
 def action_get_object(self,id, data_dict = {}):
     if isinstance(id,int) and self.id > 0:
         self.object = Service.saget(id)  
     elif isinstance(id,int) and self.id == 0:
         if 'key' in data_dict:
             self.object = Service.by_app_service(data_dict['key'])  
     else:
         self.object = Service.by_app_service(self.id)  
     if self.object:
         self.qry = [self.object]
     else:
         self.set_status(404)
         log.error("no service %s for %s" % (self.id,self.request.full_url()))
Exemplo n.º 2
0
 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')
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 def index(self,id=id):
     log.debug("in index start")
     services = Service.all().filter_by(list_public=1)
     recent = Service.recent_updates(5)
     self.render('service/service.html',services=services,recent=recent)
Exemplo n.º 5
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.º 6
0
 def view(self,id=0):
     item = Service.get(-1,id)
     self.render('service/service.html',item=item)
Exemplo n.º 7
0
 def view(self,id=0):
     c.item = Service.get(-1,id)
     return render('/service/service.html')
Exemplo n.º 8
0
 def index(self):
     c.services = Service.all().filter_by(list_public=1)
     c.recent = Service.recent_updates(5)
     return render('/service/service.html')
Exemplo n.º 9
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()