예제 #1
0
class SourceSite(models.Model):
    tweet = models.ForeignKey(Tweet)
    url = models.CharField(max_length=2000)
    domain = URLProtocolField(max_length=2000, verbose_name="Source Site")
    matched = models.BooleanField(default=False)

    def __unicode__(self):
        return self.url
예제 #2
0
파일: models.py 프로젝트: danhuacai/Voyage
class SourceSite(models.Model):
    class Meta:
        verbose_name = "Sourced Article"

    version = models.ForeignKey(Version)
    url = models.CharField(max_length=20000)
    domain = URLProtocolField(max_length=20000, verbose_name="Source Site")
    anchor_text = models.CharField(max_length=20000,
                                   verbose_name="Anchor Text")
    matched = models.BooleanField(default=False)
    local = models.BooleanField(default=True)
    referring_url = models.CharField(max_length=20000, default="")

    @property
    def title(self):
        return self.version.title

    @property
    def text(self):
        return self.version.text

    @property
    def text_hash(self):
        return self.version.text_hash

    @property
    def language(self):
        return self.version.language

    @property
    def date_added(self):
        return self.version.date_added

    @property
    def date_last_seen(self):
        return self.version.date_last_seen

    @property
    def date_published(self):
        return self.version.date_published

    # title = models.CharField(max_length=200, blank=True, null=True)
    # text = models.TextField(max_length=None, blank=True, null=True)
    # text_hash = models.CharField(max_length=100, blank=True, unique=True, null=True)
    # language = models.CharField(max_length=200, choices=LANGUAGES, blank=True, null=True)
    # date_added = models.DateTimeField('Date Added', blank=True, null=True)
    # date_last_seen = models.DateTimeField('Date Last Seen', blank=True, null=True)
    # date_published = models.DateTimeField('Date Published', blank=True, null=True)
    # is_referring = models.NullBooleanField(default=None)

    def __unicode__(self):
        return self.url
예제 #3
0
파일: models.py 프로젝트: danhuacai/Voyage
class ReferringTwitterIgnoreURL(models.Model):
    user = models.ForeignKey(ReferringTwitter)
    ignore_url = URLProtocolField(
        max_length=2000,
        unique=False,
        null=True,
        help_text=
        'Choose a simple URL to help for matching. Maximum 2000 characters (Ex. http://cnn.com)'
    )

    class Meta:
        verbose_name = 'URL To Ignore'
        verbose_name_plural = 'URLs To Ignore'

    def __unicode__(self):
        return self.ignore_url
예제 #4
0
파일: models.py 프로젝트: danhuacai/Voyage
class SourceSite(models.Model):
    url = URLProtocolField(
        max_length=2000,
        unique=True,
        help_text=
        'Choose a simple URL to maximize matches. Maximum 2000 characters (Ex. http://aljazeera.com)'
    )
    name = models.CharField(max_length=200,
                            unique=True,
                            help_text='Your favorable name of this site.')
    tags = TaggableManager()

    class Meta:
        verbose_name = 'Source Site'

    def __unicode__(self):
        return self.name
예제 #5
0
파일: models.py 프로젝트: danhuacai/Voyage
class ReferringSite(models.Model):
    url = URLProtocolField(
        max_length=2000,
        unique=True,  #validators=[validate_site],
        help_text=
        'Choose a simple URL to maximize matches. Maximum 2000 characters (Ex. http://cnn.com)'
    )
    name = models.CharField(max_length=200,
                            unique=True,
                            help_text='Your favorable name of this site.\n' +
                            'Maximum 200 characters')
    # check = models.BooleanField(default=False, verbose_name="Test Newspaper RSS Scan",
    #                             help_text=mark_safe('Check to display the amount of articles found by Newspaper RSS Scan (Displays as error).<br>Uncheck to save without testing Newspaper.'))

    is_shallow = models.BooleanField(
        default=False,
        verbose_name="Shallow State",
        help_text=mark_safe(
            'Use shallow crawler to search only until depth of 5'))
    tags = TaggableManager()

    crawl_choices = ((0, 'RSS'), (1, 'MediaCAT Crawler'), (2, 'Both'))

    # crawl_count = models.IntegerField(default=0)
    mode = models.PositiveIntegerField(
        default=0,
        choices=crawl_choices,
        verbose_name='Scanner',
        help_text=mark_safe(
            'RSS - Fast but may not work on some sites.<br>'
            +  # Use Check Newspaper to determine the compatibility<br>' +
            'MediaCAT Crawler - Slow but compatible with any sites.<br>' +
            'Both - Uses both Newspaper and MediaCAT CrawlerB for maximum results.'
        ))

    class Meta:
        verbose_name = 'Referring Site'

    def __unicode__(self):
        return self.name
예제 #6
0
파일: models.py 프로젝트: danhuacai/Voyage
class Url(models.Model):
    article = models.ForeignKey(Article)
    name = URLProtocolField(max_length=2000, verbose_name="URL", unique=True)

    def __unicode__(self):
        return self.name
예제 #7
0
파일: models.py 프로젝트: danhuacai/Voyage
class Article(models.Model):
    domain = URLProtocolField(max_length=2000, verbose_name="Referring Site")
    is_referring = models.NullBooleanField()
    is_source = models.NullBooleanField()
    referrals = models.ManyToManyField('self',
                                       related_name='sources',
                                       symmetrical=False)

    class Meta:
        verbose_name = "Referring Article"

    def __unicode__(self):
        if len(self.title) >= 30:
            return self.title[:27] + '...'
        return self.title

    @property
    def url(self):
        return self.url_set.first().name

    @property
    def title(self):
        if (self.version_set.last() == None):
            return "Version DNE"
        return self.version_set.last().title

    @property
    def text(self):
        return self.version_set.last().text

    @property
    def text_hash(self):
        return self.version_set.last().text_hash

    @property
    def language(self):
        if (self.version_set.last() == None):
            return "(None)"
        return self.version_set.last().language

    @property
    def date_added(self):
        if (self.version_set.last() == None):
            return "(None)"
        return self.version_set.last().date_added

    @property
    def date_last_seen(self):
        if (self.version_set.last() == None):
            return "(None)"
        return self.version_set.last().date_last_seen

    @property
    def date_published(self):
        if (self.version_set.last() == None):
            return "(None)"
        return self.version_set.last().date_published

    @property
    def found_by(self):
        if (self.version_set.last() == None):
            return "(None)"
        return self.version_set.last().found_by

    @property
    def source_url(self):
        if (self.version_set.last() == None):
            return "(None)"
        return self.version_set.last().sourcesite_set.last().url

    @property
    def source_anchor_text(self):
        if (self.version_set.last() == None):
            return "(None)"
        return self.version_set.last().sourcesite_set.last().anchor_text

    @property
    def source_matched(self):
        if (self.version_set.last() == None):
            return False
        return self.version_set.last().sourcesite_set.last().matched

    @property
    def source_local(self):
        if (self.version_set.last() == None):
            return False
        return self.version_set.last().sourcesite_set.last().local