当前位置: 首页>>代码示例>>Python>>正文


Python MailSnake.listSubscribe方法代码示例

本文整理汇总了Python中mailsnake.MailSnake.listSubscribe方法的典型用法代码示例。如果您正苦于以下问题:Python MailSnake.listSubscribe方法的具体用法?Python MailSnake.listSubscribe怎么用?Python MailSnake.listSubscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mailsnake.MailSnake的用法示例。


在下文中一共展示了MailSnake.listSubscribe方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: earlyAccessSubmit

# 需要导入模块: from mailsnake import MailSnake [as 别名]
# 或者: from mailsnake.MailSnake import listSubscribe [as 别名]
def earlyAccessSubmit(request):
    from signup.forms import SignupForm
    if request.method == 'POST': # If the form has been submitted...
        form = SignupForm(request.POST) # A form bound to the POST data
        if form.is_valid():
          ms = MailSnake('60a810702ef83b7de50b150df5008109-us5')
          lists = ms.lists()
          ms.listSubscribe(
            id = lists['data'][0]['id'],
            email_address = form.cleaned_data['email'],
            merge_vars = {
                'GROUPINGS': [
                    {'id': 7197,
                     'groups': 'Pre-Launch',},]
                },
            update_existing = True,
            double_optin = False,
            )
          return HttpResponseRedirect('/signup/thanks/') # Redirect after POST

    else:
        form = SignupForm() # An unbound form

    return render(request, 'signup.html', {
        'form': form,
    })
开发者ID:jkhowland,项目名称:swept.in,代码行数:28,代码来源:views.py

示例2: update_user_details

# 需要导入模块: from mailsnake import MailSnake [as 别名]
# 或者: from mailsnake.MailSnake import listSubscribe [as 别名]
def update_user_details(backend, details, uid, response, user=None, is_new=False,
                        *args, **kwargs):
    if user is None:
        return

    changed = False  # flag to track changes

    for name, value in details.iteritems():
        # configured fields if user already existed
        if not _ignore_field(name, is_new):
            if value and value != getattr(user, name, None):
                setattr(user, name, value)
                changed = True

	user.profile.activate()
	user.profile.fb_pic(uid)
	user.save()

	#add to mailchimp list
	if user.first_name:
		try:
			ms = MailSnake('f92abfa01e0a9cecc885186de4e37106-us7')
			key = ''
			ms.listSubscribe( id = 'ed61191f4e', email_address = user.email, merge_vars = { 'FNAME': user.first_name, 'LNAME': user.last_name, 'EKEY': key }, double_optin = False, send_welcome = False )
		except:
			print "Facebook login error: Couldn't add user to MailChimp list"
		else:
			user.profile.send_welcome_email(activate=False)
开发者ID:jmorrice,项目名称:garmsby-snippets,代码行数:30,代码来源:views.py

示例3: submit

# 需要导入模块: from mailsnake import MailSnake [as 别名]
# 或者: from mailsnake.MailSnake import listSubscribe [as 别名]
def submit(request):
    # grab info
    email = request.POST['email']
    referrer = request.POST['referrer']

    # save locally
    lead_to_submit = Lead(email=email, referrer=referrer)
    lead_to_submit.save()

    # send to Mailchimp
    key = settings.MAILCHIMP_API_KEY
    list_num = settings.MAILCHIMP_LIST_NUM

    # see: http://www.nerdydork.com/integrate-mailchimp-with-your-django-app.html
    mailsnake = MailSnake(key)
    try:
        mailsnake.listSubscribe(
            id=list_num,
            email_address=email,
            double_optin=False,
            send_welcome=False,
            merge_vars={
                'referrer': referrer
                }
        )
    except:
        pass

    return HttpResponseRedirect(reverse('landingpage.views.thanks'))
开发者ID:imclab,项目名称:Marketing-for-Hackers,代码行数:31,代码来源:views.py

示例4: main_post

# 需要导入模块: from mailsnake import MailSnake [as 别名]
# 或者: from mailsnake.MailSnake import listSubscribe [as 别名]
def main_post():
    ms = MailSnake(app.config["MAILCHIMP_KEY"])
    try:
        email = request.form.get("email")
        ms.listSubscribe(id="d1798f7c80", email_address=email)
        flash("Thanks for subscribing! You will receive a confirmation email shortly.")
    except MailSnakeException, e:
        print e
        flash("Sorry, an error occurred.")
开发者ID:Jonty,项目名称:Website,代码行数:11,代码来源:basic.py

示例5: main_post

