Commit dcea664b authored by Anirudh Dahiya's avatar Anirudh Dahiya Committed by Simon Hanna

Prohibit the submission of duplicate subscription requests

parent fb40efff
......@@ -38,7 +38,7 @@
{# Subscription #}
{% if user.is_authenticated %}
{% if userSubscribed %}
{% if user_subscribed %}
<h2>{% trans 'Subscription' %}</h2>
{% trans 'You are subscribed to this list with the following address:' %} <em>{{ subscribed_address }}</em>
......@@ -56,6 +56,8 @@
<button type="submit" class="btn btn-danger">{% trans 'Unsubscribe' %}</button>
{% elif user_request_pending %}
<h4>{% trans "You have a subscription request pending. If you don't hear back soon, please contact the list owners." %}</h4>
{% else %}
<h2>{% trans 'Subscribe to this list' %}</h2>
......@@ -201,7 +201,7 @@ class ListSummaryView(MailingListView):
def get(self, request, list_id):
data = {'list': self.mailing_list,
'userSubscribed': False,
'user_subscribed': False,
'subscribed_address': None,
'public_archive': False,
'hyperkitty_enabled': False}
......@@ -220,13 +220,17 @@ class ListSummaryView(MailingListView):
user_emails = EmailAddress.objects.filter(
user=request.user, verified=True).order_by(
"email").values_list("email", flat=True)
pending_requests = [r['email'] for r in self.mailing_list.requests]
for address in user_emails:
if address in pending_requests:
data['user_request_pending'] = True
except ValueError:
data['userSubscribed'] = True
data['user_subscribed'] = True
data['subscribed_address'] = address
break # no need to test more addresses
data['subscribe_form'] = ListSubscribe(user_emails)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment