Skip to content

Commit 5a02030

Browse files
committed
Fixes #253 Signature list template now allows to easily copy paste newsletter subscriptions to Sympa
1 parent cc7f8a9 commit 5a02030

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

pytition/petition/templates/petition/signature_data.html

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,32 @@ <h4><i>{{ petition.title }}</i></h4>
3131
<span class="oi oi-envelope-closed"></span>
3232
{% trans "Re-send confirmation e-mail to all unconfirmed" %}</button>
3333
</p>
34+
<p>
35+
<a href="#" class="btn btn-warning" id="show-sympa-mass-subscribe"
36+
data-toggle="modal" data-target="#sympa-modal" aria-disabled="true">
37+
{% trans "Subscribe signatories to the newsletter" %}
38+
</a>
39+
<div class="modal fade" id="sympa-modal">
40+
<div class="modal-dialog">
41+
<div class="modal-content">
42+
<div class="modal-header">
43+
<h4 class="modal-title">
44+
{% trans "copy/paste the following text block into Sympa's mass-subscribe formular" %}</h4>
45+
<button type="button" class="close" data-dismiss="modal">&times;</button>
46+
</div>
47+
48+
<div class="modal-body" id="sympa_content">
49+
50+
</div>
51+
52+
<div class="modal-footer">
53+
<button type="button" class="btn btn-info" data-dismiss="modal">{% trans "Ok" %}</button>
54+
</div>
55+
56+
</div>
57+
</div>
58+
</div>
59+
</p>
3460
<p>
3561
<div class="form-row">
3662
<div class="col-3">
@@ -125,6 +151,21 @@ <h4><i>{{ petition.title }}</i></h4>
125151
$("#select-all").on("change", function() {
126152
$(":checkbox").prop('checked', $(this).prop('checked'));
127153
});
154+
155+
$("#show-sympa-mass-subscribe").on("click", function(){
156+
$.ajax("{% url "show_sympa_subscribe_bloc" petition.id %}").done(function(data){
157+
$("#sympa_content").html(data);
158+
});
159+
});
128160
});
129161
</script>
130162
{% endblock extrajs %}
163+
164+
{% block extracss %}
165+
{{ block.super }}
166+
<style>
167+
#sympa_content {
168+
background-color: lightgrey;
169+
}
170+
</style>
171+
{% endblock extracss %}

pytition/petition/views.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
from .helpers import check_petition_is_accessible
3838
from .helpers import send_confirmation_email, subscribe_to_newsletter, send_welcome_mail
3939
from .helpers import get_update_form, petition_detail_meta
40+
from .helpers import sanitize_html
4041

4142

4243
#------------------------------------ Views -----------------------------------
@@ -107,12 +108,16 @@ def show_sympa_subscribe_bloc(request, petition_id):
107108
return redirect("index")
108109

109110
text_bloc = ""
110-
for signature in petition.signature_set.filter(subscribed_to_mailinglist=True):
111+
signatures = petition.signature_set.filter(subscribed_to_mailinglist=True)
112+
if not signatures:
113+
return HttpResponse(_("No newsletter subscription yet!"))
114+
115+
for signature in signatures:
111116
text_bloc = text_bloc + "{email} {firstname} {lastname}<br/>\n".format(email=signature.email,
112117
firstname=signature.first_name,
113118
lastname=signature.last_name)
114119

115-
return HttpResponse(text_bloc)
120+
return HttpResponse(sanitize_html(text_bloc))
116121

117122

118123
# /search?q=QUERY

0 commit comments

Comments
 (0)