From 8674c8b50e9988162aeeb57df23ef334f2701e93 Mon Sep 17 00:00:00 2001 From: rr- Date: Sat, 10 Sep 2016 10:14:53 +0200 Subject: server/posts: report duplicate post ID and URL --- server/szurubooru/func/posts.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'server/szurubooru/func/posts.py') diff --git a/server/szurubooru/func/posts.py b/server/szurubooru/func/posts.py index b7ffe2b..3863e5b 100644 --- a/server/szurubooru/func/posts.py +++ b/server/szurubooru/func/posts.py @@ -20,7 +20,13 @@ class PostAlreadyFeaturedError(errors.ValidationError): class PostAlreadyUploadedError(errors.ValidationError): - pass + def __init__(self, other_post): + super().__init__( + 'Post already uploaded (%d)' % other_post.post_id, + { + 'otherPostUrl': get_post_content_url(other_post), + 'otherPostId': other_post.post_id, + }) class InvalidPostIdError(errors.ValidationError): @@ -303,8 +309,7 @@ def update_post_content(post, content): if other_post \ and other_post.post_id \ and other_post.post_id != post.post_id: - raise PostAlreadyUploadedError( - 'Post already uploaded (%d)' % other_post.post_id) + raise PostAlreadyUploadedError(other_post) post.file_size = len(content) try: -- cgit v1.3