Commit 751c21ad by benjaoming

Better error if permissions are wrong on MEDIA_ROOT

parent b6e7b94d
...@@ -13,6 +13,7 @@ from django.views.generic.base import TemplateView, View ...@@ -13,6 +13,7 @@ from django.views.generic.base import TemplateView, View
from wiki.core.http import send_file from wiki.core.http import send_file
from django.http import Http404 from django.http import Http404
from django.db import transaction from django.db import transaction
import os
class AttachmentView(ArticleMixin, FormView): class AttachmentView(ArticleMixin, FormView):
...@@ -29,6 +30,7 @@ class AttachmentView(ArticleMixin, FormView): ...@@ -29,6 +30,7 @@ class AttachmentView(ArticleMixin, FormView):
# Fixing some weird transaction issue caused by adding commit_manually to form_valid # Fixing some weird transaction issue caused by adding commit_manually to form_valid
return super(AttachmentView, self).dispatch(request, article, *args, **kwargs) return super(AttachmentView, self).dispatch(request, article, *args, **kwargs)
# WARNING! The below decorator silences other exceptions that may occur!
@transaction.commit_manually @transaction.commit_manually
def form_valid(self, form): def form_valid(self, form):
try: try:
...@@ -45,6 +47,9 @@ class AttachmentView(ArticleMixin, FormView): ...@@ -45,6 +47,9 @@ class AttachmentView(ArticleMixin, FormView):
except models.IllegalFileExtension, e: except models.IllegalFileExtension, e:
transaction.rollback() transaction.rollback()
messages.error(self.request, _(u'Your file could not be saved: %s') % e) messages.error(self.request, _(u'Your file could not be saved: %s') % e)
except IOError:
transaction.rollback()
messages.error(self.request, _(u'Your file could not be saved, probably because of a permission error on the web server.'))
transaction.commit() transaction.commit()
if self.urlpath: if self.urlpath:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment