コード例 #1
0
def add_advertisers(advertisers_queryset):
    for advertiser_id in advertisers:
    
        try:
            advertiser = TV_Advertiser.objects.get(primary_committee__fec_id=advertiser_id)
        except:
            continue
    
        try:
            Organization.objects.get(related_advertiser=advertiser)
        
        except Organization.DoesNotExist:
            print "Missing adv %s. Creating it." % (advertiser.advertiser_name)
            name = Organization(name=advertiser.advertiser_name, organization_type='AD',related_advertiser=advertiser, created_by=user)
            name.save(user)
コード例 #2
0
def add_advertisers(advertisers_queryset):
    for advertiser_id in advertisers:

        try:
            advertiser = TV_Advertiser.objects.get(
                primary_committee__fec_id=advertiser_id)
        except:
            continue

        try:
            Organization.objects.get(related_advertiser=advertiser)

        except Organization.DoesNotExist:
            print "Missing adv %s. Creating it." % (advertiser.advertiser_name)
            name = Organization(name=advertiser.advertiser_name,
                                organization_type='AD',
                                related_advertiser=advertiser,
                                created_by=user)
            name.save(user)
コード例 #3
0
    def handle(self, *args, **options):
        
        user = User.objects.all()[0]
        print user
        
        adhawk_advertisers = TV_Advertiser.objects.filter(is_in_adhawk=True)
        for ah in adhawk_advertisers:
            name = Organization(name=ah.advertiser_name, organization_type='AD',related_advertiser=ah, created_by=user)
            print "Adding ad hawk group %s" % (ah.advertiser_name)
            name.save(user)

        for advertiser_id in advertiser_list:
        
            try:
                advertiser = TV_Advertiser.objects.get(primary_committee__fec_id=advertiser_id)
            except:
                try:
                    advertiser = TV_Advertiser.objects.get(secondary_committees__fec_id=advertiser_id)
                except:
                    continue
                continue
        
            try:
                Organization.objects.get(related_advertiser=advertiser)
            
            except Organization.DoesNotExist:
                print "Missing adv %s. Creating it." % (advertiser.advertiser_name)
                name = Organization(name=advertiser.advertiser_name, organization_type='AD',related_advertiser=advertiser, created_by=user)
                name.save(user)
コード例 #4
0
    def handle(self, *args, **options):

        user = User.objects.all()[0]
        print user

        adhawk_advertisers = TV_Advertiser.objects.filter(is_in_adhawk=True)
        for ah in adhawk_advertisers:
            name = Organization(name=ah.advertiser_name,
                                organization_type='AD',
                                related_advertiser=ah,
                                created_by=user)
            print "Adding ad hawk group %s" % (ah.advertiser_name)
            name.save(user)

        for advertiser_id in advertiser_list:

            try:
                advertiser = TV_Advertiser.objects.get(
                    primary_committee__fec_id=advertiser_id)
            except:
                try:
                    advertiser = TV_Advertiser.objects.get(
                        secondary_committees__fec_id=advertiser_id)
                except:
                    continue
                continue

            try:
                Organization.objects.get(related_advertiser=advertiser)

            except Organization.DoesNotExist:
                print "Missing adv %s. Creating it." % (
                    advertiser.advertiser_name)
                name = Organization(name=advertiser.advertiser_name,
                                    organization_type='AD',
                                    related_advertiser=advertiser,
                                    created_by=user)
                name.save(user)