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


Python MailSnake.lists方法代码示例

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


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

示例1: earlyAccessSubmit

# 需要导入模块: from mailsnake import MailSnake [as 别名]
# 或者: from mailsnake.MailSnake import lists [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: find_list

# 需要导入模块: from mailsnake import MailSnake [as 别名]
# 或者: from mailsnake.MailSnake import lists [as 别名]
def find_list(name):
    mc = MailSnake(settings.MC_API_KEY)
    lists = mc.lists(filters = {"list_name": name})

    if lists['total'] == 0:
        return 0

    return lists['data'][0]['id']
开发者ID:adicu,项目名称:pericles,代码行数:10,代码来源:pericles.py

示例3: find_list

# 需要导入模块: from mailsnake import MailSnake [as 别名]
# 或者: from mailsnake.MailSnake import lists [as 别名]
def find_list(name):
    mc = MailSnake(settings.MC_API_KEY)
    lists = mc.lists(filters={"list_name": name})

    if lists["total"] == 0:
        return 0

    return lists["data"][0]["id"]
开发者ID:kylehg,项目名称:pericles,代码行数:10,代码来源:pericles.py

示例4: form_valid

# 需要导入模块: from mailsnake import MailSnake [as 别名]
# 或者: from mailsnake.MailSnake import lists [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

示例5: connect

# 需要导入模块: from mailsnake import MailSnake [as 别名]
# 或者: from mailsnake.MailSnake import lists [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

示例6: handle

# 需要导入模块: from mailsnake import MailSnake [as 别名]
# 或者: from mailsnake.MailSnake import lists [as 别名]
    def handle(self, *args, **options):
        """
        Validates that the id passed in exists in mailchimp.
        """
        key, web_id = self.parse_options(options)

        mailchimp = MailSnake(key)

        lists = mailchimp.lists()['data']
        by_web_id = {l['web_id']: l for l in lists}

        list_with_id = by_web_id.get(web_id, None)

        if list_with_id:
            print "id: {} for web_id: {}".format(list_with_id['id'], web_id)
            print "list name: {}".format(list_with_id['name'])
        else:
            print "list with web_id: {} not found.".format(web_id)
            sys.exit(1)
开发者ID:10clouds,项目名称:edx-platform,代码行数:21,代码来源:mailchimp_id.py

示例7: new_member

# 需要导入模块: from mailsnake import MailSnake [as 别名]
# 或者: from mailsnake.MailSnake import lists [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

示例8: MailSnake

# 需要导入模块: from mailsnake import MailSnake [as 别名]
# 或者: from mailsnake.MailSnake import lists [as 别名]
from mailsnake import MailSnake
from mailsnake.exceptions import *
import settings
import logging

ms = MailSnake(settings.MAILCHIMP_API_KEY)

lists = ms.lists()

logger = logging.getLogger(__name__)


def subscribe_user(user):
    try:
        ms.listSubscribe(
            id=lists['data'][0]['id'],
            email_address=user.email,
            merge_vars={
                'USERNAME': user.username,
                'FNAME': user.first_name or '',
                'LNAME': user.last_name or '',
                },
            update_existing=True,
            double_optin=False,
            send_welcome=False,
        )
    except MailSnakeException:
        logger.warn('MailChimp listSubscribe call failed for user %s' % user.email, exc_info=True)
开发者ID:reverie,项目名称:jotleaf.com,代码行数:30,代码来源:email_marketing.py


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