예제 #1
0
    def post(self, name):
        if TeamModel.lookup(name):
            return {
                'message': "A team with name '{}' already exists.".format(name)
            }, 400

        team = TeamModel(name)
        try:
            team.save()
        except:
            return {"message": "An error occurred creating the team."}, 500

        return team.json(), 201
예제 #2
0
 def get(self, name):
     team = TeamModel.lookup(name)
     if team:
         return team.json()
     return {'message': 'Team not found'}, 404
예제 #3
0
    def delete(self, name):
        team = TeamModel.lookup(name)
        if team:
            team.delete()

        return {'message': 'Team deleted'}