コード例 #1
0
    def handle(self, *args, **options):

        print("- profile")
        from dashboard.models import Profile
        # right now, we only take profiles that've given us an access token
        profiles = Profile.objects.exclude(github_access_token='').exclude(
            email='').all()
        # in the future, though, we could take ALL github profiles in the system and use those
        # profiles = Profile.objects.exclude(email='').all()
        for profile in profiles:
            process_email(profile.email, 'profile_email')

        print("- match")
        from marketing.models import Match
        for match in Match.objects.all():
            process_email(match.email, 'match')

        get_size = 50
        client = MailChimp(settings.MAILCHIMP_USER, settings.MAILCHIMP_API_KEY)

        print('mailchimp')
        for i in range(0, 90000):
            members = client.lists.members.all(settings.MAILCHIMP_LIST_ID,
                                               count=get_size,
                                               offset=(i * get_size),
                                               fields="members.email_address")
            members = members['members']
            if not len(members):
                break
            print(i)
            for member in members:
                email = member['email_address']
                process_email(email, 'mailchimp')
        #TODO: could sync back
        #with client.lists.members.create(
        print('/mailchimp')

        print('local')
        print("- dashboard_sub")
        from dashboard.models import Subscription
        for sub in Subscription.objects.all():
            email = sub.email
            process_email(email, 'dashboard_subscription')

        print("- tip")
        from dashboard.models import Tip
        for tip in Tip.objects.all():
            for email in tip.emails:
                process_email(email, 'tip_usage')
            if tip.from_email:
                process_email(tip.from_email, 'tip_usage')

        print("- bounty")
        from dashboard.models import Bounty
        for b in Bounty.objects.all():
            email_list = []
            if b.bounty_owner_email:
                email_list.append(b.bounty_owner_email)
            if b.fulfiller_email:
                email_list.append(b.fulfiller_email)
            for email in email_list:
                process_email(email, 'bounty_usage')

        print("- tdi")
        from tdi.models import WhitepaperAccess, WhitepaperAccessRequest
        for wa in WhitepaperAccess.objects.all():
            process_email(wa.email, 'whitepaperaccess')

        for wa in WhitepaperAccessRequest.objects.all():
            process_email(wa.email, 'whitepaperaccessrequest')

        print('/local')
コード例 #2
0
    def handle(self, *args, **options):
        get_size = 50
        client = MailChimp(settings.MAILCHIMP_USER, settings.MAILCHIMP_API_KEY)

        print('mailchimp')
        for i in range(0, 90000):
            members = client.lists.members.all(settings.MAILCHIMP_LIST_ID,
                                               count=get_size,
                                               offset=(i * get_size),
                                               fields="members.email_address")
            members = members['members']
            if not len(members):
                break
            print(i)
            for member in members:
                email = member['email_address']
                process_email(email, 'mailchimp')
        #TODO: could sync back
        #with client.lists.members.create(
        print('/mailchimp')

        print('local')
        print("- dashboard_sub")
        from dashboard.models import Subscription
        for sub in Subscription.objects.all():
            email = sub.email
            process_email(email, 'dashboard_subscription')

        print("- tip")
        from dashboard.models import Tip
        for tip in Tip.objects.all():
            for email in tip.emails:
                process_email(email, 'tip_usage')

        print("- bounty")
        from dashboard.models import Bounty
        for b in Bounty.objects.all():
            email_list = []
            if b.bounty_owner_email:
                email_list.append(b.bounty_owner_email)
            if b.claimee_email:
                email_list.append(b.claimee_email)
            for email in email_list:
                process_email(email, 'bounty_usage')

        print("- tdi")
        from tdi.models import WhitepaperAccess, WhitepaperAccessRequest
        for wa in WhitepaperAccess.objects.all():
            process_email(wa.email, 'whitepaperaccess')

        for wa in WhitepaperAccessRequest.objects.all():
            process_email(wa.email, 'whitepaperaccessrequest')

        print('/local')
コード例 #3
0
ファイル: sync_mail.py プロジェクト: zzyyxxww/web
def pull_to_db():
    print('- pull_to_db')
    print("- profile")
    from dashboard.models import Profile
    # right now, we only take profiles that've given us an access token
    profiles = Profile.objects.exclude(email='').all()
    # in the future, though, we could take ALL github profiles in the system and use those
    # profiles = Profile.objects.exclude(email='').all()
    for profile in profiles:
        process_email(profile.email, 'profile_email')

    print("- match")
    from marketing.models import Match
    for match in Match.objects.all():
        process_email(match.email, 'match')

    get_size = 50
    client = MailChimp(mc_api=settings.MAILCHIMP_API_KEY,
                       mc_user=settings.MAILCHIMP_USER)

    print('mailchimp')
    for i in range(0, 90000):
        members = client.lists.members.all(settings.MAILCHIMP_LIST_ID,
                                           count=get_size,
                                           offset=(i * get_size),
                                           fields="members.email_address")
        members = members['members']
        if not members:
            break
        print(i)
        for member in members:
            email = member['email_address']
            process_email(email, 'mailchimp')
    print('/mailchimp')

    print('local')
    print("- dashboard_sub")
    from dashboard.models import Subscription
    for sub in Subscription.objects.all():
        email = sub.email
        process_email(email, 'dashboard_subscription')

    print("- tip, Kudos")
    from dashboard.models import Tip
    from kudos.models import KudosTransfer
    objects = [Tip, KudosTransfer]
    for obj in objects:
        for _this in obj.objects.all():
            # do not add receive tip emails to the mailing list,
            # don't want to spam people at 4 diff email addresses
            # for email in tip.emails:
            #    process_email(email, 'tip_usage')
            if _this.from_email:
                process_email(_this.from_email, 'kudos_tip_usage')
            if _this.primary_email:
                process_email(_this.primary_email, 'kudos_tip_receive')

    print("- bounty")
    from dashboard.models import Bounty
    for b in Bounty.objects.prefetch_related('fulfillments').all():
        email_list = []
        if b.bounty_owner_email:
            email_list.append(b.bounty_owner_email)
        for fulfiller in b.fulfillments.all():
            if fulfiller.fulfiller_email:
                email_list.append(fulfiller.fulfiller_email)
        for email in email_list:
            process_email(email, 'bounty_usage')

    print("- tdi")
    from tdi.models import WhitepaperAccess, WhitepaperAccessRequest
    for wa in WhitepaperAccess.objects.all():
        process_email(wa.email, 'whitepaperaccess')

    for wa in WhitepaperAccessRequest.objects.all():
        process_email(wa.email, 'whitepaperaccessrequest')

    print('/pull_to_db')