def delete(self, performance_number): user_id = verify_auth() performance = Performance.query.filter_by( id=performance_number).first() if performance is None: raise NotFound() db.session.remove(performance) db.session.commit() return performance
def post(self): user_id = verify_auth() user = User.query.filter_by(id=user_id).first() if user is None: raise NotFound() data = request.get_json() departure_station = data['departure_station'] departure_time = datetime.datetime.utcnow() distance = data['distance'] performance = Performance(user, departure_station, departure_time, distance) return performance
def put(self, station_number): user_id = verify_auth() station = Station.query.filter_by(number=station_number).first() if station is None: raise NotFound() user = User.query.filter_by(id=user_id).first() if user is None: raise NotFound() user.bookmarks.append(station) db.session.commit() return user.bookmarks
def put(self, performance_number): user_id = verify_auth() data = request.get_json() performance = Performance.query.filter_by( id=performance_number).first() if performance is None: raise NotFound() performance.arrival_loc = data['arrival_loc'] performance.arrival_time = datetime.datetime.utcnow() duration = (performance.arrival_time - performance.departure_time ).total_seconds() # mean_speed in m/s --> performance.distance in meter mean_speed = performance.distance / duration db.session.remove(performance) db.session.add(performance) db.session.commit() return performance
def put(self, performance_number): user_id = verify_auth() data = request.get_json() performance = Performance.query.filter_by( id=performance_number).first() if performance is None: raise NotFound() performance.arrival_loc = data['arrival_loc'] performance.arrival_time = datetime.datetime.utcnow() duration = (performance.arrival_time - performance.departure_time).total_seconds() # mean_speed in m/s --> performance.distance in meter mean_speed = performance.distance / duration db.session.remove(performance) db.session.add(performance) db.session.commit() return performance
def get(self): user_id = verify_auth() performances = Performance.query.filter( Performance.users.any(id=user_id)).all() return performances
def get(self): user_id = verify_auth() user = User.query.filter_by(id=user_id).first() return user
def get(self): user_id = verify_auth() stations = Station.query.filter(Station.users.any(id=user_id)).all() return stations