Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class CommissionImportCommissionJunction(models.Model):
- class Meta(object):
- db_table = u'commission_import_commission_junction'
- objects = CommissionImportCommissionJunctionManager()
- commission_import_commission_junction_id = models.AutoField(primary_key=True)
- action_status = models.CharField(max_length=50)
- action_type = models.CharField(max_length=50)
- ad_id = models.BigIntegerField(null=True, blank=True)
- commission_id = models.BigIntegerField()
- country = models.CharField(max_length=255, null=True, blank=True)
- event_date = models.DateTimeField()
- locking_date = models.DateTimeField(null=True, blank=True)
- order_id = models.CharField(max_length=50)
- original = models.NullBooleanField(null=True, blank=True)
- original_action_id = models.BigIntegerField()
- posting_date = models.DateTimeField()
- website_id = models.BigIntegerField()
- advertiser_name = models.CharField(max_length=500, null=True, blank=True)
- commission_amount = models.DecimalField(max_digits=19, decimal_places=2)
- sale_amount = models.DecimalField(max_digits=19, decimal_places=2)
- aggregator_affiliate_id = models.IntegerField()
- is_processed = models.BooleanField(db_index=True)
- created_date = models.DateTimeField(auto_now_add=True)
- member_transaction = models.ForeignKey(transactionsmodels.MemberTransaction, null=True, blank=True)
- commission_import_build = models.ForeignKey(CommissionImportBuild)
- sid = models.CharField(max_length=255, null=True, blank=True)
- error_description = models.TextField(null=True, blank=True)
- error_type = models.ForeignKey(ImportErrorType, db_column='error_type', to_field='error_type_code', null=True, blank=True)
- class Affiliate(models.Model):
- ''' Affiliate.
- Fields maintained EXPLICITLY by CSV imports:
- - aggregator/aggregator_affiliate_id (PK)
- - aggregator_affiliate_name
- - name
- - website_name
- - offer (JSON) :: AffiliateCommissionBracket, NonCommissionableGood, CommissionableGood, select_goods_only, has_non_commissionable_goods
- - notes
- - green
- - categories (CSV) :: AffiliateCategory
- - description
- - rollover
- - days_to_return
- - active
- - impression_pixel
- - aggregator_affiliate_name
- - Optionally:
- - link
- - link_expiration_date
- - image_src
- - impression_pixel
- Fields implicitly maintained by CSV imports:
- - auto_activate
- - updated -- if image_src and link are supplied, updated gets set to True
- Fields implicitly maintained by the old Affiliate Admin system:
- - updated
- Share-A-Sale updates take up too many API credits. Updating the links
- and images needs to be done manually after the first time they are updated.
- '''
- affiliate_id = models.AutoField(primary_key=True)
- aggregator = models.ForeignKey(aggregatorsmodels.Aggregator)
- #: This is the ID of the affiliate given by an Aggregator
- aggregator_affiliate_id = models.IntegerField()
- #: This is the name of the affiliate given by an Aggregator
- aggregator_affiliate_name = models.CharField(max_length=255, null=True, blank=True)
- #: This is the name of the affiliate given by Employee Rewards
- name = models.CharField(max_length=255, null=True, blank=True)
- #: This is a description of the affiliate. It is displayed over the affiliate website name
- description = models.TextField(max_length=1000, null=True, blank=True)
- #: This is a secondary description of the affiliate. It is displayed over the affiliate image
- rollover = models.TextField(max_length=1000, null=True, blank=True)
- #: This is the link to follow to reach this affiliate's website and be tracked through the aggregator
- link = models.CharField(max_length=1024, null=True, blank=True)
- #: This is the day the link expires
- link_expiration_date = models.DateTimeField(null=True, blank=True)
- #: The URL of this affiliate's image
- image_src = models.CharField(max_length=1024, null=True, blank=True)
- #: The local filepath of this affiliate's image
- image_filepath = models.CharField(max_length=1000, null=True, blank=True)
- #: Whether or not this affiliate is active on the aggreagtor system.
- active = models.BooleanField(db_index=True, default=False)
- #: The name of the affiliate's website i.e. walmart.com or bestbuy.com
- website_name = models.CharField(max_length=150, null=True, blank=True)
- #: Admin notes about this affiliate
- notes = models.TextField(max_length=1000, null=True, blank=True)
- #: A URL of a pixel used to track how many times an affiliate's information has been shown to customers
- impression_pixel = models.CharField(max_length=1000, null=True, blank=True)
- #: Whether or not this affiliate is explicitly earth-friendly
- green = models.NullBooleanField(null=True, blank=True)
- #: Number of days an affiliate takes before issuing commission for purchases
- days_to_return = models.IntegerField(null=True, blank=True)
- auto_activate = models.BooleanField(default=False)
- ''' If an affiliate is uploaded for the first time, it is not active, but
- will be automatically activated when the next affiliates update occurs and
- the affiliate is ready to be seen by the public'''
- #: Whether this affiliate has commission only on select goods.
- is_select_goods_only = models.BooleanField(default=False)
- has_non_commissionable_goods = models.BooleanField(default=False)
- ''' Whether or not this affiliate has goods that do not have a commission reward.
- Helpful when a list of those goods is not available. '''
- #: Whether or not this Affiliate has been published, and should be shown to the customer
- published = models.BooleanField(default=False)
- #: Specify the through-table for our M2M relationship with categories
- categories = models.ManyToManyField(categorymodels.Category, through='AffiliateCategory')
- class Meta(object):
- db_table = u'affiliates'
- unique_together = ("aggregator", "aggregator_affiliate_id")
- ordering = ['name']
- def __unicode__(self):
- return self.name
- def get_external_properties(self):
- return self.aggregator.proxy.affiliate_properties(self.aggregator_affiliate_id)
- class MemberHash(models.Model):
- member_hash_id = models.AutoField(primary_key=True)
- member = models.ForeignKey('Member')
- site = models.ForeignKey(legacymodels.Site)
- hash = models.CharField(unique=True, max_length=24)
- class Meta(object):
- db_table = u'member_hashes'
- class CommissionImportBuild(models.Model):
- commission_import_build_id = models.AutoField(primary_key=True)
- build_date = models.DateTimeField(unique=True)
- class Meta(object):
- db_table = u'commission_import_builds'
- def __unicode__(self):
- return self.build_date.strftime('%B %m, %Y, %I:%M %p')
- # Create your models here.
- class Aggregator(models.Model):
- aggregator_id = models.AutoField(primary_key=True)
- system_name = models.CharField(max_length=255, null=False, blank=False, unique=True)
- name = models.CharField(max_length=255, null=True, blank=True)
- active = models.BooleanField(default=False, db_index=True)
- #: The user name to log into the aggregator's management system/API
- account_username = models.CharField(max_length=255, null=True, blank=True)
- #: The password to log into the aggregator's management system/API
- account_password = models.CharField(max_length=255, null=True, blank=True)
- objects = AggregatorManager()
- linkshare_objects = LinkshareManager()
- commission_junction_objects = CommissionJunctionManager()
- shareasale_objects = ShareASaleManager()
- class Meta(object):
- db_table = u'aggregators'
- @property
- def proxy(self):
- return self._get_proxy()
- def _get_proxy(self):
- ''' Return the Proxy instance for this Aggregator. '''
- if self.name == 'Linkshare':
- return Linkshare.objects.get_instance()
- elif self.name == 'Commission Junction':
- return CommissionJunction.objects.get_instance()
- elif self.name == 'Share-A-Sale':
- return ShareASale.objects.get_instance()
- else:
- raise Exception('Invalid aggregator name "%s". Excpected Linkshare, Commission Junction, or Share-A-Sale.' % self.name)
- def __unicode__(self):
- return self.name
Add Comment
Please, Sign In to add comment