예제 #1
0
    def default(self, team):
        s = Session()
        our_teams = dict((t.name, t) for t in s.query(Team).all())
        s.close()

        if team in our_teams:
            team = our_teams[team]
            return ("teampage", {'team': team})

        return "Invalid page"
예제 #2
0
    def default(self, team):
        s = Session()
        our_teams = dict((t.name, t) for t in s.query(Team).all())
        s.close()

        if team in our_teams:
            team = our_teams[team]
            return ("teampage", {'team': team})

        return "Invalid page"
예제 #3
0
    def addteam_(self, **kwargs):
        success, serial = self._addteamform.Validate(kwargs)
        if not success:
            raise cpy.HTTPRedirect("/admin/addteam?%s" % Form.Encode(serial))

        session = Session()
        team = Team(kwargs['name'], 
                    kwargs['thumb'],
                    kwargs['fullsize'],
                    encrypt(kwargs['password']),
                    1,
                    kwargs['description'])
        session.save(team)
        session.commit()
        session.close()

        raise cpy.HTTPRedirect("/admin/lsteam/")
예제 #4
0
    def editteam_(self, **kwargs):
        success, serial = self._editteamform.Validate(kwargs)
        if not success:
            raise cpy.HTTPRedirect("/admin/editteam?%s" % Form.Encode(serial))

        session = Session()
        #TODO: load the team, see what's different, and change those fields
        team = session.query(Team).filter_by(id=kwargs["team_id"]).first()
        if team.name != kwargs["name"]: 
            team.name = kwargs.name
        if team.description != kwargs["description"]: 
            team.description = kwargs["description"]
        if team.fullsize != kwargs["fullsize"]:
            team.fullsize = kwargs["fullsize"]
        if "password" in kwargs:
            team.password = encrypt(kwargs["password"])
        session.commit()
        session.close()
        raise cpy.HTTPRedirect("/admin/lsteam/")
예제 #5
0
def auth():
    session = Session()
    users = dict(
        (str(t.name), str(t.password)) for t in session.query(Team).all())
    session.close()
    return users
예제 #6
0
 def getteam(self, name, default):
     session = Session()
     team = session.query(Team).filter_by(name=name).first() or default
     session.close()
     return team
예제 #7
0
 def lsteam(self):
     session = Session()
     teams = session.query(Team).all()
     session.close()
     #TODO: move the admin templates into a subdir?
     return ("lsteam", {"teams": teams})
예제 #8
0
def auth():
    session = Session()
    users = dict((str(t.name), str(t.password)) for t in session.query(Team).all())
    session.close()
    return users