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"
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/")
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/")
def auth(): session = Session() users = dict( (str(t.name), str(t.password)) for t in session.query(Team).all()) session.close() return users
def getteam(self, name, default): session = Session() team = session.query(Team).filter_by(name=name).first() or default session.close() return team
def lsteam(self): session = Session() teams = session.query(Team).all() session.close() #TODO: move the admin templates into a subdir? return ("lsteam", {"teams": teams})
def auth(): session = Session() users = dict((str(t.name), str(t.password)) for t in session.query(Team).all()) session.close() return users