mirror of
https://github.com/apache/superset.git
synced 2026-05-12 19:35:17 +00:00
Do not add tag to non-saved objects (#7266)
This commit is contained in:
@@ -77,6 +77,9 @@ class TagView(BaseSupersetView):
|
|||||||
@expose('/tags/<object_type:object_type>/<int:object_id>/', methods=['GET'])
|
@expose('/tags/<object_type:object_type>/<int:object_id>/', methods=['GET'])
|
||||||
def get(self, object_type, object_id):
|
def get(self, object_type, object_id):
|
||||||
"""List all tags a given object has."""
|
"""List all tags a given object has."""
|
||||||
|
if object_id == 0:
|
||||||
|
return json_success(json.dumps([]))
|
||||||
|
|
||||||
query = db.session.query(TaggedObject).filter(and_(
|
query = db.session.query(TaggedObject).filter(and_(
|
||||||
TaggedObject.object_type == object_type,
|
TaggedObject.object_type == object_type,
|
||||||
TaggedObject.object_id == object_id))
|
TaggedObject.object_id == object_id))
|
||||||
@@ -87,6 +90,9 @@ class TagView(BaseSupersetView):
|
|||||||
@expose('/tags/<object_type:object_type>/<int:object_id>/', methods=['POST'])
|
@expose('/tags/<object_type:object_type>/<int:object_id>/', methods=['POST'])
|
||||||
def post(self, object_type, object_id):
|
def post(self, object_type, object_id):
|
||||||
"""Add new tags to an object."""
|
"""Add new tags to an object."""
|
||||||
|
if object_id == 0:
|
||||||
|
return Response(status=404)
|
||||||
|
|
||||||
tagged_objects = []
|
tagged_objects = []
|
||||||
for name in request.get_json(force=True):
|
for name in request.get_json(force=True):
|
||||||
if ':' in name:
|
if ':' in name:
|
||||||
|
|||||||
Reference in New Issue
Block a user