Permalink
Browse files

Reformatted some code to fit on one line

  • Loading branch information...
atombrella committed Oct 7, 2017
1 parent 14c1731 commit d8e81c779d271da2acc4c1b80327fe5b671b92b5
View
@@ -285,8 +285,7 @@ def clean(self):
'While you were editing, someone else changed the revision. Your contents have been automatically merged with the new contents. Please review the text below.'))
if ('title' in cd) and cd['title'] == self.initial_revision.title and cd[
'content'] == self.initial_revision.content:
raise forms.ValidationError(
ugettext('No changes made. Nothing to save.'))
raise forms.ValidationError(ugettext('No changes made. Nothing to save.'))
self.check_spam()
return cd
@@ -347,19 +346,11 @@ def render_options(self, choices, selected_choices):
if isinstance(option_label, (list, tuple)):
output.append(
'<li class="divider" label="%s"></li>' %
escape(
force_text(option_value)))
escape(force_text(option_value)))
for option in option_label:
output.append(
self.render_option(
selected_choices,
*option))
output.append(self.render_option(selected_choices, *option))
else:
output.append(
self.render_option(
selected_choices,
option_value,
option_label))
output.append(self.render_option(selected_choices, option_value, option_label))
return '\n'.join(output)
class Media(forms.Media):
@@ -464,28 +455,24 @@ class PermissionsForm(PluginSettingsFormMixin, forms.ModelForm):
recursive = forms.BooleanField(
label=_('Inherit permissions'),
help_text=_(
'Check here to apply the above permissions (excluding group and owner of the article) recursively to articles below this one.'),
help_text=_('Check here to apply the above permissions (excluding group and owner of the article) recursively to articles below this one.'),
required=False)
recursive_owner = forms.BooleanField(
label=_('Inherit owner'),
help_text=_(
'Check here to apply the ownership setting recursively to articles below this one.'),
help_text=_('Check here to apply the ownership setting recursively to articles below this one.'),
required=False)
recursive_group = forms.BooleanField(
label=_('Inherit group'),
help_text=_(
'Check here to apply the group setting recursively to articles below this one.'),
help_text=_('Check here to apply the group setting recursively to articles below this one.'),
required=False)
def get_usermessage(self):
if self.changed_data:
return _('Permission settings for the article were updated.')
else:
return _(
'Your permission settings were unchanged, so nothing saved.')
return _('Your permission settings were unchanged, so nothing saved.')
def __init__(self, article, request, *args, **kwargs):
self.article = article
@@ -662,6 +649,7 @@ class Meta:
model = User
fields = ("username", "email")
class UserUpdateForm(forms.ModelForm):
password1 = forms.CharField(label="New password", widget=forms.PasswordInput(), required=False)
password2 = forms.CharField(label="Confirm password", widget=forms.PasswordInput(), required=False)
@@ -39,13 +39,7 @@ def dispatch(self, request, article, *args, **kwargs):
# 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)
def form_valid(self, form):
@@ -89,8 +83,7 @@ def get_context_data(self, **kwargs):
current_revision__deleted=True)
kwargs['search_form'] = forms.SearchForm()
kwargs['selected_tab'] = 'attachments'
kwargs['anonymous_disallowed'] = self.request.user.is_anonymous(
) and not settings.ANONYMOUS
kwargs['anonymous_disallowed'] = self.request.user.is_anonymous() and not settings.ANONYMOUS
return super(AttachmentView, self).get_context_data(**kwargs)
@@ -110,13 +103,7 @@ def dispatch(self, request, article, attachment_id, *args, **kwargs):
models.Attachment.objects.active(),
id=attachment_id,
articles=article)
return super(
AttachmentHistoryView,
self).dispatch(
request,
article,
*args,
**kwargs)
return super(AttachmentHistoryView, self).dispatch(request, article, *args, **kwargs)
def get_context_data(self, **kwargs):
kwargs['attachment'] = self.attachment
@@ -134,12 +121,7 @@ class AttachmentReplaceView(ArticleMixin, FormView):
@method_decorator(get_article(can_write=True, not_locked=True))
def dispatch(self, request, article, attachment_id, *args, **kwargs):
if request.user.is_anonymous() and not settings.ANONYMOUS:
return response_forbidden(
request,
article,
kwargs.get(
'urlpath',
None))
return response_forbidden(request, article, kwargs.get('urlpath', None))
if article.can_moderate(request.user):
self.attachment = get_object_or_404(
models.Attachment,
@@ -152,13 +134,7 @@ def dispatch(self, request, article, attachment_id, *args, **kwargs):
id=attachment_id,
articles=article)
self.can_moderate = False
return super(
AttachmentReplaceView,
self).dispatch(
request,
article,
*args,
**kwargs)
return super(AttachmentReplaceView, self).dispatch(request, article, *args, **kwargs)
def get_form_class(self):
if self.can_moderate:
@@ -181,10 +157,7 @@ def form_valid(self, form):
attachment_revision.get_filename())
self.article.clear_cache()
except models.IllegalFileExtension as e:
messages.error(
self.request,
_('Your file could not be saved: %s') %
e)
messages.error(self.request, _('Your file could not be saved: %s') % e)
return redirect(
"wiki:attachments_replace",
attachment_id=self.attachment.id,
@@ -256,13 +229,7 @@ def dispatch(self, request, article, attachment_id, *args, **kwargs):
attachment__articles=article)
else:
self.revision = self.attachment.current_revision
return super(
AttachmentDownloadView,
self).dispatch(
request,
article,
*args,
**kwargs)
return super(AttachmentDownloadView, self).dispatch(request, article, *args, **kwargs)
def get(self, request, *args, **kwargs):
if self.revision:
@@ -286,14 +253,7 @@ class AttachmentChangeRevisionView(ArticleMixin, View):
template_name = "wiki/plugins/attachments/replace.html"
@method_decorator(get_article(can_write=True, not_locked=True))
def dispatch(
self,
request,
article,
attachment_id,
revision_id,
*args,
**kwargs):
def dispatch(self, request, article, attachment_id, revision_id, *args, **kwargs):
if article.can_moderate(request.user):
self.attachment = get_object_or_404(
models.Attachment,
@@ -308,13 +268,7 @@ def dispatch(
models.AttachmentRevision,
id=revision_id,
attachment__articles=article)
return super(
AttachmentChangeRevisionView,
self).dispatch(
request,
article,
*args,
**kwargs)
return super(AttachmentChangeRevisionView, self).dispatch(request, article, *args, **kwargs)
def post(self, request, *args, **kwargs):
self.attachment.current_revision = self.revision
@@ -345,13 +299,7 @@ def dispatch(self, request, article, attachment_id, *args, **kwargs):
models.Attachment.objects.active().can_write(
request.user),
id=attachment_id)
return super(
AttachmentAddView,
self).dispatch(
request,
article,
*args,
**kwargs)
return super(AttachmentAddView, self).dispatch(request, article, *args, **kwargs)
def post(self, request, *args, **kwargs):
if not self.attachment.articles.filter(id=self.article.id):
@@ -380,24 +328,10 @@ class AttachmentDeleteView(ArticleMixin, FormView):
@method_decorator(get_article(can_write=True, not_locked=True))
def dispatch(self, request, article, attachment_id, *args, **kwargs):
self.attachment = get_object_or_404(
models.Attachment,
id=attachment_id,
articles=article)
self.attachment = get_object_or_404(models.Attachment, id=attachment_id, articles=article)
if not self.attachment.can_delete(request.user):
return response_forbidden(
request,
article,
kwargs.get(
'urlpath',
None))
return super(
AttachmentDeleteView,
self).dispatch(
request,
article,
*args,
**kwargs)
return response_forbidden(request, article, kwargs.get('urlpath', None))
return super(AttachmentDeleteView, self).dispatch(request, article, *args, **kwargs)
def form_valid(self, form):
@@ -412,21 +346,15 @@ def form_valid(self, form):
self.attachment.current_revision = revision
self.attachment.save()
self.article.clear_cache()
messages.info(
self.request,
_('The file %s was deleted.') %
self.attachment.original_filename)
messages.info(self.request, _('The file %s was deleted.') % self.attachment.original_filename)
else:
self.attachment.articles.remove(self.article)
messages.info(
self.request,
_('This article is no longer related to the file %s.') %
self.attachment.original_filename)
self.article.clear_cache()
return redirect(
"wiki:get",
path=self.urlpath.path,
article_id=self.article.id)
return redirect("wiki:get", path=self.urlpath.path, article_id=self.article.id)
def get_context_data(self, **kwargs):
kwargs['attachment'] = self.attachment
@@ -446,12 +374,7 @@ class AttachmentSearchView(ArticleMixin, ListView):
@method_decorator(get_article(can_write=True))
def dispatch(self, request, article, *args, **kwargs):
return super(AttachmentSearchView, self).dispatch(
request,
article,
*args,
**kwargs
)
return super(AttachmentSearchView, self).dispatch(request, article, *args, **kwargs)
def get_queryset(self):
self.query = self.request.GET.get('query', None)
@@ -30,13 +30,7 @@ class ImageView(ArticleMixin, ListView):
@method_decorator(get_article(can_read=True, not_locked=True))
def dispatch(self, request, article, *args, **kwargs):
return super(
ImageView,
self).dispatch(
request,
article,
*args,
**kwargs)
return super(ImageView, self).dispatch(request, article, *args, **kwargs)
def get_queryset(self):
if (self.article.can_moderate(self.request.user) or
@@ -83,24 +77,12 @@ def get_redirect_url(self, **kwargs):
self.image.current_revision = new_revision
self.image.save()
if self.restore:
messages.info(
self.request,
_('%s has been restored') %
new_revision.get_filename())
messages.info(self.request, _('%s has been restored') % new_revision.get_filename())
else:
messages.info(
self.request,
_('%s has been marked as deleted') %
new_revision.get_filename())
messages.info(self.request, _('%s has been marked as deleted') % new_revision.get_filename())
if self.urlpath:
return reverse(
'wiki:images_index',
kwargs={
'path': self.urlpath.path})
return reverse(
'wiki:images_index',
kwargs={
'article_id': self.article.id})
return reverse('wiki:images_index', kwargs={'path': self.urlpath.path})
return reverse('wiki:images_index', kwargs={'article_id': self.article.id})
class PurgeView(ArticleMixin, FormView):
@@ -113,12 +95,11 @@ class PurgeView(ArticleMixin, FormView):
def dispatch(self, request, article, *args, **kwargs):
self.image = get_object_or_404(models.Image, article=article,
id=kwargs.get('image_id', None))
return ArticleMixin.dispatch(self, request, article, *args, **kwargs)
return super(PurgeView, self).dispatch(request, article, *args, **kwargs)
def form_valid(self, form):
for revision in self.image.revision_set.all().select_related(
"imagerevision"):
for revision in self.image.revision_set.all().select_related("imagerevision"):
revision.imagerevision.image.delete(save=False)
revision.imagerevision.delete()
@@ -17,12 +17,7 @@ class NotificationSettings(FormView):
@method_decorator(login_required)
def dispatch(self, request, *args, **kwargs):
return super(
NotificationSettings,
self).dispatch(
request,
*args,
**kwargs)
return super(NotificationSettings, self).dispatch(request, *args, **kwargs)
def form_valid(self, formset):
for form in formset:
Oops, something went wrong.

0 comments on commit d8e81c7

Please sign in to comment.