Skip to content

Commit

Permalink
Trick to allow dumping subscribers in sympa 'mass subscribe' bloc for…
Browse files Browse the repository at this point in the history
…mat 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
  • Loading branch information
fallen committed Jun 10, 2020
1 parent d53f81e commit ab2499a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions pytition/petition/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
path('resend/<int:signature_id>', views.go_send_confirmation_email, name='resend_confirmation_email'),
path('<int:petition_id>/sign', views.create_signature, name='create_signature'),
path('<int:petition_id>/show_signatures', views.show_signatures, name='show_signatures'),
path('<int:petition_id>/show_sympa_subscribe_bloc', views.show_sympa_subscribe_bloc, name='show_sympa_subscribe_bloc'),
path('<int:petition_id>/delete', views.petition_delete, name='petition_delete'),
path('<int:petition_id>/publish', views.petition_publish, name='petition_publish'),
path('<int:petition_id>/unpublish', views.petition_unpublish, name='petition_unpublish'),
Expand Down
27 changes: 27 additions & 0 deletions pytition/petition/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,33 @@ def index(request):
)


# <int:petition_id>/show_sympa_subscribe_bloc
# Show sympa subscribe bloc to mass subscribe people to newsletter
@login_required
def show_sympa_subscribe_bloc(request, petition_id):
try:
pytitionuser = get_session_user(request)
except:
pytitionuser = None

if not pytitionuser:
return redirect('index')

petition = petition_from_id(petition_id)

if petition.owner_type == "org" and not petition.org.is_allowed_to(pytitionuser, "can_view_signatures"):
return redirect("index")
elif petition.owner_type == "user" and petition.owner != pytitionuser:
return redirect("index")

text_bloc = ""
for signature in petition.signature_set.filter(subscribed_to_mailinglist=True):
text_bloc = text_bloc + "{email} {firstname} {lastname}<br/>\n".format(email=signature.email,
firstname=signature.first_name,
lastname=signature.last_name)

return HttpResponse(text_bloc)

# /all_petitions
# Show all the petitions in the database
def all_petitions(request):
Expand Down

0 comments on commit ab2499a

Please sign in to comment.