Skip to content

Commit ab2499a

Browse files
committed
Trick to allow dumping subscribers in sympa 'mass subscribe' bloc format for copy paste
If you have the "can_view_signatures" right or are the owner of the petition, point your browser to: https://yourdomain/petition/<petitionID>/show_sympa_subscribe_bloc
1 parent d53f81e commit ab2499a

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

pytition/petition/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
path('resend/<int:signature_id>', views.go_send_confirmation_email, name='resend_confirmation_email'),
2121
path('<int:petition_id>/sign', views.create_signature, name='create_signature'),
2222
path('<int:petition_id>/show_signatures', views.show_signatures, name='show_signatures'),
23+
path('<int:petition_id>/show_sympa_subscribe_bloc', views.show_sympa_subscribe_bloc, name='show_sympa_subscribe_bloc'),
2324
path('<int:petition_id>/delete', views.petition_delete, name='petition_delete'),
2425
path('<int:petition_id>/publish', views.petition_publish, name='petition_publish'),
2526
path('<int:petition_id>/unpublish', views.petition_unpublish, name='petition_unpublish'),

pytition/petition/views.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,33 @@ def index(request):
8282
)
8383

8484

85+
# <int:petition_id>/show_sympa_subscribe_bloc
86+
# Show sympa subscribe bloc to mass subscribe people to newsletter
87+
@login_required
88+
def show_sympa_subscribe_bloc(request, petition_id):
89+
try:
90+
pytitionuser = get_session_user(request)
91+
except:
92+
pytitionuser = None
93+
94+
if not pytitionuser:
95+
return redirect('index')
96+
97+
petition = petition_from_id(petition_id)
98+
99+
if petition.owner_type == "org" and not petition.org.is_allowed_to(pytitionuser, "can_view_signatures"):
100+
return redirect("index")
101+
elif petition.owner_type == "user" and petition.owner != pytitionuser:
102+
return redirect("index")
103+
104+
text_bloc = ""
105+
for signature in petition.signature_set.filter(subscribed_to_mailinglist=True):
106+
text_bloc = text_bloc + "{email} {firstname} {lastname}<br/>\n".format(email=signature.email,
107+
firstname=signature.first_name,
108+
lastname=signature.last_name)
109+
110+
return HttpResponse(text_bloc)
111+
85112
# /all_petitions
86113
# Show all the petitions in the database
87114
def all_petitions(request):

0 commit comments

Comments
 (0)