summaryrefslogtreecommitdiff
path: root/server/szurubooru/func/posts.py
diff options
context:
space:
mode:
authorrr- <rr-@sakuya.pl>2017-01-03 21:37:38 +0100
committerrr- <rr-@sakuya.pl>2017-01-03 21:37:38 +0100
commit9edaaffec230130566289deb16cc79ee37597a9e (patch)
treec1e2143d21af115ec466cd8caa80fc0b6c735bd1 /server/szurubooru/func/posts.py
parent627574a9c2f9c6e1f048ba945357426fb4783812 (diff)
server/posts: fix post relations
Trying to relate post to itself resulted in 500 ISE.
Diffstat (limited to 'server/szurubooru/func/posts.py')
-rw-r--r--server/szurubooru/func/posts.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/server/szurubooru/func/posts.py b/server/szurubooru/func/posts.py
index 6ff3a87..d190b8d 100644
--- a/server/szurubooru/func/posts.py
+++ b/server/szurubooru/func/posts.py
@@ -377,6 +377,8 @@ def update_post_relations(post, new_post_ids):
.all()
if len(new_posts) != len(new_post_ids):
raise InvalidPostRelationError('One of relations does not exist.')
+ if post.post_id in new_post_ids:
+ raise InvalidPostRelationError('Post cannot relate to itself.')
relations_to_del = [p for p in old_posts if p.post_id not in new_post_ids]
relations_to_add = [p for p in new_posts if p.post_id not in old_post_ids]