Do not add tag to non-saved objects (#7266)

This commit is contained in:
Beto Dealmeida 2019-04-09 20:51:42 -07:00 committed by GitHub
parent e505e326b2
commit 9856800cee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -77,6 +77,9 @@ class TagView(BaseSupersetView):
@expose('/tags/<object_type:object_type>/<int:object_id>/', methods=['GET'])
def get(self, object_type, object_id):
"""List all tags a given object has."""
if object_id == 0:
return json_success(json.dumps([]))
query = db.session.query(TaggedObject).filter(and_(
TaggedObject.object_type == object_type,
TaggedObject.object_id == object_id))
@ -87,6 +90,9 @@ class TagView(BaseSupersetView):
@expose('/tags/<object_type:object_type>/<int:object_id>/', methods=['POST'])
def post(self, object_type, object_id):
"""Add new tags to an object."""
if object_id == 0:
return Response(status=404)
tagged_objects = []
for name in request.get_json(force=True):
if ':' in name: