本文整理汇总了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,
})
示例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']
示例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"]
示例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)
示例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)
)
示例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)
示例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)
示例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)