# 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 datetime import datetime
from werkzeug import generate_password_hash,check_password_hash
from _helpers import db
from flask.ext.login import UserMixin
            
            #user.score += 1
            topic.post_count += 1
            
            db.session.add(topic)
            db.session.commit()
            return self

    def delete(self):
        if self.topic.first_post_id == self.id:
            self.topic.delete()
            return False
        if self.topic.last_post_id == self.id:
            self.topic.last_post_id = self.topic.second_last_post_id
            db.session.commit()

            # Here's self.user and self.topic
            # is the backref which define in
            # User class and Topic class
            
            #self.user.score -= 1
            self.topic.post_count -= 1
            
            db.session.delete(self)
            db.session.commit()
            return True

class Notice(db.Model):
    __tablename__ = 'notice'
    id = db.Column(db.Integer,primary_key = True)

# 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: lolipop/models.py
from datetime import datetime
from werkzeug import generate_password_hash,check_password_hash
from _helpers import db
from flask.ext.login import UserMixin

            
            #user.score += 1
            topic.post_count += 1
            
            db.session.add(topic)
            db.session.commit()
            return self

    def delete(self):
        if self.topic.first_post_id == self.id:
            self.topic.delete()
            return False
        if self.topic.last_post_id == self.id:
            self.topic.last_post_id = self.topic.second_last_post_id
            db.session.commit()

            # Here's self.user and self.topic
            # is the backref which define in
            # User class and Topic class
            
            #self.user.score -= 1
            self.topic.post_count -= 1
            
            db.session.delete(self)
            db.session.commit()
            return True

class Notice(db.Model):
    __tablename__ = 'notice'
    id = db.Column(db.Integer,primary_key = True)

    title = db.Column(db.String)