def delete(self, nid):
     m = NoticeModel.find_one_by(id=nid)
     if m:
         NoticeModel.delete(m.id)
         return dict(code=200, msg='success', data=None)
     else:
         return dict(code=404, msg='not found', data=None)
 def post(self):
     form = NoticeForm(meta=dict(csrf=False))
     if form.validate():
         m = NoticeModel.new(**form.form)
         return dict(code=200, msg='success', data=m.asdict())
     else:
         return dict(code=400, msg='failure', data=form.errors)
    def put(self, nid):
        notice = NoticeModel.find_one_by(id=nid)
        if notice:
            form = NoticeForm(meta=dict(csrf=False))

            m = notice.update(user_id=current_user.id, **form.form)
            return dict(code=200, msg='success', data=m.asdict())
        else:
            return dict(code=404, msg='not found', data=None)
 def get(self, notice_id):
     return jsonify(NoticeModel.get_notice(notice_id))
 def get(self):
     return jsonify(NoticeModel.get_notice_list())
 def get(self, nid):
     model = NoticeModel.find_by_id(nid)
     if not model:
         return dict(code=404, msg='not found', data=None)
     else:
         return dict(code=200, msg='success', data=model.asdict())
 def get(self):
     # tips 没有分页操作,默认公告不多的情况下
     model = NoticeModel.find_all()
     return dict(code=200, msg='success', data=[_.asdict() for _ in model])