Merge lp:~bhargav-golla/postorius/bug-1294463 into lp:postorius

Proposed by Bhargav
Status: Merged
Merged at revision: 177
Proposed branch: lp:~bhargav-golla/postorius/bug-1294463
Merge into: lp:postorius
Diff against target: 44 lines (+14/-3)
2 files modified
src/postorius/templates/postorius/lists/summary.html (+5/-2)
src/postorius/views/list.py (+9/-1)
To merge this branch: bzr merge lp:~bhargav-golla/postorius/bug-1294463
Reviewer Review Type Date Requested Status
Terri Approve
Review via email: mp+212167@code.launchpad.net

Commit message

Description of the change

This merge fixes Bug 1294463.

To post a comment you must log in.
Revision history for this message
Terri (terriko) wrote :

Looks good!

Florian and I had a quick chat to see if we could think of a way to do this without a REST call, but we're pretty sure we don't have the info requested already at this point, so this is probably as efficient as it gets. I'll be merging it shortly.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/postorius/templates/postorius/lists/summary.html'
2--- src/postorius/templates/postorius/lists/summary.html 2013-05-31 02:21:03 +0000
3+++ src/postorius/templates/postorius/lists/summary.html 2014-03-21 14:26:05 +0000
4@@ -15,13 +15,16 @@
5 <h2>{% trans 'Description' %}</h2>
6 <p>{{list.settings.description }}</p>
7
8+ {% if user.is_authenticated %}
9+ {% if userSubscribed %}
10+ <a href="{% url 'list_unsubscribe' list.fqdn_listname user.email %}" class="btn btn-danger">Unsubscribe</a>
11+ {% else %}
12 <h2>{% trans 'Subscribe to this list' %}</h2>
13- {% if user.is_authenticated %}
14 <form action="{% url 'list_subscribe' list.fqdn_listname %}" method="post" class="list_subscribe"> {% csrf_token %}
15 {{subscribe_form.as_p}}
16 <input class="btn btn-success" type="submit" value="{% trans 'Subscribe' %}" />
17- <a href="{% url 'list_unsubscribe' list.fqdn_listname user.email %}" class="btn btn-danger">Unsubscribe</a>
18 </form>
19+ {% endif %}
20 {% else %}
21 <p>To subscribe or unsubscribe this list you have to be logged in.</p>
22 <p><a href="{% url 'user_login' %}"class="btn btn-primary">Log In</a></p>
23
24=== modified file 'src/postorius/views/list.py'
25--- src/postorius/views/list.py 2014-03-15 21:36:39 +0000
26+++ src/postorius/views/list.py 2014-03-21 14:26:05 +0000
27@@ -117,10 +117,18 @@
28
29 def get(self, request, fqdn_listname):
30 user_email = getattr(request.user, 'email', None)
31+ userSubscribed = False
32+ try:
33+ userMember = self.mailing_list.get_member(user_email)
34+ except ValueError:
35+ pass
36+ else:
37+ userSubscribed = True
38 return render_to_response(
39 'postorius/lists/summary.html',
40 {'list': self.mailing_list,
41- 'subscribe_form': ListSubscribe(initial={'email': user_email})},
42+ 'subscribe_form': ListSubscribe(initial={'email': user_email}),
43+ 'userSubscribed': userSubscribed},
44 context_instance=RequestContext(request))
45
46

Subscribers

People subscribed via source and target branches