def post(self): id = int(self.request.get('_id')) item = db.get(db.Key.from_path('Picture', id)) parameters = formutils.getBasicParameters(self) if not parameters["admin"]: self.error(403) return form = tourismforms.PictureForm(data=self.request.POST, instance=item) if form.is_valid(): entity = form.save(commit=False) try: image = self.request.get("pictureImage") entity.image = db.Blob(image) except: entity.image = item.image entity.put() url = r'/' SessionHandler.setSessionAttribute('addmsg', 'Imagem alterada com sucesso!') if SessionHandler.getSessionAttribute('new_home'): url = SessionHandler.removeSessionAttribute('new_home') self.redirect(url) else: parameters["content"] = formutils.getFormContentForUpdate(form, id, 'frmRegistration', r'/updatePicture') path = os.path.join(os.getcwd(), 'templates/index.html') self.response.out.write(template.render(path, parameters))
def get(self): query = db.GqlQuery("SELECT * FROM MenuLink ORDER BY position") s = u"<a href='/addMenuLink'>Registrar novo link no menu...</a><br><br>Menus já cadastrados:<br>" for item in query: s = s + "<a href='/updateMenuLink?key=" + str(item.key()) + "'>" + item.title + "</a><br>" SessionHandler.setSessionAttribute('new_home', '/menuLink') parameters = formutils.getBasicParameters(self) parameters["content"] = s path = os.path.join(os.getcwd(), 'templates/index.html') self.response.out.write(template.render(path, parameters))
def get(self): query = db.GqlQuery("SELECT * FROM StaticContent ORDER BY shortname") s = u"<a href='/addStaticContent'>Registrar novo conteudo estático...</a><br><br>Conteudos estaticos existentes:<br>" for item in query: s = s + "<a href='/updateStaticContent?key=" + str(item.key()) + "'>" + item.shortname + "</a><br>" SessionHandler.setSessionAttribute('new_home', '/staticContent') parameters = formutils.getBasicParameters(self) parameters["content"] = s path = os.path.join(os.getcwd(), 'templates/index.html') self.response.out.write(template.render(path, parameters))
def get(self): query = db.GqlQuery("SELECT * FROM Picture ORDER BY name") s = u"<a href='/addPicture'>Registrar nova Imagem...</a><br><br>Imagens já cadastradas:<br>" for item in query: s = s + "<a href='/updatePicture?key=" + str(item.key()) + "'>" + item.name + "</a><br>" SessionHandler.setSessionAttribute('new_home', '/picture') parameters = formutils.getBasicParameters(self) parameters["content"] = s path = os.path.join(os.getcwd(), 'templates/index.html') self.response.out.write(template.render(path, parameters))
def get(self): content = 'home' if self.request.get('content'): content = self.request.get('content') contents = db.GqlQuery("SELECT * FROM StaticContent WHERE shortname = :1", content) if contents.count() != 1: content = "Conteúdo retornado com problemas. Entre em contato com o administrador." else: content = contents.get().content parameters = formutils.getBasicParameters(self) parameters["content"] = content path = os.path.join(os.getcwd(), 'templates/index.html') self.response.out.write(template.render(path, parameters))