def ativaCampanha(self, candidatas=[]):
     session = TorneiraSession()
     
     try:
         session.begin()
         campanha_ativa = session.query(Campanha).filter(Campanha.ativo==True).one()
         campanha_ativa.ativo = False
         campanha_ativa.save()
         
         campanha = session.query(Campanha).filter(Campanha.candidata==True).order_by(Campanha.votos.desc()).first()
         campanha.ativo = True
         campanha.inicio = datetime.now()
         campanha.save()
         
         session.execute("UPDATE tface_campanha SET candidata = 0 ")
         
         for candidata in candidatas:
             c = Campanha()
             c.nome = candidata
             c.candidata = True
             c.save()
             
         session.commit()
     except NoResultFound:
         pass
     except Exception, e:
         session.rollback()
         raise(e)
Example #2
0
 def doLogin(login, password):
     
     session = TorneiraSession()
     
     try:
         user = session.query(User).filter(User.login == login).filter(User.password==password).one()
         return user
     except NoResultFound:
         return None
Example #3
0
    def doLogin(login, password):

        session = TorneiraSession()

        try:
            user = session.query(User).filter(User.login == login).filter(
                User.password == password).one()
            return user
        except NoResultFound:
            return None
Example #4
0
 def all(cls, limit=None):
     session = TorneiraSession()
     if limit:
         return session.query(cls).all()[limit[0]:limit[1]]
     return session.query(cls).all()
Example #5
0
 def fetch_by(cls, **kw):
     session = TorneiraSession()
     return session.query(cls).filter_by(**kw)
Example #6
0
 def get(cls, id):
     session = TorneiraSession()
     return session.query(cls).get(id)
Example #7
0
 def all(cls, limit=None):
     session = TorneiraSession()
     if limit:
         return session.query(cls).all()[limit[0]:limit[1]]
     return session.query(cls).all()
Example #8
0
 def fetch_by(cls, **kw):
     session = TorneiraSession()
     return session.query(cls).filter_by(**kw)
Example #9
0
 def get(cls, id):
     session = TorneiraSession()
     return session.query(cls).get(id)
 def listaCandidatas(self):
     session = TorneiraSession()
     result = session.query(Campanha).filter(Campanha.candidata==True).all()
     return [row.as_dict() for row in result]
 def getAtiva(self):
     session = TorneiraSession()
     campanha_ativa = session.query(Campanha).filter(Campanha.ativo==True).one()
     return campanha_ativa