# 需要导入模块: from mailsnake import MailSnake [as 别名]
# 或者: from mailsnake.MailSnake import listSubscribe [as 别名]
def main_post():
    ms = MailSnake(app.config['MAILCHIMP_KEY'])
    try:
        email = request.form.get('email')
        ms.listSubscribe(id='d1798f7c80', email_address=email)
        flash('Thanks for subscribing! You will receive a confirmation email shortly.')
    except MailSnakeException, e:
        app.logger.error('Error subscribing: %s', e)
        flash('Sorry, an error occurred.')
开发者ID:marekventur,项目名称:Website,代码行数:11,代码来源:basic.py

示例6: form_valid

# 需要导入模块: from mailsnake import MailSnake [as 别名]
# 或者: from mailsnake.MailSnake import listSubscribe [as 别名]
    def form_valid(self, form):
        ms = MailSnake(getattr(settings, 'MAILCHIMP_KEY'))
        double_optin = getattr(settings, 'MAILCHIMP_CONFIRM', True)
        list_id = getattr(settings, 'MAILCHIMP_LIST_ID', None)

        if not list_id:
            list_id = ms.lists()['data'][0]['id']

        ms.listSubscribe(id=list_id, email_address=form.cleaned_data['email'],
                         merge_vars={'NAME': form.cleaned_data['name']},
                         update_existing=True, double_optin=double_optin)

        return super(SubscribeView, self).form_valid(form)
开发者ID:simonluijk,项目名称:django-chimps,代码行数:15,代码来源:views.py

示例7: __add_to_mailchimp

# 需要导入模块: from mailsnake import MailSnake [as 别名]
# 或者: from mailsnake.MailSnake import listSubscribe [as 别名]
def __add_to_mailchimp(user):
    if settings.MAILCHIMP_AUTO_SUBSCRIBE:
        ms = MailSnake(settings.MAILCHIMP_API_KEY)
        ms.listSubscribe(
            id=settings.MAILCHIMP_LIST_ID,
            email_address=user.email,
            merge_vars={
                'FNAME': user.first_name,
                'LNAME': user.last_name,
            },
            double_optin=False,  # no confirm message
            send_welcome=True,  # if new, send welcome
            update_existing=True,  # if existing, update
        )
开发者ID:byuacm,项目名称:byu-acm-web,代码行数:16,代码来源:views.py

示例8: connect

# 需要导入模块: from mailsnake import MailSnake [as 别名]
# 或者: from mailsnake.MailSnake import listSubscribe [as 别名]
def connect(request):
  ms = MailSnake(settings.MAILCHIMP_API_KEY)
  lists = ms.lists()
  if request.method == 'POST':
    form = ConnectForm(request.POST)
    message = 'the sky is falling'
    if form.is_valid():
      ms.listSubscribe(
          id = lists['data'][0]['id'],
          email_address = (form.cleaned_data['email_signup']),
          update_existing = True,
          double_optin = False,
      )
      
      #ms.listStaticSegmentMembersAdd(
      #    id = lists['data'][0]['id'],
      #    seg_id = 157, #Fake Development People... kill this in production!
      #    batch = {
      #        'email_address': form.cleaned_data['email_signup']
      #        },
      #)
      
      
      if request.is_ajax(): #success with js
          message = 'success!'
          status = True
          return HttpResponse(json.dumps({'message':message, 'status':status}), 'application/json')
      else: #success with no js
          return redirect('success') 
    else:
      if request.is_ajax(): #error with js
          message = 'Invalid email address'
          status = False
          return HttpResponse(json.dumps({'message':message, 'status':status}), 'application/json')
      else: # error with no js
          form.addError('Invalid email address')  
  else:
    form = ConnectForm()
  
  
  return render_to_response(
    'signups/connect.html',
    {
      'form': form,
   
    },
    context_instance=RequestContext(request)
  )
开发者ID:davogler,项目名称:POST,代码行数:50,代码来源:views.py

示例9: api_createuser

