Merge lp:~coolyashish/postorius/postorius into lp:postorius

Proposed by Ashish
Status: Merged
Merged at revision: 243
Proposed branch: lp:~coolyashish/postorius/postorius
Merge into: lp:postorius
Diff against target: 188 lines (+111/-38) (has conflicts)
3 files modified
src/postorius/templates/postorius/lists/members.html (+4/-0)
src/postorius/urls.py (+2/-0)
src/postorius/views/list.py (+105/-38)
Text conflict in src/postorius/views/list.py
To merge this branch: bzr merge lp:~coolyashish/postorius/postorius
Reviewer Review Type Date Requested Status
Terri Approve
Review via email: mp+252088@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Terri (terriko) wrote :

Can you make sure that this code works correctly with @method_decorator(list_owner_required) so that the csv export is only available to list owners? It looks like this might need some code cleanup as well so that it matches the other code. (try running the pep8 checker, at least!)

review: Needs Fixing
Revision history for this message
Terri (terriko) wrote :

Other than that, it's looking like a great feature and I'd love to be able to merge it!

lp:~coolyashish/postorius/postorius updated
205. By Ashish

Pep8 + Owner check

Revision history for this message
Ashish (coolyashish) wrote :

Hi Terri,

I have added @list_owner_required. It is working fine with it. Also I had ran pep8 in both the files and did cleanup of the code.

Thanks

Revision history for this message
Terri (terriko) wrote :

Excellent! Can you run the tox tests as well? Also, it looks like you've got some leftovers from the merge, e.g. ("<<<<<<< TREE") that you might need to clean up.

We're just going to grab lunch, but I'll take a more detailed look at this when I get back in an hour or so.

review: Needs Fixing
lp:~coolyashish/postorius/postorius updated
206. By Ashish

Merge

Revision history for this message
Terri (terriko) wrote :

I fixed the errors and merged without waiting 'cause I need to catch my train soon!

review: Approve
Revision history for this message
Ashish (coolyashish) wrote :

Hi,

I have created a new branch https://code.launchpad.net/~coolyashish/postorius/CSV_EXPORT with propert testing with tox and Current remote changes merged into it.

Revision history for this message
Ashish (coolyashish) wrote :

Thanks :)

On Thu, Apr 16, 2015 at 11:56 PM, Ashish <email address hidden> wrote:

