# Path: pyfeedreader/models/ReadEntries.py
# class ReadEntry(Model):
#     __tablename__ = "read_entry"
#     id = Column('id', Integer, primary_key=True)
#     entry_id = Column(Integer)
#     user_id = Column(Integer, ForeignKey('user.id'))
# 
#     def __init__(self, entry_id, user_id):
#         self.entry_id = entry_id
#         self.user_id = user_id
# 
#     def __repr__(self):
#         return '<ReadEntry %r>' % self.username
# 
# Path: pyfeedreader/database.py
# def init_db():
# def drop_all():


from flask import *
from pyfeedreader.models.ReadEntries import ReadEntry
from pyfeedreader.database import db_session
from flask.ext.login import *
__author__ = 'DownGoat'



mod = Blueprint('read', __name__)

@mod.route("/read", methods=["POST"])
@login_required
def read_entry():
    if not request.form.get("entry_id", None):
        return jsonify(success=False)

    entry_id = request.form.get("entry_id", None)

    read_entry = ReadEntry(entry_id=entry_id, user_id=current_user.id)
    db_session.add(read_entry)

# Path: pyfeedreader/models/ReadEntries.py
# class ReadEntry(Model):
#     __tablename__ = "read_entry"
#     id = Column('id', Integer, primary_key=True)
#     entry_id = Column(Integer)
#     user_id = Column(Integer, ForeignKey('user.id'))
# 
#     def __init__(self, entry_id, user_id):
#         self.entry_id = entry_id
#         self.user_id = user_id
# 
#     def __repr__(self):
#         return '<ReadEntry %r>' % self.username
# 
# Path: pyfeedreader/database.py
# def init_db():
# def drop_all():


# Path: pyfeedreader/views/read.py
from flask import *
from pyfeedreader.models.ReadEntries import ReadEntry
from pyfeedreader.database import db_session
from flask.ext.login import *

__author__ = 'DownGoat'



mod = Blueprint('read', __name__)

@mod.route("/read", methods=["POST"])
@login_required
def read_entry():
    if not request.form.get("entry_id", None):
        return jsonify(success=False)

    entry_id = request.form.get("entry_id", None)

    read_entry = ReadEntry(entry_id=entry_id, user_id=current_user.id)
    db_session.add(read_entry)

    db_session.commit()