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


Python mailsnake.MailSnake类代码示例

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


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

示例1: update_user_details

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,代码行数:28,代码来源:views.py

示例2: test_pending_user_subscription

 def test_pending_user_subscription(self):
     ms = MailSnake(settings.MAILCHIMP_API_KEY)
     user = get_admin_user()
     subscription = UserSubscription.objects.get(user=user)
     delete_member(user)
     ms.listInterestGroupingAdd(id=get_list_id(), 
                                name="Test Interest Group",
                                type="checkboxes",
                                groups=["Option 1", "Option 2"])
                                         
     # when a user signs up...
     pending, c = PendingUserSubscription.objects.get_or_create(user=user)
     optin_ip = getattr(settings, 'MAILCHIMP_TEST_IP', '184.106.168.48')
     optin_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
     pending.merge_vars = {
         'OPTIN_IP': optin_ip,
         'OPTIN_TIME': optin_time,
     }
     pending.save()
     
     # when the user is activated, confirmed, etc.
     pending.subscribe(double_optin=False)
     subscription.sync()
     self.assertEqual(optin_ip, subscription.optin_ip)
     self.assertEqual(optin_time, subscription.optin_time)
     self.assertTrue(subscription.is_subscribed())
     pending.delete()
开发者ID:Quixotix,项目名称:django-chimpusers,代码行数:27,代码来源:tests.py

示例3: earlyAccessSubmit

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,代码行数:26,代码来源:views.py

示例4: edit_profile

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 })
开发者ID:jmorrice,项目名称:garmsby-snippets,代码行数:26,代码来源:views.py

示例5: submit

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,代码行数:29,代码来源:views.py

示例6: main

def main(mailchimp_key, list_id, rapleaf_key):
    
    thirty_days_ago = datetime.datetime.now() - datetime.timedelta(days=30)
    ms = MailSnake(mailchimp_key)
    rapleaf = RapleafApi.RapleafApi(rapleaf_key)
    
    members = ms.listMembers(id=list_id, limit=1500)['data']
    
    active_members = []
    for member in members:
        member_activity = ms.listMemberActivity(id=list_id, email_address=member['email'])
        actions = [action for action in member_activity['data'][0] if action['action'] == 'open']
        if actions:
            last_action = actions[0]
            last_event = datetime.datetime.strptime(last_action['timestamp'], "%Y-%m-%d %H:%M:%S")
            if last_event > thirty_days_ago:
                active_members.append(member['email'])
    
    age_map = defaultdict(int)
    for active_member in active_members:
        try:
            response = rapleaf.query_by_email(active_member)
            age = response.get("age")
            age_map[age] += 1
            # for k, v in response.iteritems():
            #     print '%s = %s' % (k, v)
        except Exception as e:
          print e
    for x, y in age_map.iteritems():
        print x, y
开发者ID:spulec,项目名称:mailchimp_rapleaf,代码行数:30,代码来源:connect.py

示例7: api_createuser

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,代码行数:59,代码来源:views.py

示例8: find_list

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,代码行数:8,代码来源:pericles.py

示例9: find_list

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,代码行数:8,代码来源:pericles.py

示例10: main_post

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,代码行数:9,代码来源:basic.py

示例11: connect_mailchimp

def connect_mailchimp(api_key):
    """
    Initializes connection to the mailchimp api
    """
    mailchimp = MailSnake(api_key)
    result = mailchimp.ping()
    log.debug(result)

    return mailchimp
开发者ID:Lektorium-LLC,项目名称:edx-platform,代码行数:9,代码来源:mailchimp_sync_course.py

示例12: main_post

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,代码行数:9,代码来源:basic.py

示例13: find_template

def find_template(name):
    mc = MailSnake(settings.MC_API_KEY)
    templates = mc.templates()["user"]

    for temp in templates:
        if temp["name"] == name:
            return temp["id"]

    return 0
开发者ID:kylehg,项目名称:pericles,代码行数:9,代码来源:pericles.py

示例14: form_valid

    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,代码行数:13,代码来源:views.py

示例15: newsletter_signup

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,代码行数:14,代码来源:api.py


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