diff --git a/API.md b/API.md index e5b8571c..cb827ddc 100644 --- a/API.md +++ b/API.md @@ -486,7 +486,6 @@ data. - **Errors** - the tag does not exist - - the tag is used by some posts - privileges are too low - **Description** diff --git a/server/szurubooru/api/tag_api.py b/server/szurubooru/api/tag_api.py index 72e29ffd..c5322662 100644 --- a/server/szurubooru/api/tag_api.py +++ b/server/szurubooru/api/tag_api.py @@ -90,10 +90,6 @@ class TagDetailApi(BaseApi): def delete(self, ctx, tag_name): tag = tags.get_tag_by_name(tag_name) - if tag.post_count > 0: - raise tags.TagIsInUseError( - 'Tag has some usages and cannot be deleted. ' + - 'Please untag relevant posts first.') auth.verify_privilege(ctx.user, 'tags:delete') snapshots.save_entity_deletion(tag, ctx.user) tags.delete(tag) diff --git a/server/szurubooru/tests/api/test_tag_deleting.py b/server/szurubooru/tests/api/test_tag_deleting.py index 634962fb..bb7cd498 100644 --- a/server/szurubooru/tests/api/test_tag_deleting.py +++ b/server/szurubooru/tests/api/test_tag_deleting.py @@ -31,18 +31,19 @@ def test_deleting(test_ctx): assert db.session.query(db.Tag).count() == 0 assert os.path.exists(os.path.join(config.config['data_dir'], 'tags.json')) -def test_trying_to_delete_used(test_ctx, post_factory): +def test_deleting_used(test_ctx, post_factory): tag = test_ctx.tag_factory(names=['tag']) post = post_factory() post.tags.append(tag) db.session.add_all([tag, post]) db.session.commit() - with pytest.raises(tags.TagIsInUseError): - test_ctx.api.delete( - test_ctx.context_factory( - user=test_ctx.user_factory(rank=db.User.RANK_REGULAR)), - 'tag') - assert db.session.query(db.Tag).count() == 1 + test_ctx.api.delete( + test_ctx.context_factory( + user=test_ctx.user_factory(rank=db.User.RANK_REGULAR)), + 'tag') + db.session.refresh(post) + assert db.session.query(db.Tag).count() == 0 + assert post.tags == [] def test_trying_to_delete_non_existing(test_ctx): with pytest.raises(tags.TagNotFoundError):