daily pastebin goal
9%
SHARE
TWEET

Untitled

a guest Jun 19th, 2017 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import settings
  2.  
  3. from django.shortcuts import get_object_or_404, render_to_response
  4.  
  5. from plugins.newsletter.forms import NewsletterForm
  6. from plugins.newsletter.campaign_monitor_api import CampaignMonitorApi
  7.  
  8. def submit(request):
  9.     if request.method == 'POST':
  10.         form = NewsletterForm(request.POST)
  11.         if form.is_valid():
  12.             email = form.cleaned_data['email']
  13.             name = form.cleaned_data['name']
  14.             province = form.cleaned_data['province']
  15.    
  16.             api_key = settings.NEWSLETTER_API_KEY     #"59ccb89e6658a1684fa03dd061290d41"
  17.             client_id = settings.NEWSLETTER_CLIENT_ID #"483565b6a955fe6ec0b76d6b5b77ab52"
  18.             list_id = settings.NEWSLETTER_LIST_ID      #'330ee7dfb921dfa40d30aaf93103971c'
  19.  
  20.             cm = CampaignMonitorApi(api_key, None)
  21.  
  22.             if cm.subscriber_add(list_id, email, name):
  23.         return render_to_response('newsletter/added_user.html', RequestContext(request, {}))
  24.             else:
  25.         return render_to_response('newsletter/user_not_added.html', RequestContext(request, {'form': form}))
  26.     else:
  27.         form = NewsletterForm()
  28.    
  29.     return render_to_response('newsletter/add_user.html', RequestContext(request, {'form': form}))
RAW Paste Data
Top