# 需要导入模块: from mailsnake import MailSnake [as 别名]
# 或者: from mailsnake.MailSnake import listSubscribe [as 别名]
def api_createuser(request):
    code = 100
    data = {'code':code, 'error': 'Request Error'}
    
    if request.POST:
        if 'name' in request.POST and 'email' in request.POST and 'password' in request.POST:
            name = request.POST['name']
            email_x = request.POST['email']
            password = request.POST['password']
            
            email = email_x.lower()
            
            if validateEmail(email):
                ck_u = User.objects.filter(email=email)
                if len(ck_u) > 0: 
                    existing_user = True
                    code = 100
                    data = {'code':code, 'error': 'User Already Exists'}
                else:
                    existing_user = False
                    u = User(username=email, password=password, email=email)
                    u.save()
                
                    """create invitation"""
                    store = Store.objects.filter(active=True,city='San Francisco')[0]
                    inv = Invitation(user=u, default_store=store, email=u.username, used=True)
                    inv.save()
                    
                    up = UserProfile(user=u, default_store=store)
                    up.save()
                    
                    """create default subscription"""
                    sub = Subscription(userprofile=up, subscription=False, subscription_type='un-subscribed')
                    sub.save()
                    
                    """Send admin email"""
                    sendSignupAdminEmail(u, 'San Francisco')
                    
                    """Send user email"""
                    sendWelcomeEmail(email,'sanfrancisco', 'San Francisco')
                    
                    """subscribe user to daily email"""
                    LIST_IDS = {'san-francisco':'eaa0a378ba'}
                    l_id = LIST_IDS['san-francisco']
                    
                    ms = MailSnake(settings.MAILCHIMP_API_KEY)
                    success = ms.listSubscribe(id=l_id, email_address=u.email, double_optin=False)
                    
                    d, code = api_auth_helper(u)
                    code = 200
                    data = {'code':code, 'account':d['account']}
            else:
                code = 100
                data = {'code':code, 'error': 'Invalid Email'}
        else:
            code = 100
            data = {'code':code, 'error': 'Invalid Sign-up'}
          
    return HttpResponse(simplejson.dumps(data, cls=MyJSONEncoder),content_type = 'application/javascript; charset=utf8')
开发者ID:serkanh,项目名称:Yupeat,代码行数:61,代码来源:views.py

示例10: MailchimpRegistrar

# 需要导入模块: from mailsnake import MailSnake [as 别名]
# 或者: from mailsnake.MailSnake import listSubscribe [as 别名]
class MailchimpRegistrar(object):
    _mail_snake = None

    def __init__(self):
        if not hasattr(settings, 'MAILCHIMP_API_KEY'):
            logger.error('MailChimp API key not present')
        self._mail_snake = MailSnake(settings.MAILCHIMP_API_KEY)

    def _register_email(self, email, list_id):
        self._mail_snake.listSubscribe(id=list_id,
                                       email_address=email,
                                       merge_vars={'EMAIL': email},
                                       double_optin=True,
                                       update_existing=True)

    def subscribe_to_events_notification(self, email):
        list_id = settings.MAILCHIMP_EVENTS_NOTIFICATION_LIST_ID
        self._register_email(email, list_id)
开发者ID:MouvementY,项目名称:y-engine,代码行数:20,代码来源:utils.py

示例11: form_valid

# 需要导入模块: from mailsnake import MailSnake [as 别名]
# 或者: from mailsnake.MailSnake import listSubscribe [as 别名]
    def form_valid(self, form):

      	ms = MailSnake(settings.MAILCHIMP_API_KEY)

        ms.listSubscribe(
            id = settings.MAILCHIMP_LIST_ID,
            email_address = form.cleaned_data['email'],
            merge_vars = {
                'FNAME': form.cleaned_data['first_name'],
                'GROUPINGS': [{'name':'reading','groups':'bcseoguide'}],
                },
            update_existing = True,
            double_optin = True,
        )

        if self.request.is_ajax():
            return self.response_class(
		request=self.request,
		template='sm/subscribe/ajax/success.html', 
		context={})
	
        return HttpResponseRedirect(reverse('subscribe_success'))
开发者ID:springmerchant,项目名称:sm,代码行数:24,代码来源:views.py

示例12: newsletter_signup

# 需要导入模块: from mailsnake import MailSnake [as 别名]
# 或者: from mailsnake.MailSnake import listSubscribe [as 别名]
def newsletter_signup(request):
    email = request.POST['email']

    if re.match('^[a-zA-Z0-9._%-][email protected][a-zA-Z0-9._%-]+.[a-zA-Z]{2,6}$', email):
        ms = MailSnake(settings.MAILCHIMP_KEY)
        r = ms.listSubscribe(id='df179acee6', email_address=email)
        print(r)
        if r:
            return HttpResponse()  
        else:
            return HttpResponseServerError()
    else:
        #Invalid email address. Return 400        
        return HttpResponseBadRequest(content='Invalid email address')
开发者ID:kiwiholmberg,项目名称:gbc,代码行数:16,代码来源:api.py

示例13: new_member

