Beispiel #1
0
class Feed(model.Model):
    user = model.ForeignKey(User)
    title = model.Field()
    link = model.Field()
    #    subscribed = model.Field(default=True)
    rss = model.Field()

    def get_feed(self):
        feed = feedparser.parse(self.rss)
        return feed

    @classmethod
    def feed_exists(cls, link):
        return not Feed.is_unique(link=link)
Beispiel #2
0
class FeedList(model.Model):
    name = model.Field()
    user = model.ForeignKey(User)

    @classmethod
    def check_unique(cls, user, name):
        return FeedList.is_unique(user=user, name=name)
Beispiel #3
0
class User(model.Model):
    username = model.Field()
    default_user = model.Field(default=False)
    unread_only = model.Field(default=False)

    def subscribed(self):
        feeds = []
        for sub in Subscription.all(user=self):
            feeds.append(Feed.get(id=sub.feed.id))
        return feeds

    def set_default_user(self):
        u = User.get(default_user=True)
        u.default_user = False
        u.save()
        self.default_user = True
        self.save()

    @classmethod
    def get_default_user(self):
        return User.get(default_user=True)
Beispiel #4
0
class Entry(model.Model):
    feed = model.ForeignKey(Feed)
    user = model.ForeignKey(User)
    starred = model.Field(default=False)
    title = model.Field()
    updated = model.Field()
    created = model.Field()
    author = model.Field()
    content = model.Field()
    link = model.Field()

    def set_source(self):
        source_sub = re.sub('https?://', '', self.link)
        source = source_sub.split('/')[0]
        source = source.split('.')
        source = '.'.join(source[-2:])
        self.source = source

    def get_source(self):
        self.set_source()
        return self.source

    @classmethod
    def entry_exists(cls, link):
        return not Entry.is_unique(link=link)

    @classmethod
    def get_starred(cls, user):
        return list(Entry.all(user=user, starred=True))

    @classmethod
    def search_all(cls, user, query):
        matches = []
        for e in Entry.all(user=user):
            if query in e.title.lower() or query in c.content.lower():
                matches.append(e)
        return matches
Beispiel #5
0
class Message(orm.Model):
    user_from = orm.ForeignKey(User)  # field should be named "user_from_id"
    user_to = orm.ForeignKey(User)  # field should be named "user_to_id"
    date_sent = orm.Field()
    body = orm.Field()
    read = orm.Field(default=False)
Beispiel #6
0
class User(orm.Model):
    username = orm.Field()
    password = orm.Field()
Beispiel #7
0
class Filter(model.Model):
    name = model.Field()
    user = model.ForeignKey(User)
Beispiel #8
0
class EntryList(model.Model):
    name = model.Field()
    user = model.ForeignKey(User)