# Path: lolipop/models.py
# class Notice(db.Model):
#     __tablename__ = 'notice'
#     id = db.Column(db.Integer,primary_key = True)
#     title = db.Column(db.String)
#     content = db.Column(db.Text)
#     date_create = db.Column(db.DateTime,default = datetime.utcnow)
#     viewed = db.Column(db.Integer,default=0)
# 
#     def __str__(self):
#         return self.title
# 
#     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: lolipop/form.py
# class NoticeForm(Form):
#     subject = TextField(u'标题',validators=[DataRequired(message=u'标题')],description=u'这里填写标题哦')
#     content = TextAreaField(u'内容',validators=[DataRequired(u'内容')],description=u'这里填写内容的说')
# 
#     def save(self):
#         notice = Notice(title = self.subject.data,content = self.content.data)
#         return notice.save()
# 
# Path: views/account.py
# def admin_required(func):
#     @wraps(func)
#     def decorated_view(*args,**kwargs):
#         try:
#             if not current_user.id == 1:
#                 abort(403)
#             return func(*args,**kwargs)
#         except AttributeError:
#             abort(403)
#     return decorated_view
# 
# 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,render_template,redirect,url_for,flash
from lolipop.models import Notice
from lolipop.form import NoticeForm
from views.account import admin_required
from _helpers import cache
# coding: utf-8

bp = Blueprint('notice',__name__)

@bp.route('/create',methods=('GET','POST'))
@admin_required
def create():
    form = NoticeForm()
    if form.validate_on_submit():
        form.save()
    else:
        flash(('Missing content'),'error')
    return redirect(url_for('admin.dashboard'))

@bp.route('/delete/<int:uid>')

# Path: lolipop/models.py
# class Notice(db.Model):
#     __tablename__ = 'notice'
#     id = db.Column(db.Integer,primary_key = True)
#     title = db.Column(db.String)
#     content = db.Column(db.Text)
#     date_create = db.Column(db.DateTime,default = datetime.utcnow)
#     viewed = db.Column(db.Integer,default=0)
# 
#     def __str__(self):
#         return self.title
# 
#     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: lolipop/form.py
# class NoticeForm(Form):
#     subject = TextField(u'标题',validators=[DataRequired(message=u'标题')],description=u'这里填写标题哦')
#     content = TextAreaField(u'内容',validators=[DataRequired(u'内容')],description=u'这里填写内容的说')
# 
#     def save(self):
#         notice = Notice(title = self.subject.data,content = self.content.data)
#         return notice.save()
# 
# Path: views/account.py
# def admin_required(func):
#     @wraps(func)
#     def decorated_view(*args,**kwargs):
#         try:
#             if not current_user.id == 1:
#                 abort(403)
#             return func(*args,**kwargs)
#         except AttributeError:
#             abort(403)
#     return decorated_view
# 
# 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/notice.py
from flask import Blueprint,render_template,redirect,url_for,flash
from lolipop.models import Notice
from lolipop.form import NoticeForm
from views.account import admin_required
from _helpers import cache

# coding: utf-8

bp = Blueprint('notice',__name__)

@bp.route('/create',methods=('GET','POST'))
@admin_required
def create():
    form = NoticeForm()
    if form.validate_on_submit():
        form.save()
    else:
        flash(('Missing content'),'error')
    return redirect(url_for('admin.dashboard'))

@bp.route('/delete/<int:uid>')

@admin_required