# 需要导入模块: from mailsnake import MailSnake [as 别名]
# 或者: from mailsnake.MailSnake import listSubscribe [as 别名]
def new_member(request):
	#auth.logout(request)
	if request.method == 'POST':
		uform = MyUserCreationForm(request.POST)
		pform = MemberForm(request.POST)
		if uform.is_valid() and pform.is_valid():
			user = uform.save()
			member = pform.save(commit=False)
			member.user = user
			member.save()
			user = authenticate(username=uform.data['username'], password=uform.data['password1'])
			auth.login(request, user)
			
			if settings.USE_MAILCHIMP:
				ms = MailSnake(settings.MAILCHIMP_API_KEY)
				lists = ms.lists()
				ms.listSubscribe(
					id = lists['data'][0]['id'], #TODO: assumes use of first list,
					email_address = user.email,
					merge_vars = {
						'FNAME' : user.first_name,
						'LNAME' : user.last_name,
					},
					update_existing = True,
					double_optin = False, #no confirm message
					send_welcome = True, #note: won't send if merely updates existing
				)
			
			return redirect('membership.views.enrollment')
	else:
		uform = MyUserCreationForm()
		pform = MemberForm()
	d = {
		'uform':uform,
		'pform':pform,
	}
	return render(request, 'membership/new_member.html', d)
开发者ID:lexic92,项目名称:byu-acm,代码行数:39,代码来源:views.py

示例14: ajax_signup

# 需要导入模块: from mailsnake import MailSnake [as 别名]
# 或者: from mailsnake.MailSnake import listSubscribe [as 别名]
def ajax_signup(request):
    if request.POST:
        new_signup = MyUserCreationForm(request.POST)
        if new_signup.is_valid():
            new_signup.save()
            uname = new_signup.cleaned_data["username"]

            """set up so username and email are the same"""
            user = User.objects.get(username=uname)
            user.email = uname
            user.save()

            """create user profile"""
            store_id = request.POST.get("default_store")
            store = Store.objects.get(id=store_id)
            up = UserProfile(user=user, default_store=store)
            up.save()

            """create default subscription"""
            sub = Subscription(userprofile=up, subscription=False, subscription_type="un-subscribed")
            sub.save()

            """email admin of new signup"""
            sendSignupAdminEmail(user, store)

            """email user with signup information"""
            sendSignupEmail(user, store)

            """subscrbe user to daily email"""
            LIST_IDS = {"sflaunch_group": "eaa0a378ba"}
            l_id = LIST_IDS["sflaunch_group"]

            ms = MailSnake(settings.MAILCHIMP_API_KEY)
            success = ms.listSubscribe(id=l_id, email_address=user.email, double_optin=False)

            username = user.username
            password = user.password
            user = authenticate(username=username, password=password)
            if user is not None:
                if user.is_active:
                    login(request, user)

            return HttpResponse("success", status=200)

    return HttpResponse("Username is already taken", status=403)
开发者ID:serkanh,项目名称:Yupeat,代码行数:47,代码来源:views.py

示例15: CreateNewUserHelper

# 需要导入模块: from mailsnake import MailSnake [as 别名]
# 或者: from mailsnake.MailSnake import listSubscribe [as 别名]
def CreateNewUserHelper(request, c_email, c_city):
    email = c_email.lower()
    token = get_rand_token()

    ck_u = User.objects.filter(email=email)
    if len(ck_u) > 0:
        existing_user = True
    else:
        existing_user = False
        u = User(username=email, password=token, email=email)
        u.save()

        """create invitation"""
        store = Store.objects.filter(active=True, city="San Francisco")[0]
        inv = Invitation(user=u, default_store=store, email=u.username, token=token, used=False)
        inv.save()

        # save in session
        request.session["user"] = base64.b16encode(str(u.id))

        CITY_LIST = {"san-francisco": "San Francisco"}
        cl_city = CITY_LIST[c_city]

        up = UserProfile(user=u, default_store=store)
        up.save()

        """create default subscription"""
        sub = Subscription(userprofile=up, subscription=False, subscription_type="un-subscribed")
        sub.save()

        """Send admin email"""
        sendSignupAdminEmail(u, cl_city)

        """Send welcome email to new user"""
        c = cl_city.lower()
        city = c.replace(" ", "")
        sendWelcomeEmail(email, token, city, cl_city)

        """subscribe user to daily email"""
        LIST_IDS = {"san-francisco": "eaa0a378ba"}
        l_id = LIST_IDS[c_city]

        ms = MailSnake(settings.MAILCHIMP_API_KEY)
        success = ms.listSubscribe(id=l_id, email_address=u.email, double_optin=False)
开发者ID:serkanh,项目名称:Yupeat,代码行数:46,代码来源:views.py


注:本文中的mailsnake.MailSnake.listSubscribe方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。