def edit_POST(self, id=0): """ User has selected to change site config info """ site = Site.get(-1, self.get_argument("id")) form = SiteForm(QueryDict(self.request.arguments)) if form and site and form.validate(): if site is None: self.add_error("We experienced an error, please try again") else: site.name = form.name.data log.debug("description pre sanitize = %s" % form.description.data) site.description = sanitize.sanitize(form.description.data) site.email = form.email.data site.slug = self.get_argument("real_permalink") # TODO, check uniqueness site.public = bool(form.public.data) site.base_url = form.base_url.data site.site_url = form.site_url.data site.save() # refresh session store user = Person.get(self.user.site_id, self.user.id) self.set_current_user(user) self.add_alert("Site settings were updated") else: log.error(form.errors) log.error("There was an Error site=%s form.data%s" % (site, form.data)) self.add_error("There was an Error") return self.render("/site/site_edit.html", item=site, form=form) return self.redirect("/site/view?msg=Site+Updated")
def appedit(self,id=0): log.info('what the heck, in edit %s' % id) id = self.get_argument("app_id") site = Site.get(-1,self.user.site_id) if id == 0 or id == None or id == '0': app = App() app.site_id = site.id app.owner_id = self.user.id log.info('hm, id == 0') else: app = App.get(site.id,id) log.info('args = %s' % (str(self.request.arguments))) app.slug = sanitize(self.get_argument('real_permalink2')) app.name = sanitize(self.get_argument('app_name')) app.authn = sanitize(self.get_argument('authn')) #if 'description' in self.request.arguments: app.description = sanitize(self.get_argument('description','')) app.base_url = sanitize(self.get_argument('base_url')) app.save() self.write(str(app.id))
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 sanitize(text): return libsanitize.sanitize(text)