Пример #1
0
 def get (self, registry_id, id_noticia):
     # Validar acesso
     #if eh_acesso_invalido(self, registry_id): return
     
     user = self.get_current_user()
             
     tr = self.get_argument("tr","")
     
     try:
         id = int(id_noticia)
     except:
         msg = u"Notícia inválida."
         self.render("home.html", NOMEPAG=u'Notícias', MSG=msg, REGISTRY_ID=registry_id)
         
     noticia = Noticia(registry_id, id)
     noticia.dt_publicacao = short_date(noticia.dt_publicacao)
     
     if noticia.url != "":
         self.redirect(noticia.url)
     else:
         log.model.log(user, u'acessou uma notícia em', objeto=registry_id, tipo="noticia", news=False)            
         self.render("modules/noticia/noticia.html", NOMEPAG=u'Notícias', \
                     REGISTRY_ID=registry_id, \
                     NOTICIA=noticia, TR=tr)
     return
Пример #2
0
 def get (self, registry_id):
     # Validar acesso
     if eh_acesso_invalido(self, registry_id): return
     
     try:
         id = int(self.get_argument("n",""))
     except:
         id = -1
         
     noticia = Noticia(registry_id, id)
     if noticia.dt_validade != "":
         n = noticia.dt_validade
         n = n[8:]+"/"+n[5:7]+"/"+n[0:4]
         noticia.dt_validade = n
     
     self.render("modules/noticia/noticia-new.html", NOMEPAG=u'Notícias', \
                 REGISTRY_ID=registry_id, MSG="", \
                 NOTICIA=noticia)
     return
Пример #3
0
 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