def get (self, registry_id): # Classe noticias noticias = Noticias(registry_id) lista = noticias.get_obj_lista_noticias(popup="S") self.set_header("Content-Type", "application/xml") self.render("modules/noticia/noticias.xml", NOMEPAG=u'Notícias', \ LISTA=lista, NOW=str(datetime.now())[0:11], \ CHANGE_NAVIGATION=False, \ REGISTRY_ID=registry_id)
def post(self, registry_id): # Validar acesso if eh_acesso_invalido(self, registry_id): return user = self.get_current_user() id = int( self.get_argument("id","") ) noticias = Noticias(registry_id) noticia = Noticia(registry_id, id) noticia.id = id noticia.titulo = self.get_argument("titulo","Sem titulo") noticia.resumo = self.get_argument("resumo", "") noticia.texto = self.get_argument("texto","") noticia.dt_publicacao = str(datetime.now()) noticia.url = self.get_argument("url", "") noticia.dt_validade = self.get_argument("dt_validade", "") noticia.fonte = self.get_argument("fonte", "") noticia.popup = self.get_argument("popup", "") if noticia.dt_validade != "": try: f = lambda n: ("00"+n)[-2:] x = noticia.dt_validade.split("/") x.reverse() x[1] = f(x[1]) x[2] = f(x[2]) x = "-".join(x) d = time.strptime(x, "%Y-%m-%d") noticia.dt_validade = x except: self.render("modules/noticia/noticia-new.html", NOMEPAG=u'Notícias', \ REGISTRY_ID=registry_id, MSG="Data inválida", \ NOTICIA=noticia) return noticias.insert_noticia(noticia) log.model.log(user, u'criou ou alterou uma notícia em', objeto=registry_id, tipo="noticia") self.redirect("/noticia/"+registry_id) return
def get (self, registry_id): user = self.get_current_user() # Validar acesso #if eh_acesso_invalido(self, registry_id): return # Classe noticias noticias = Noticias(registry_id) lista = noticias.get_obj_lista_noticias(user=user) links = [] if isOwner(user, registry_id): links.append((u"Nova notícia", "/static/imagens/icones/add_news32.png", "/noticia/"+registry_id+"/new")) log.model.log(user, u'acessou as notícias de', objeto=registry_id, tipo="noticia", news=False) #chamando a página self.render("modules/noticia/noticia-list.html", NOMEPAG=u'Notícias', \ REGISTRY_ID=registry_id, \ LINKS=links, NOW=str(datetime.now())[0:11], \ LISTA=lista, EH_EDITOR=isOwner(user,registry_id)) return