# Path: pyfeedreader/database.py
# def init_db():
# def drop_all():
# 
# Path: pyfeedreader/models/entry.py
# class Entry(Model):
#     __tablename__ = "entry"
#     id = Column('id', Integer, primary_key=True)
#     feed_id = Column(Integer)
#     published = Column(Integer)
#     updated = Column(Integer)
#     title = Column(String(1024))
#     content = Column(Text)
#     description = Column(String(256))
#     link = Column(String(1024))
#     remote_id = Column(String(1024))
# 
#     def __init__(self, feed_id=None, published=None, updated=None, title=None, content=None, description=None,
#                  link=None, remote_id=None, unread=True):
#         self.feed_id = feed_id
#         self.published = published
#         self.updated = updated
#         self.title = title
#         self.content = content
#         self.description = description
#         self.link = link
#         self.remote_id = remote_id
#         self.unread = unread
# 
#     @staticmethod
#     def json_entry(entry, db_session, user_id):
#         """
#         Turns the entry object into a JSON ready dict object.
# 
#         :param entry: The entry you want to make JSON ready.
# 
#         :return: The JSON ready dict.
#         """
# 
#         read_entry = db_session.query(ReadEntry).filter(ReadEntry.entry_id == entry.id,
#                                                         ReadEntry.user_id == user_id).first()
#         unread = read_entry is None
# 
#         return {
#             "entry_id": entry.id,
#             "feed_id": entry.feed_id,
#             "published": entry.published,
#             "updated": entry.updated,
#             "title": entry.title,
#             "content": entry.content,
#             "description": entry.description,
#             "link": entry.link,
#             "remote_id": entry.remote_id,
#             "unread": unread,
#         }
# 
#     @staticmethod
#     def json_list(entries, db_session, user_id):
#         """
#         Turns a list of entries into JSON ready entries.
# 
#         :param entries: The list of entries you want to turn into JSON ready dicts.
# 
#         :return: List of JSON ready dicts.
#         """
# 
#         json_ready = []
#         for entry in entries:
#             json_ready.append(
#                 Entry.json_entry(entry, db_session, user_id)
#             )
# 
#         return json_ready
# 
# Path: pyfeedreader/models/feed.py
# class Feed(Model):
#     __tablename__ = "feed"
#     id = Column('id', Integer, primary_key=True)
#     feed_url = Column(String(1024))
#     last_checked = Column(Integer)
#     subscribers = Column(Integer)
#     title = Column(String(128))
#     update_frequency = Column(Integer)
#     favicon = Column(String(1024))
#     metadata_update = Column(Integer)
# 
#     def __init__(self, update_frequency=1, favicon="", feed_url=None, last_checked=1, subscribers=1,
#                  title=u"Some feed", metadata_update=1):
#         self.feed_url = feed_url
#         self.last_checked = last_checked
#         self.subscribers = subscribers
#         self.title = title
#         self.update_frequency = update_frequency
#         self.favicon = favicon
#         self.metadata_update = metadata_update
# 
#     @staticmethod
#     def json_list(feeds):
#         """
#         Creates a json ready list of feeds that is ready for jsonify.
# 
#         :param feeds List of feeds to turn to json.
# 
#         :return Returns a list of dicts that is ready to be turned to json.
#         """
#         json_ready = []
#         for feed in feeds:
#             json_ready.append(
#                 Feed.json(feed)
#             )
# 
#         return json_ready
# 
#     @staticmethod
#     def json(feed):
#         """
#         Turns a single feed into a json ready dict.
# 
#         :param feed The feed to turn to json ready.
#         """
#         return {
#             "feed_url": feed.feed_url,
#             "title": feed.title,
#             "favicon": feed.favicon,
#             "id": feed.id,
#             "unread": feed.unread,
#         }
# 
#     @staticmethod
#     def unread(feed, db_session, limit=100):
#         """
#         Finds the number of unread entries for the feed, it will only check the amount of entries specified in in the
#         limit parameter, some feeds might have thousands of entries and it would take too long to check them all.
# 
#         :param feed: The feed you want to check.
#         :param db_session: Current database session.
#         :param limit: The limit of entries to be checked, by default this is set to 100.
#         :return: The updated feed object.
#         """
# 
#         entries = db_session.query(Entry).filter(
#             Entry.feed_id == feed.id).order_by(
#             desc(Entry.updated)).limit(limit).all()
# 
#         ids = []
#         for entry in entries:
#             ids.append(entry.id)
# 
#         read_entries = db_session.query(ReadEntry).filter(
#             ReadEntry.entry_id.in_(ids)).all()
# 
#         feed.unread = len(entries) - len(read_entries)
# 
#         return feed


from pyfeedreader.database import Model
from sqlalchemy import Column, Integer, String, Text, desc
from sqlalchemy.orm import relationship
from pyfeedreader.models.entry import Entry
from pyfeedreader.models.feed import Feed
        self.username = username
        self.categories = categories
        self.feeds = feeds
        self.read_ents = read_ents

    def is_authenticated(self):
        return True

    def is_active(self):
        return True

    def is_anonymous(self):
        return False

    def get_id(self):
        return unicode(self.id)

    def q_categories(self, session):
        """
        Dont remember what this function is for
        TODO fix this.
        :param session:
        :return:
        """
        for category in self.categories:
            category.get_feeds(session)

    def get_feeds(self, session):
        temp_list = []
        for uf in self.feeds:

