server/posts: report duplicate post ID and URL
This commit is contained in:
parent
0a19e7bbd0
commit
8674c8b50e
3 changed files with 10 additions and 3 deletions
|
@ -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:
|
||||
|
|
|
@ -261,6 +261,7 @@ def test_errors_not_spending_ids(
|
|||
config_injector, tmpdir, context_factory, read_asset, user_factory):
|
||||
config_injector({
|
||||
'data_dir': str(tmpdir.mkdir('data')),
|
||||
'data_url': 'example.com',
|
||||
'thumbnails': {
|
||||
'post_width': 300,
|
||||
'post_height': 300,
|
||||
|
|
|
@ -329,6 +329,7 @@ def test_update_post_content_to_existing_content(
|
|||
tmpdir, config_injector, post_factory, read_asset):
|
||||
config_injector({
|
||||
'data_dir': str(tmpdir.mkdir('data')),
|
||||
'data_url': 'example.com',
|
||||
'thumbnails': {
|
||||
'post_width': 300,
|
||||
'post_height': 300,
|
||||
|
|
Loading…
Reference in a new issue