Пример #1
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
Пример #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
Пример #3
0
 def save(self):
     session = TorneiraSession()
     if not self.id:
         session.add(self)
     session.flush()
Пример #4
0
 def delete(self):
     session = TorneiraSession()
     session.delete(self)
     session.flush()
Пример #5
0
 def all(cls, limit=None):
     session = TorneiraSession()
     if limit:
         return session.query(cls).all()[limit[0]:limit[1]]
     return session.query(cls).all()
Пример #6
0
 def fetch_by(cls, **kw):
     session = TorneiraSession()
     return session.query(cls).filter_by(**kw)
Пример #7
0
 def get(cls, id):
     session = TorneiraSession()
     return session.query(cls).get(id)
Пример #8
0
 def save(self):
     session = TorneiraSession()
     if not self.id: 
         session.add(self)
     session.flush()
Пример #9
0
 def delete(self):
     session = TorneiraSession()
     session.delete(self)
     session.flush()
Пример #10
0
 def all(cls, limit=None):
     session = TorneiraSession()
     if limit:
         return session.query(cls).all()[limit[0]:limit[1]]
     return session.query(cls).all()
Пример #11
0
 def fetch_by(cls, **kw):
     session = TorneiraSession()
     return session.query(cls).filter_by(**kw)
Пример #12
0
 def get(cls, id):
     session = TorneiraSession()
     return session.query(cls).get(id)
Пример #13
0
 def votar(self, id):
     session = TorneiraSession()
     session.execute("UPDATE tface_campanha SET votos = votos + 1 where id = %s" % id)
Пример #14
0
 def listaCandidatas(self):
     session = TorneiraSession()
     result = session.query(Campanha).filter(Campanha.candidata==True).all()
     return [row.as_dict() for row in result]
Пример #15
0
 def getAtiva(self):
     session = TorneiraSession()
     campanha_ativa = session.query(Campanha).filter(Campanha.ativo==True).one()
     return campanha_ativa
Пример #16
0
 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)