From 9cf7eb28714374326d9bea4834d63d0bcdcf374f Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Tue, 19 Feb 2013 01:05:40 -0500 Subject: [PATCH] adds feature #560 --- djangobb_forum/forms.py | 2 +- djangobb_forum/templates/djangobb_forum/edit_post.html | 7 ++++++- djangobb_forum/views.py | 7 +++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/djangobb_forum/forms.py b/djangobb_forum/forms.py index 81e0b4f..7e4df42 100644 --- a/djangobb_forum/forms.py +++ b/djangobb_forum/forms.py @@ -160,6 +160,7 @@ class AddPostForm(forms.ModelForm): class EditPostForm(forms.ModelForm): name = forms.CharField(required=False, label=_('Subject'), widget=forms.TextInput(attrs={'size':'115'})) + silent_edit = forms.BooleanField(required=False, label=_('Silent edit?')) class Meta: model = Post @@ -188,7 +189,6 @@ class EditPostForm(forms.ModelForm): def save(self, commit=True): post = super(EditPostForm, self).save(commit=False) - post.updated = now() topic_name = self.cleaned_data['name'] if topic_name: post.topic.name = topic_name diff --git a/djangobb_forum/templates/djangobb_forum/edit_post.html b/djangobb_forum/templates/djangobb_forum/edit_post.html index 6349c46..b5703c7 100644 --- a/djangobb_forum/templates/djangobb_forum/edit_post.html +++ b/djangobb_forum/templates/djangobb_forum/edit_post.html @@ -35,7 +35,12 @@ {{ form.body.errors }} {{ form.body }} - + {% if moderator %} + + {% endif %}

{% trans "Go back" %} diff --git a/djangobb_forum/views.py b/djangobb_forum/views.py index e787048..ebf0021 100644 --- a/djangobb_forum/views.py +++ b/djangobb_forum/views.py @@ -667,22 +667,25 @@ def get_topic_title(request, topic_id): @transaction.commit_on_success def edit_post(request, post_id): from djangobb_forum.templatetags.forum_extras import forum_editable_by - post = get_object_or_404(Post, pk=post_id) topic = post.topic if not forum_editable_by(post, request.user): messages.error(request, _("You don't have permission to edit this post.")) return HttpResponseRedirect(post.get_absolute_url()) + moderator = request.user.is_superuser or request.user in topic.forum.moderators.all() form = build_form(EditPostForm, request, topic=topic, instance=post) if form.is_valid(): post = form.save(commit=False) - post.updated_by = request.user + if not form.cleaned_data['silent_edit']: + post.updated_by = request.user + post.updated = timezone.now() post.save() messages.success(request, _("Post updated.")) return HttpResponseRedirect(post.get_absolute_url()) return render(request, 'djangobb_forum/edit_post.html', {'form': form, 'post': post, + 'moderator': moderator, })