def get(self): team = get_current_team() awards = team.get_awards(admin=True) schema = AwardSchema(many=True) response = schema.dump(awards) if response.errors: return {"success": False, "errors": response.errors}, 400 return {"success": True, "data": response.data}
def get(self, team_id): team = Teams.query.filter_by(id=team_id).first_or_404() if (team.banned or team.hidden) and is_admin() is False: abort(404) awards = team.get_awards(admin=is_admin()) schema = AwardSchema(many=True) response = schema.dump(awards) if response.errors: return {"success": False, "errors": response.errors}, 400 return {"success": True, "data": response.data}
def post(self): req = request.get_json() schema = AwardSchema() response = schema.load(req, session=db.session) if response.errors: return {"success": False, "errors": response.errors}, 400 db.session.add(response.data) db.session.commit() response = schema.dump(response.data) db.session.close() # Delete standings cache because awards can change scores clear_standings() return {"success": True, "data": response.data}