Changeset - c0a4fe5f39d0
[Not reviewed]
0 4 0
Ben Sturmfels (bsturmfels) - 2 months ago 2024-03-15 07:21:59
ben@sturm.com.au
usethesource: Add checkbox to opt-out of posting comment to mailing list
4 files changed with 10 insertions and 6 deletions:
0 comments (0 inline, 0 general)
conservancy/usethesource/forms.py
Show inline comments
...
 
@@ -6,5 +6,7 @@ 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']
 

	
conservancy/usethesource/templates/usethesource/add_comment_button_partial.html
Show inline comments
 
<div class="mt2" hx-target="this" hx-swap="outerHTML">
 
  <button type="submit" title="Add comment" class="f3 b white bg-light-silver ph2" style="border: none" hx-get="{% url 'usethesource:add_comment' slug=candidate.slug %}">+</button>
 
  <button type="submit" title="Add comment" class="f3 b white bg-light-silver pointer ph2" style="border: none" hx-get="{% url 'usethesource:add_comment' slug=candidate.slug %}">+</button>
 
</div>
conservancy/usethesource/templates/usethesource/add_comment_form.html
Show inline comments
...
 
@@ -4,5 +4,6 @@
 
  <div class="mt2">{{ form.message }}</div>
 
  <div class="mt2"><label>{{ form.post_to_list }} Post to the mailing list</div>
 
  <div class="mt2">
 
    <button type="submit" hx-get="{% url 'usethesource:add_button' slug=candidate.slug %}" class="b pointer white bg-light-silver pv2 ph3" style="border: none">Cancel</button>
 
    <button type="submit" class="b white bg-green pv2 ph3" style="border: none">Save and email</button>
 
    <button type="submit" class="b white bg-green pv2 ph3" style="border: none">Save</button>
 
  </div>
conservancy/usethesource/views.py
Show inline comments
...
 
@@ -37,3 +37,3 @@ def create_comment(request, slug):
 
    if request.method == 'GET':
 
        form = CommentForm()
 
        form = CommentForm(initial={'post_to_list': True})
 
    else:
...
 
@@ -45,4 +45,5 @@ def create_comment(request, slug):
 
            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')
0 comments (0 inline, 0 general)