本文整理汇总了Python中mailsnake.MailSnake.listUpdateMember方法的典型用法代码示例。如果您正苦于以下问题:Python MailSnake.listUpdateMember方法的具体用法?Python MailSnake.listUpdateMember怎么用?Python MailSnake.listUpdateMember使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mailsnake.MailSnake
的用法示例。
在下文中一共展示了MailSnake.listUpdateMember方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: edit_profile
# 需要导入模块: from mailsnake import MailSnake [as 别名]
# 或者: from mailsnake.MailSnake import listUpdateMember [as 别名]
def edit_profile(request):
user = request.user
email = user.email
#after submission
if request.method == 'POST':
edit_profile_form = EditProfileForm(request.POST, request.FILES, instance=user.profile)
edit_user_form = EditUserForm(request.POST, request.FILES, instance=user, request=request)
#success
if edit_profile_form.is_valid() and edit_user_form.is_valid():
ms = MailSnake('f92abfa01e0a9cecc885186de4e37106-us7')
print user.email
ms.listUpdateMember(id='ed61191f4e', email_address=email, merge_vars={
'FNAME':edit_user_form.cleaned_data.get('first_name'),
'LNAME':edit_user_form.cleaned_data.get('last_name'),
'EMAIL':edit_user_form.cleaned_data.get('email'),
})
edit_profile_form.save()
edit_user_form.save()
return redirect('/profiles/' + user.username)
#before submission
else:
edit_profile_form = EditProfileForm(instance=user.profile)
edit_user_form = EditUserForm(instance=user, request=request)
user_profile = user
return render(request, 'edit_profile.html', {'edit_profile_form': edit_profile_form, 'edit_user_form': edit_user_form, 'user_profile' : user_profile })
示例2: handle_noargs
# 需要导入模块: from mailsnake import MailSnake [as 别名]
# 或者: from mailsnake.MailSnake import listUpdateMember [as 别名]
def handle_noargs(self, **options):
try:
ms = MailSnake('f92abfa01e0a9cecc885186de4e37106-us7')
self.stdout.write('connected to mailchimp')
except:
raise CommandError("Can't connect to MailChimp")
designs = Design.objects.filter(created__gt=datetime.now(timezone('Europe/London')) - timedelta(days=14))
designers = []
for design in designs:
designers.append(design.designer)
for designer in set(designers):
user_designs = designs.filter(designer=designer)[:3]
self.stdout.write('updating ' + user_designs[0].name + ' by ' + designer.first_name + ' ' + designer.last_name)
ms.listUpdateMember(id='ed61191f4e', email_address=designer.email, merge_vars = {
'TITLE1':user_designs[0].name,
'URL1':user_designs[0].tee_pic,
'LIKES1':user_designs[0].likes,
'COMMENTS1':Comment.objects.filter(object_pk=user_designs[0].id).count()
})
if len(user_designs) > 1:
self.stdout.write('updating ' + user_designs[1].name + ' by ' + designer.first_name + ' ' + designer.last_name)
ms.listUpdateMember(id='ed61191f4e', email_address=designer.email, merge_vars = {
'TITLE2':user_designs[1].name,
'URL2':user_designs[1].tee_pic,
'LIKES2':user_designs[1].likes,
'COMMENTS2':Comment.objects.filter(object_pk=user_designs[1].id).count()
})
else:
ms.listUpdateMember(id='ed61191f4e', email_address=designer.email, merge_vars = {
'TITLE2':'',
'URL2':'',
'LIKES2':'',
'COMMENTS2':'',
})
if len(user_designs) > 2:
self.stdout.write('updating ' + user_designs[2].name + ' by ' + designer.first_name + ' ' + designer.last_name)
ms.listUpdateMember(id='ed61191f4e', email_address=designer.email, merge_vars = {
'TITLE3':user_designs[2].name,
'URL3':user_designs[2].tee_pic,
'LIKES3':user_designs[2].likes,
'COMMENTS3':Comment.objects.filter(object_pk=user_designs[2].id).count()
})
else:
ms.listUpdateMember(id='ed61191f4e', email_address=designer.email, merge_vars = {
'TITLE3':'',
'URL3':'',
'LIKES3':'',
'COMMENTS3':'',
})
self.stdout.write('done.')
示例3: main
# 需要导入模块: from mailsnake import MailSnake [as 别名]
# 或者: from mailsnake.MailSnake import listUpdateMember [as 别名]
def main():
mailsnake = MailSnake("385108a2f086d0ede1a046291c92fc4f-us2")
list_num = "e2f95e9547"
for email in emails:
try:
returned = mailsnake.listUpdateMember(
id=list_num,
email_address=email,
merge_vars={
'PURCHASED': True
}
)
print "updated", email
except EmailNotExistsException:
print email, "isn't a subscriber"
continue
except ListNotSubscribedException:
print email, "isn't a part of this list"
continue