diff --git a/conservancy/usethesource/forms.py b/conservancy/usethesource/forms.py index 9328b6d5..3f1277f0 100644 --- a/conservancy/usethesource/forms.py +++ b/conservancy/usethesource/forms.py @@ -4,9 +4,11 @@ from .models import Comment class CommentForm(forms.ModelForm): + post_to_list = forms.BooleanField(required=False) + class Meta: model = Comment - fields = ['time', 'message'] + fields = ['time', 'message', 'post_to_list'] def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) diff --git a/conservancy/usethesource/templates/usethesource/add_comment_button_partial.html b/conservancy/usethesource/templates/usethesource/add_comment_button_partial.html index 806d6bea..3e524056 100644 --- a/conservancy/usethesource/templates/usethesource/add_comment_button_partial.html +++ b/conservancy/usethesource/templates/usethesource/add_comment_button_partial.html @@ -1,3 +1,3 @@
- +
diff --git a/conservancy/usethesource/templates/usethesource/add_comment_form.html b/conservancy/usethesource/templates/usethesource/add_comment_form.html index a3228f60..11e29666 100644 --- a/conservancy/usethesource/templates/usethesource/add_comment_form.html +++ b/conservancy/usethesource/templates/usethesource/add_comment_form.html @@ -2,8 +2,9 @@ {% csrf_token %}
{{ form.time }}
{{ form.message }}
+
- +
diff --git a/conservancy/usethesource/views.py b/conservancy/usethesource/views.py index 33158f78..6b3c10d6 100644 --- a/conservancy/usethesource/views.py +++ b/conservancy/usethesource/views.py @@ -35,7 +35,7 @@ def download_page(request, slug, download_type): def create_comment(request, slug): candidate = get_object_or_404(Candidate, slug=slug) if request.method == 'GET': - form = CommentForm() + form = CommentForm(initial={'post_to_list': True}) else: form = CommentForm(request.POST) if form.is_valid(): @@ -43,8 +43,9 @@ def create_comment(request, slug): comment.candidate = candidate comment.user = request.user comment.save() - email = make_comment_email(comment) - email.send() + if 'post_to_list' in request.POST: + email = make_comment_email(comment) + email.send() return redirect('usethesource:view_comment', comment_id=comment.id, show_add='true') return render(request, 'usethesource/add_comment_form.html', {'form': form, 'candidate': candidate})