> Hi,
>
> I have created a new branch
> https://code.launchpad.net/~coolyashish/postorius/CSV_EXPORT with propert
> testing with tox and Current remote changes merged into it.
>
>
>
> --
> https://code.launchpad.net/~coolyashish/postorius/postorius/+merge/252088
> You are the owner of lp:~coolyashish/postorius/postorius.
>

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/members.html'
2--- src/postorius/templates/postorius/lists/members.html 2015-04-15 21:48:46 +0000
3+++ src/postorius/templates/postorius/lists/members.html 2015-04-16 18:14:05 +0000
4@@ -74,6 +74,10 @@
5 </tr>
6 </thead>
7 <tbody>
8+ <form action="{% url 'csv_view' list.list_id %}" method="post" class="well"> {% csrf_token %}
9+ <button type="submit" class="btn">{% trans 'CSV Export' %}</button>
10+ </form>
11+
12 {% for member in list.member_page %}
13 <tr>
14 <td> <a href="{% url 'list_member_options' list.fqdn_listname member.email %}">
15
16=== modified file 'src/postorius/urls.py'
17--- src/postorius/urls.py 2015-04-15 21:48:46 +0000
18+++ src/postorius/urls.py 2015-04-16 18:14:05 +0000
19@@ -29,6 +29,8 @@
20 url(r'^members/(?P<page>\d+)/$',
21 ListMembersView.as_view(
22 ), name='list_members_paged'),
23+ url(r'^csv_view/$',
24+ 'csv_view', name='csv_view'),
25 url(r'^members/$',
26 ListMembersView.as_view(
27 ), name='list_members'),
28
29=== modified file 'src/postorius/views/list.py'
30--- src/postorius/views/list.py 2015-04-15 23:44:05 +0000
31+++ src/postorius/views/list.py 2015-04-16 18:14:05 +0000
32@@ -16,6 +16,9 @@
33 # You should have received a copy of the GNU General Public License along with
34 # Postorius. If not, see <http://www.gnu.org/licenses/>.
35 import logging
36+import csv
37+
38+from django.http import HttpResponse
39
40 from django.contrib import messages
41 from django.contrib.auth.decorators import (login_required,
42@@ -266,44 +269,108 @@
43 return redirect('mass_subscribe', self.mailing_list.list_id)
44
45
46-class ListMassRemovalView(MailingListView):
47-
48- """Class For Mass Removal"""
49-
50- @method_decorator(list_owner_required)
51- def get(self, request, *args, **kwargs):
52- form = ListMassRemoval()
53- return render_to_response('postorius/lists/mass_removal.html',
54- {'form': form, 'list': self.mailing_list},
55- context_instance=RequestContext(request))
56-
57- @method_decorator(list_owner_required)
58- def post(self, request, *args, **kwargs):
59- form = ListMassRemoval(request.POST)
60- if not form.is_valid():
61- messages.error(request, 'Please fill out the form correctly.')
62- else:
63- emails = request.POST["emails"].splitlines()
64- for email in emails:
65- try:
66- validate_email(email)
67- self.mailing_list.unsubscribe(email.lower())
68- messages.success(request,
69- 'The address %s has been unsubscribed from %s.' %
70- (email, self.mailing_list.fqdn_listname))
71- except MailmanApiError:
72- return utils.render_api_error(request)
73- except HTTPError, e:
74- messages.error(request, e)
75- except ValueError, e:
76- messages.error(request, e)
77- except ValidationError:
78- messages.error(request,
79- 'The email address %s is not valid.' %
80- email)
81- return redirect('mass_removal', self.mailing_list.list_id)
82-
83-
84+<<<<<<< TREE
85+class ListMassRemovalView(MailingListView):
86+
87+ """Class For Mass Removal"""
88+
89+ @method_decorator(list_owner_required)
90+ def get(self, request, *args, **kwargs):
91+ form = ListMassRemoval()
92+ return render_to_response('postorius/lists/mass_removal.html',
93+ {'form': form, 'list': self.mailing_list},
94+ context_instance=RequestContext(request))
95+
96+ @method_decorator(list_owner_required)
97+ def post(self, request, *args, **kwargs):
98+ form = ListMassRemoval(request.POST)
99+ if not form.is_valid():
100+ messages.error(request, 'Please fill out the form correctly.')
101+ else:
102+ emails = request.POST["emails"].splitlines()
103+ for email in emails:
104+ try:
105+ validate_email(email)
106+ self.mailing_list.unsubscribe(email.lower())
107+ messages.success(request,
108+ 'The address %s has been unsubscribed from %s.' %
109+ (email, self.mailing_list.fqdn_listname))
110+ except MailmanApiError:
111+ return utils.render_api_error(request)
112+ except HTTPError, e:
113+ messages.error(request, e)
114+ except ValueError, e:
115+ messages.error(request, e)
116+ except ValidationError:
117+ messages.error(request,
118+ 'The email address %s is not valid.' %
119+ email)
120+ return redirect('mass_removal', self.mailing_list.list_id)
121+
122+
123+=======
124+class ListMassRemovalView(MailingListView):
125+
126+ """Class For Mass Removal"""
127+
128+ @method_decorator(list_owner_required)
129+ def get(self, request, *args, **kwargs):
130+ form = ListMassRemoval()
131+ return render_to_response('postorius/lists/mass_removal.html',
132+ {'form': form, 'list': self.mailing_list},
133+ context_instance=RequestContext(request))
134+
135+ @method_decorator(list_owner_required)
136+ def post(self, request, *args, **kwargs):
137+ form = ListMassRemoval(request.POST)
138+ if not form.is_valid():
139+ messages.error(request, 'Please fill out the form correctly.')
140+ else:
141+ emails = request.POST["emails"].splitlines()
142+ for email in emails:
143+ try:
144+ validate_email(email)
145+ self.mailing_list.unsubscribe(email.lower())
146+ messages.success(request,
147+ 'The address %s has been unsubscribed from %s.' %
148+ (email, self.mailing_list.fqdn_listname))
149+ except MailmanApiError:
150+ return utils.render_api_error(request)
151+ except HTTPError, e:
152+ messages.error(request, e)
153+ except ValueError, e:
154+ messages.error(request, e)
155+ except ValidationError:
156+ messages.error(request,
157+ 'The email address %s is not valid.' %
158+ email)
159+ return redirect('mass_removal', self.mailing_list.list_id)
160+
161+
162+@list_owner_required
163+def csv_view(request, list_id):
164+ """Export all the subscriber in csv
165+ """
166+ mm_lists = []
167+ try:
168+ client = utils.get_client()
169+ mm_lists = client.get_list(list_id)
170+ except MailmanApiError:
171+ return utils.render_api_error(request)
172+
173+ response = HttpResponse(content_type='text/csv')
174+ response['Content-Disposition'] = (
175+ 'attachment; filename="Subscribers.csv"')
176+
177+ writer = csv.writer(response)
178+ if mm_lists:
179+ for i in mm_lists.members:
180+ writer.writerow([i.email])
181+
182+ return response
183+
184+
185+>>>>>>> MERGE-SOURCE
186 def _get_choosable_domains(request):
187 try:
188 domains = Domain.objects.all()

Subscribers

People subscribed via source and target branches