Beispiel #1
0
 def post(self, team_id):
     if TeamModel.find_by_id(team_id):
         return {"msg": "Team already exist"}, 400
     data = self.parser.parse_args()
     new_team = TeamModel(team_id, **data)
     new_team.save_to_db()
     return new_team.json(), 201
Beispiel #2
0
    def post(self, business_name):
        if TeamModel.find_by_business_name(business_name):
            return {'message': "That team already exists!"}

        data = Team.parser.parse_args()
        print(data['location'])
        new_team = TeamModel(business_name, data['location'])

        new_team.save_to_db()

        return new_team.json(), 201  # 201 status code means created
    def put(self, name):
        data = Team.parser.parse_args()

        team = TeamModel.find_by_name(name)

        if team is None:
            team = TeamModel(name, data['division'])
        else:
            team.division = data['division']

        team.save_to_db()

        return team.json()
Beispiel #4
0
    def put(self, team_id):
        data = self.parser.parse_args()

        team = TeamModel.find_by_id(team_id)

        if team is None:
            team = TeamModel(team_id, **data)

        else:
            team.team_name = data["team_name"]

        team.save_to_db()
        return team.json()
Beispiel #5
0
    def post(self, name):
        if TeamModel.find_by_name(name):
            return {
                'message': "A team with name '{}' already exists.".format(name)
            }, 400

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

        return team.json(), 201
    def post(self, name, division=None):
        data = Team.parser.parse_args()

        if TeamModel.find_by_name(name):
            return {"message": "{} already exists".format(name)}
        team = TeamModel(name, data['division'])
        try:
            team.save_to_db()
        except:
            return {
                "message": "An error occured while creating the team."
            }, 500

        return team.json()
Beispiel #7
0
    def put(self, business_name):
        data = Team.parser.parse_args()

        team = TeamModel.find_by_business_name(business_name)

        if team is None:
            # team = TeamModel(name, data['price'], data['storebusiness_name'])
            team = TeamModel(**data)
        else:
            team.business_name = business_name
            team.location = data['location']

        team.save_to_db()
        return team.json()
Beispiel #8
0
def check_in(data):
    server_data = {
        'groupName': data['groupName'],
        'time_stamp': datetime.datetime.now(),
        'gate': data['gate'],
        'inout': data['inout']
    }
    prog = TeamModel(name=server_data['groupName'],
                     time_stamp=server_data['time_stamp'],
                     gate=server_data['gate'],
                     inout=server_data['inout']
                     )  # data = {groupName:gpName, gate:'', inout:'in'};
    prog.save_to_db()

    server_data['time_stamp'] = datetime.datetime.strftime(
        server_data['time_stamp'], '%c')
    socketio.emit('reply', server_data)
    ret = prog.find_interval()
    if ret:
        emit('status', {'data': ret}, broadcast=True)