# Path: pyfeedreader/database.py
# def init_db():
# def drop_all():
# 
# Path: pyfeedreader/models/entry.py
# class Entry(Model):
#     __tablename__ = "entry"
#     id = Column('id', Integer, primary_key=True)
#     feed_id = Column(Integer)
#     published = Column(Integer)
#     updated = Column(Integer)
#     title = Column(String(1024))
#     content = Column(Text)
#     description = Column(String(256))
#     link = Column(String(1024))
#     remote_id = Column(String(1024))
# 
#     def __init__(self, feed_id=None, published=None, updated=None, title=None, content=None, description=None,
#                  link=None, remote_id=None, unread=True):
#         self.feed_id = feed_id
#         self.published = published
#         self.updated = updated
#         self.title = title
#         self.content = content
#         self.description = description
#         self.link = link
#         self.remote_id = remote_id
#         self.unread = unread
# 
#     @staticmethod
#     def json_entry(entry, db_session, user_id):
#         """
#         Turns the entry object into a JSON ready dict object.
# 
#         :param entry: The entry you want to make JSON ready.
# 
#         :return: The JSON ready dict.
#         """
# 
#         read_entry = db_session.query(ReadEntry).filter(ReadEntry.entry_id == entry.id,
#                                                         ReadEntry.user_id == user_id).first()
#         unread = read_entry is None
# 
#         return {
#             "entry_id": entry.id,
#             "feed_id": entry.feed_id,
#             "published": entry.published,
#             "updated": entry.updated,
#             "title": entry.title,
#             "content": entry.content,
#             "description": entry.description,
#             "link": entry.link,
#             "remote_id": entry.remote_id,
#             "unread": unread,
#         }
# 
#     @staticmethod
#     def json_list(entries, db_session, user_id):
#         """
#         Turns a list of entries into JSON ready entries.
# 
#         :param entries: The list of entries you want to turn into JSON ready dicts.
# 
#         :return: List of JSON ready dicts.
#         """
# 
#         json_ready = []
#         for entry in entries:
#             json_ready.append(
#                 Entry.json_entry(entry, db_session, user_id)
#             )
# 
#         return json_ready
# 
# Path: pyfeedreader/models/feed.py
# class Feed(Model):
#     __tablename__ = "feed"
#     id = Column('id', Integer, primary_key=True)
#     feed_url = Column(String(1024))
#     last_checked = Column(Integer)
#     subscribers = Column(Integer)
#     title = Column(String(128))
#     update_frequency = Column(Integer)
#     favicon = Column(String(1024))
#     metadata_update = Column(Integer)
# 
#     def __init__(self, update_frequency=1, favicon="", feed_url=None, last_checked=1, subscribers=1,
#                  title=u"Some feed", metadata_update=1):
#         self.feed_url = feed_url
#         self.last_checked = last_checked
#         self.subscribers = subscribers
#         self.title = title
#         self.update_frequency = update_frequency
#         self.favicon = favicon
#         self.metadata_update = metadata_update
# 
#     @staticmethod
#     def json_list(feeds):
#         """
#         Creates a json ready list of feeds that is ready for jsonify.
# 
#         :param feeds List of feeds to turn to json.
# 
#         :return Returns a list of dicts that is ready to be turned to json.
#         """
#         json_ready = []
#         for feed in feeds:
#             json_ready.append(
#                 Feed.json(feed)
#             )
# 
#         return json_ready
# 
#     @staticmethod
#     def json(feed):
#         """
#         Turns a single feed into a json ready dict.
# 
#         :param feed The feed to turn to json ready.
#         """
#         return {
#             "feed_url": feed.feed_url,
#             "title": feed.title,
#             "favicon": feed.favicon,
#             "id": feed.id,
#             "unread": feed.unread,
#         }
# 
#     @staticmethod
#     def unread(feed, db_session, limit=100):
#         """
#         Finds the number of unread entries for the feed, it will only check the amount of entries specified in in the
#         limit parameter, some feeds might have thousands of entries and it would take too long to check them all.
# 
#         :param feed: The feed you want to check.
#         :param db_session: Current database session.
#         :param limit: The limit of entries to be checked, by default this is set to 100.
#         :return: The updated feed object.
#         """
# 
#         entries = db_session.query(Entry).filter(
#             Entry.feed_id == feed.id).order_by(
#             desc(Entry.updated)).limit(limit).all()
# 
#         ids = []
#         for entry in entries:
#             ids.append(entry.id)
# 
#         read_entries = db_session.query(ReadEntry).filter(
#             ReadEntry.entry_id.in_(ids)).all()
# 
#         feed.unread = len(entries) - len(read_entries)
# 
#         return feed


# Path: pyfeedreader/models/user.py
from pyfeedreader.database import Model
from sqlalchemy import Column, Integer, String, Text, desc
from sqlalchemy.orm import relationship
from pyfeedreader.models.entry import Entry
from pyfeedreader.models.feed import Feed

        self.username = username
        self.categories = categories
        self.feeds = feeds
        self.read_ents = read_ents

    def is_authenticated(self):
        return True

    def is_active(self):
        return True

    def is_anonymous(self):
        return False

    def get_id(self):
        return unicode(self.id)

    def q_categories(self, session):
        """
        Dont remember what this function is for
        TODO fix this.
        :param session:
        :return:
        """
        for category in self.categories:
            category.get_feeds(session)

    def get_feeds(self, session):
        temp_list = []
        for uf in self.feeds:

            f = session.query(Feed).filter(Feed.id == uf.feed_id).first()