Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Feed(PolymorphicModel):
- active = models.BooleanField(default=True)
- feed_code = models.CharField(max_length=60)
- feed_delay = models.SmallIntegerField(default=0, validators=[MinValueValidator(-4)])
- feed_description = models.CharField(max_length=255, blank=True)
- feed_name = models.CharField(max_length=60)
- feed_type = models.ForeignKey(FeedType)
- partner = models.ForeignKey(Partner)
- # Schedule Settings
- schedule_type = models.CharField(max_length=1, choices=SCHEDULE_TYPE_CHOICES)
- # this is stored as minute of the day (so 6:30am is 390)
- time_of_day = models.IntegerField("Time", blank=True, null=True, choices=TIME_OF_DAY_CHOICES)
- class Meta:
- verbose_name_plural = 'Feeds'
- abstract = True
- def __unicode__(self):
- return u'%s' % self.feed_name
- def date_is_within_embargo(self, content_date):
- """
- Pass in a date (possibly an Issue publication date, and get a Boolean
- back indicating whether or not this feed is allowed to have the content.
- If the Content's date + feed_delay < today, return True
- """
- today = datetime.now().replace(hour=0, minute=0, second=0, microsecond=0)
- # Compute the most recent possible date, based on this feed's delay
- latest_valid_date = content_date + timedelta(days=int(self.feed_delay))
- # Return whether the requested date is before the latest valid date
- if latest_valid_date < today:
- return True
- return False
- def deliver(self):
- raise NotImplementedError('This must be implemented')
- class KirkusHostedFTPFeed(Feed):
- username = models.CharField(max_length=24, unique=True)
- password = models.CharField(max_length=64)
- def deliver(self):
- pass
- class EmailFeed(Feed):
- email_list = models.TextField(blank=True)
- def deliver(self):
- pass
- class ExternalFTPFeed(Feed):
- remote_server_name = models.CharField(max_length=100, blank=True)
- remote_username = models.CharField(max_length=30, blank=True)
- remote_password = models.CharField(max_length=30, blank=True)
- remote_path = models.CharField(max_length=200, blank=True)
- def deliver(self):
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement