Ejemplo n.º 1
0
 def get(self) -> Response:
     """
     GET request method for retrieving all meals documents.
     JSON Web Token is required.
     """
     output = Meals.objects()
     return jsonify({'result': output})
Ejemplo n.º 2
0
 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})
Ejemplo n.º 3
0
    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()
Ejemplo n.º 4
0
 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})
Ejemplo n.º 5
0
    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()
Ejemplo n.º 6
0
 def put(self, meal_id: str) :
     
     data = request.get_json()
     put_user = Meals.objects(id=meal_id).update(**data)
     return jsonify({'result': put_user})
Ejemplo n.º 7
0
 def get(self):
    
     output = Meals.objects()
     return jsonify({'result': output})