diff --git a/src/postorius/templates/postorius/lists/summary.html b/src/postorius/templates/postorius/lists/summary.html index fc76ac0..fc5a594 100644 --- a/src/postorius/templates/postorius/lists/summary.html +++ b/src/postorius/templates/postorius/lists/summary.html @@ -15,13 +15,16 @@

{% trans 'Description' %}

{{list.settings.description }}

-

{% trans 'Subscribe to this list' %}

{% if user.is_authenticated %} + {% if userSubscribed %} + Unsubscribe + {% else %} +

{% trans 'Subscribe to this list' %}

{% csrf_token %} {{subscribe_form.as_p}} - Unsubscribe
+ {% endif %} {% else %}

To subscribe or unsubscribe this list you have to be logged in.

Log In

diff --git a/src/postorius/views/list.py b/src/postorius/views/list.py index 5605773..221f6ac 100644 --- a/src/postorius/views/list.py +++ b/src/postorius/views/list.py @@ -170,10 +170,18 @@ def get(self, request, fqdn_listname): user_email = getattr(request.user, 'email', None) + userSubscribed = False + try: + userMember = self.mailing_list.get_member(user_email) + except ValueError: + pass + else: + userSubscribed = True return render_to_response( 'postorius/lists/summary.html', {'list': self.mailing_list, - 'subscribe_form': ListSubscribe(initial={'email': user_email})}, + 'subscribe_form': ListSubscribe(initial={'email': user_email}), + 'userSubscribed': userSubscribed}, context_instance=RequestContext(request))