def get(self) -> Response: """ GET request method for retrieving all meals documents. JSON Web Token is required. """ output = Meals.objects() return jsonify({'result': output})
def get(self) -> Response: """ GET response method for all documents in meal collection. JSON Web Token is required. :return: JSON object """ output = Meals.objects() return jsonify({'result': output})
def delete(self, user_id: str) : authorized: bool = Users.objects.get(id=get_jwt_identity()).access.admin if authorized: output = Meals.objects(id=user_id).delete() return jsonify({'result': output}) else: return forbidden()
def put(self, meal_id: str) -> Response: """ PUT response method for updating a meal. JSON Web Token is required. Authorization is required: Access(admin=true) :return: JSON object """ data = request.get_json() put_user = Meals.objects(id=meal_id).update(**data) return jsonify({'result': put_user})
def delete(self, user_id: str) -> Response: """ DELETE response method for deleting single meal. JSON Web Token is required. Authorization is required: Access(admin=true) :return: JSON object """ authorized: bool = Meals.objects.get( id=get_jwt_identity()).access.admin if authorized: output = Meals.objects(id=user_id).delete() return jsonify({'result': output}) else: return forbidden()
def put(self, meal_id: str) : data = request.get_json() put_user = Meals.objects(id=meal_id).update(**data) return jsonify({'result': put_user})
def get(self): output = Meals.objects() return jsonify({'result': output})