Merge lp://staging/~rajeevs1992/postorius/postorius into lp://staging/postorius

Proposed by Rajeev S
Status: Needs review
Proposed branch: lp://staging/~rajeevs1992/postorius/postorius
Merge into: lp://staging/postorius
Diff against target: 109 lines (+36/-22)
3 files modified
src/postorius/forms.py (+5/-0)
src/postorius/templates/postorius/lists/mass_subscribe.html (+1/-1)
src/postorius/views/list.py (+30/-21)
To merge this branch: bzr merge lp://staging/~rajeevs1992/postorius/postorius
Reviewer Review Type Date Requested Status
Florian Fuchs Pending
Review via email: mp+207826@code.staging.launchpad.net

Description of the change

Added a file upload feature to add Mass subscriptions.Also changed email validator to django builtin validator.(DRY)

To post a comment you must log in.
Revision history for this message
Sumana Harihareswara (sumanah) :
Revision history for this message
Rajeev S (rajeevs1992) wrote :
Download full text (4.3 KiB)

Looks fine to me.

Sent from my BlackBerry 10 smartphone.
  Original Message
From: Sumana Harihareswara
Sent: Saturday 10 January 2015 03:13
To: Rajeev S
Reply To: <email address hidden>
Subject: Re: [Merge] lp:~rajeevs1992/postorius/postorius into lp:postorius

Diff comments:

> === modified file 'src/postorius/forms.py'
> --- src/postorius/forms.py 2013-10-22 18:52:15 +0000
> +++ src/postorius/forms.py 2014-02-23 14:49:03 +0000
> @@ -706,6 +706,11 @@
> widget=forms.Textarea,
> )
>
> + upload = forms.FileField(
> + label = ('Or Upload a file,with one email per line'),

I'm sorry that I don't have a more substantive comment on the code to offer, but I can suggest that the label be:

'Or upload a file, with one email address per line'

> + required = False,
> + )
> +
> verify_with_email = forms.BooleanField(required=False)
>
> class Meta:
>
> === modified file 'src/postorius/templates/postorius/lists/mass_subscribe.html'
> --- src/postorius/templates/postorius/lists/mass_subscribe.html 2013-05-31 02:21:03 +0000
> +++ src/postorius/templates/postorius/lists/mass_subscribe.html 2014-02-23 14:49:03 +0000
> @@ -6,7 +6,7 @@
> {% block main %}
> {% list_nav 'mass_subscribe' 'Mass Subscription' %}
>
> - <form action="{% url 'mass_subscribe' list.fqdn_listname %}" method="post" class="well"> {% csrf_token %}
> + <form action="{% url 'mass_subscribe' list.fqdn_listname %}" method="post" class="well" enctype="multipart/form-data"> {% csrf_token %}
> {{ form.as_p }}
> <button class="btn btn-primary" type="submit">{% trans "Subscribe users" %}</button>
> </form>
>
> === modified file 'src/postorius/views/list.py'
> --- src/postorius/views/list.py 2013-10-22 20:01:21 +0000
> +++ src/postorius/views/list.py 2014-02-23 14:49:03 +0000
> @@ -21,13 +21,15 @@
> from django.contrib import messages
> from django.contrib.auth.decorators import (login_required,
> user_passes_test)
> +from django.core.validators import validate_email
> +from django.core.exceptions import ValidationError
> from django.core.urlresolvers import reverse
> from django.shortcuts import render_to_response, redirect
> from django.template import RequestContext
> from django.utils.decorators import method_decorator
> from django.utils.translation import gettext as _
> from urllib2 import HTTPError
> -
> +import csv
> from postorius import utils
> from postorius.models import (Domain, List, MailmanUser,
> MailmanApiError)
> @@ -170,6 +172,12 @@
> class ListMassSubsribeView(MailingListView):
>
> """Mass subscription."""
> + def verify_email(self,email):
> + try:
> + validate_email( email )
> + return True
> + except ValidationError:
> + return False
>
> @method_decorator(list_owner_required)
> def get(self, request, *args, **kwargs):
> @@ -180,27 +188,28 @@
>
> def post(self, request, *args, **kwargs):
> form = ListMassSubscription(request.POST)
> - if not form.is_valid():
> + emails = request.POST["emails"].splitlines()
> + if 'upload' in request.FILES:
> + for i in request.FILES["upload"].readlines():
> + emails.append(i.strip())
> + if emails == []:
> messages.error(request, 'Please fill out the form correctly.')
> - else:
> - emails = request.POST["emails"].splitlines()
> ...

Read more...

Unmerged revisions

160. By Rajeev S

Added an upload file feature to the Mass Subscribe.
Also used the django inbuilt email verifier to verify
the emails, in views/list.py.(DRY).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches