aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/edit
diff options
context:
space:
mode:
authorayleph <ayleph@thisshitistemp.com>2017-06-27 22:45:42 -0700
committerAndrew Browning <ayleph@thisshitistemp.com>2017-08-15 01:43:58 -0400
commit2f2b4cbacb72cbeb21d51323296fb90a20c81737 (patch)
treefc5ff942c00542f54ab01ec099a992ef6e011896 /mediagoblin/edit
parent1f8c877d7430c1101740ef6ee732e90ff4c9cfdc (diff)
downloadmediagoblin-2f2b4cbacb72cbeb21d51323296fb90a20c81737.tar.lz
mediagoblin-2f2b4cbacb72cbeb21d51323296fb90a20c81737.tar.xz
mediagoblin-2f2b4cbacb72cbeb21d51323296fb90a20c81737.zip
Fix #5513 - Can't delete blog post drafts
Modify the @get_media_entry_by_id decorator to return media regardless of processing state. Separately modify all view functions that use the @get_media_entry_by_id decorator to require that the media be in the processed state, other than for the media_confirm_delete view. This allows blog post drafts to be deleted without returning a 404. Further, it adds the ability to delete unprocessed media in the future, which would be a nice addition to the user processing panel.
Diffstat (limited to 'mediagoblin/edit')
-rw-r--r--mediagoblin/edit/views.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/mediagoblin/edit/views.py b/mediagoblin/edit/views.py
index b15fb2e7..17aea922 100644
--- a/mediagoblin/edit/views.py
+++ b/mediagoblin/edit/views.py
@@ -55,6 +55,10 @@ import mimetypes
@get_media_entry_by_id
@require_active_login
def edit_media(request, media):
+ # If media is not processed, return NotFound.
+ if not media.state == u'processed':
+ return render_404(request)
+
if not may_edit_media(request, media):
raise Forbidden("User may not edit this media")
@@ -115,6 +119,10 @@ UNSAFE_MIMETYPES = [
@get_media_entry_by_id
@require_active_login
def edit_attachments(request, media):
+ # If media is not processed, return NotFound.
+ if not media.state == u'processed':
+ return render_404(request)
+
if mg_globals.app_config['allow_attachments']:
form = forms.EditAttachmentsForm()
@@ -499,6 +507,10 @@ def change_email(request):
@require_active_login
@get_media_entry_by_id
def edit_metadata(request, media):
+ # If media is not processed, return NotFound.
+ if not media.state == u'processed':
+ return render_404(request)
+
form = forms.EditMetaDataForm(request.form)
if request.method == "POST" and form.validate():
metadata_dict = dict([(row['identifier'],row['value'])