Beispiel #1
0
def mailing_subscribe(request):
    """Handles MailChimp email registration."""
    if request.method == 'POST':
        form = EmailForm(request.POST)
        if form.is_valid():
            try:
                subscribe_email(form.cleaned_data['email'])
                messages.success(request, 'Successfully subscribed.')
                redirect_to = 'home'
            except mailchimp.ListAlreadySubscribedError:
                messages.error(request, 'Already subscribed.')
                redirect_to = 'mailing_subscribe'
            except mailchimp.ValidationError, e:
                messages.error(request, 'ERROR: %s' % e.args[0])
                redirect_to = 'mailing_subscribe'
            return redirect(redirect_to)
Beispiel #2
0
def mailing_subscribe(request, slug="default"):
    """Handles MailChimp email registration."""
    if request.method == "POST":
        form = EmailForm(request.POST)
        if form.is_valid():
            try:
                subscribe_email(form.cleaned_data, slug)
                messages.success(request, "Successfully subscribed.")
                if slug == "globalcityteams":
                    redirect_to = "https://www.us-ignite.org/globalcityteams/"
                else:
                    redirect_to = "home"
            except mailchimp.ListAlreadySubscribedError:
                messages.error(request, "Already subscribed.")
                redirect_to = "mailing_subscribe"
            except mailchimp.ValidationError, e:
                messages.error(request, "ERROR: %s" % e.args[0])
                redirect_to = "mailing_subscribe"
            return redirect(redirect_to)
Beispiel #3
0
def mailing_subscribe(request, slug='default'):
    print slug
    """Handles MailChimp email registration."""
    if request.method == 'POST':
        form = EmailForm(request.POST)
        if form.is_valid():
            try:
                subscribe_email(form.cleaned_data, slug)
                messages.success(request, 'Successfully subscribed.')
                if slug == 'globalcityteams':
                    redirect_to = 'https://www.us-ignite.org/globalcityteams/'
                elif slug == 'sgc_launch':
                    redirect_to = 'smart_gigabit_communities_reverse_pitch'
                else:
                    redirect_to = 'home'
            except mailchimp.ListAlreadySubscribedError:
                messages.error(request, 'Already subscribed.')
                redirect_to = 'mailing_subscribe'
            except mailchimp.ValidationError, e:
                messages.error(request, 'ERROR: %s' % e.args[0])
                redirect_to = 'mailing_subscribe'
            return redirect(redirect_to)