# Path: lolipop/models.py
# class Node(db.Model):
#     __tablename__ = "nodes"
#     id = db.Column(db.Integer,primary_key = True)
#     title = db.Column(db.String(120),unique=True)
#     description = db.Column(db.String)
#     topics = db.relationship("Topic",backref="node",lazy="joined")
#     
#     @property
#     def post_count(self):
#         return Post.query.filter(Topic.node_id == self.id).filter(Post.topic_id == Topic.node_id).count()
# 
#     @property
#     def topic_count(self):
#         return Topic.query.filter(Topic.node_id == self.id).count()
# 
#     def save(self):
#         db.session.add(self)
#         db.session.commit()
#         return self
# 
#     def delete(self):
#         db.session.delete(self)
#         db.session.commit()
#         return self
# 
# Path: _helpers.py
# ONLINE_LAST_MINUTES = 5
# def force_int(value,default=1):
#     def block_code(self,text,lang):
# def fill_with_user(items):
# def fill_with_node(items):
# def fill_object(items,objects,*args,**kwargs):
# def _add_attr(item,objects_dict,arg,kwargs):
# def mark_online(user_id):
# def get_online_users():
# class BleepRenderer(HtmlRenderer,SmartyPants):
# class MaxinObject(object):


from flask import Blueprint,redirect,url_for,abort
from flask.ext.login import current_user
from lolipop.models import Node
from _helpers import redis,cache

bp = Blueprint("focus",__name__)

def nodes_id():
    if current_user is not None and current_user.is_authenticated():
        user_key = 'user-nodes/%d' % current_user.id
        return redis.smembers(user_key)

def getNodes():
    nodes = None
    uids = nodes_id()
    if uids:
        nodes = Node.query.filter(Node.id.in_(uids))
    return nodes

@bp.route('/add/<int:node_id>')
def add(node_id):
    if current_user is not None and current_user.is_authenticated():
        user_key = 'user-nodes/%d' % current_user.id

# Path: lolipop/models.py
# class Node(db.Model):
#     __tablename__ = "nodes"
#     id = db.Column(db.Integer,primary_key = True)
#     title = db.Column(db.String(120),unique=True)
#     description = db.Column(db.String)
#     topics = db.relationship("Topic",backref="node",lazy="joined")
#     
#     @property
#     def post_count(self):
#         return Post.query.filter(Topic.node_id == self.id).filter(Post.topic_id == Topic.node_id).count()
# 
#     @property
#     def topic_count(self):
#         return Topic.query.filter(Topic.node_id == self.id).count()
# 
#     def save(self):
#         db.session.add(self)
#         db.session.commit()
#         return self
# 
#     def delete(self):
#         db.session.delete(self)
#         db.session.commit()
#         return self
# 
# Path: _helpers.py
# ONLINE_LAST_MINUTES = 5
# def force_int(value,default=1):
#     def block_code(self,text,lang):
# def fill_with_user(items):
# def fill_with_node(items):
# def fill_object(items,objects,*args,**kwargs):
# def _add_attr(item,objects_dict,arg,kwargs):
# def mark_online(user_id):
# def get_online_users():
# class BleepRenderer(HtmlRenderer,SmartyPants):
# class MaxinObject(object):


# Path: views/focus.py
from flask import Blueprint,redirect,url_for,abort
from flask.ext.login import current_user
from lolipop.models import Node
from _helpers import redis,cache


bp = Blueprint("focus",__name__)

def nodes_id():
    if current_user is not None and current_user.is_authenticated():
        user_key = 'user-nodes/%d' % current_user.id
        return redis.smembers(user_key)

def getNodes():
    nodes = None
    uids = nodes_id()
    if uids:
        nodes = Node.query.filter(Node.id.in_(uids))
    return nodes

@bp.route('/add/<int:node_id>')
def add(node_id):
    if current_user is not None and current_user.is_authenticated():
        user_key = 'user-nodes/%d' % current_user.id

        p = redis.pipeline()