Skip to content

Allow admins to disable the newsletters #336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions pytition/petition/templates/petition/edit_petition.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@
data-toggle="list" aria-controls="social_network_form" role="tab"><span class="oi oi-share-boxed"></span> {% trans "Social Networks" %}</a>
<a href="#email_form" class="list-group-item list-group-item-info list-group-item-action"
data-toggle="list" aria-controls="email_form" role="tab"><span class="oi oi-envelope-closed"></span> {% trans "E-mail setup" %}</a>
<a href="#newsletter_form" class="list-group-item list-group-item-info list-group-item-action"
data-toggle="list" aria-controls="newsletter_form" role="tab"><span class="oi oi-rss"></span> {% trans "Newsletter setup" %}</a>
{% if not settings.DISABLE_NEWSLETTER %}
<a href="#newsletter_form" class="list-group-item list-group-item-info list-group-item-action"
data-toggle="list" aria-controls="newsletter_form" role="tab"><span class="oi oi-rss"></span> {% trans "Newsletter setup" %}</a>
{% endif %}
<a href="#preview" class="list-group-item list-group-item-info list-group-item-action"
data-toggle="list" aria-controls="preview" role="tab"><span class="oi oi-clipboard"></span> {% trans "Preview petition" %}</a>
</div>
Expand Down Expand Up @@ -247,13 +249,15 @@
<button name="email_form_submitted" class="btn btn-primary" value="yes" type="submit">{% trans "Save" %}</button>
</form>
</div>
<div class="tab-pane fade" id="newsletter_form" role="tabpanel"
aria-labelledby="list-newsletter-form-list">
<form method="POST" id="form_newsletter">{% csrf_token %}
{% include "petition/bs4_form.html" with form=newsletter_form %}
<button name="newsletter_form_submitted" class="btn btn-primary" value="yes" type="submit">{% trans "Save" %}</button>
</form>
</div>
{% if not settings.DISABLE_NEWSLETTER %}
<div class="tab-pane fade" id="newsletter_form" role="tabpanel"
aria-labelledby="list-newsletter-form-list">
<form method="POST" id="form_newsletter">{% csrf_token %}
{% include "petition/bs4_form.html" with form=newsletter_form %}
<button name="newsletter_form_submitted" class="btn btn-primary" value="yes" type="submit">{% trans "Save" %}</button>
</form>
</div>
{% endif %}
<div class="tab-pane fade" id="preview" role="tabpanel"
aria-labelledby="list-preview-list" data-src="{{ petition.url }}">
<div class="alert alert-warning" role="alert">
Expand Down Expand Up @@ -502,7 +506,7 @@
|| (content_tab_changed && !formcontent.data('submitted'))
|| (formstyle.serialize() !== formstyle.data('serialize') && !formstyle.data('submitted'))
|| (formemail.serialize() !== formemail.data('serialize') && !formemail.data('submitted'))
|| (formnewsletter.serialize() !== formnewsletter.data('serialize') && !formnewsletter.data('submitted'));
|| (formnewsletter.length > 0 && formnewsletter.serialize() !== formnewsletter.data('serialize') && !formnewsletter.data('submitted'));

}

Expand Down
2 changes: 1 addition & 1 deletion pytition/petition/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,7 @@ def edit_petition(request, petition_id):
social_network_form = SocialNetworkForm(data)


if 'newsletter_form_submitted' in request.POST:
if not settings.DISABLE_NEWSLETTER and 'newsletter_form_submitted' in request.POST:
submitted_ctx['newsletter_form_submitted'] = True
newsletter_form = NewsletterForm(request.POST)
if newsletter_form.is_valid():
Expand Down
3 changes: 3 additions & 0 deletions pytition/pytition/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@
#:| If set to True, users won't be able to create petitions in their name, but only for an organization
DISABLE_USER_PETITION = False

#:| If set to True, users won't be able to set a newsletter on their petitions
DISABLE_NEWSLETTER = False

#:| If set to True, regular users won't be able to create new organizations.
#:| Only superusers will be allowed to
RESTRICT_ORG_CREATION = False
Expand Down