示例#1
0
    def get(self) -> Response:
        """
        GET response method for all documents in product collection.
        JSON Web Token is required.

        :return: JSON object
        """
        output = Products.objects()
        return jsonify({'result': output})
示例#2
0
    def put(self, product_id: str) -> Response:
        """
        PUT response method for updating a product.
        JSON Web Token is required.
        Authorization is required: Access(admin=true)

        :return: JSON object
        """
        data = request.get_json()
        put_user = Products.objects(id=product_id).update(**data)
        return jsonify({'result': put_user})
示例#3
0
    def delete(self, user_id: str) -> Response:
        """
        DELETE response method for deleting single product.
        JSON Web Token is required.
        Authorization is required: Access(admin=true)

        :return: JSON object
        """
        #authorized: bool = Products.objects.get(id=get_jwt_identity()).access.admin

        if True:
            output = Products.objects(id=user_id).delete()
            return jsonify({'result': output})
        else:
            return forbidden()
示例#4
0
def get_detail(id):

    docs = Products.objects(id=id)
    return jsonify(docs), 200
示例#5
0
def get_list():
    docs = Products.objects()
    return jsonify(docs), 200