Commit b85791d5 by benjaoming

Message after uploading image. Do not redirect after plugin form submit as…

Message after uploading image. Do not redirect after plugin form submit as changes to article text and title are lost.
parent 0863c41a
......@@ -24,7 +24,9 @@ class BasePlugin(object):
class PluginSidebarFormMixin(object):
pass
def get_usermessage(self):
pass
class PluginSettingsFormMixin(object):
settings_form_headline = _(u'Notifications')
......
from django import forms
from django.utils.translation import ugettext as _
from wiki.plugins import PluginSidebarFormMixin
from wiki.plugins.images import models
......@@ -9,7 +10,10 @@ class SidebarForm(forms.ModelForm, PluginSidebarFormMixin):
def __init__(self, *args, **kwargs):
self.article = kwargs.pop('article')
super(SidebarForm, self).__init__(*args, **kwargs)
def get_usermessage(self):
return _(u"New image %s was successfully uploaded. You can use it by selecting it from the list of available images.") % self.instance.get_filename()
class Meta:
model = models.Image
fields = ('image',)
\ No newline at end of file
......@@ -3,4 +3,7 @@ from django.conf import settings as django_settings
# Where to store images
IMAGE_PATH = getattr(django_settings, 'WIKI_IMAGE_PATH', "wiki/images/%aid/")
# Allow anonymous users to upload (not nice on an open network)
ANONYMOUS = getattr(django_settings, 'WIKI_ATTACHMENTS_ANONYMOUS', False)
SLUG = 'images'
\ No newline at end of file
......@@ -256,10 +256,13 @@ class Edit(FormView, ArticleMixin):
form = self.sidebar_forms[plugin.sidebar_form_context]
if form.is_valid():
form.save()
if self.urlpath:
return redirect('wiki:edit', path=self.urlpath.path)
else:
return redirect('wiki:edit', article_id=self.article.id)
message = form.get_usermessage()
if message:
messages.success(request, message)
#if self.urlpath:
# return redirect('wiki:edit', path=self.urlpath.path)
#else:
# return redirect('wiki:edit', article_id=self.article.id)
if self.request.POST.get('save', '') == '1':
return super(Edit, self).post(request, *args, **kwargs)
......
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