# Path: mod/models/lecturedb.py
# class LectureDB(Base):
#     __tablename__ = 'db_lecture'
#     lid = Column(Integer, primary_key=True)
#     date = Column(Integer, index=True)
#     speaker = Column(String(128))
#     time = Column(String(128))
#     location = Column(String(256))
#     topic = Column(String(256))
#     detail = Column(String(256))


from config import *
from ..models.lecturedb import LectureDB
from sqlalchemy.orm.exc import NoResultFound
from time import time, strftime, mktime, localtime, strptime
import tornado.web
import tornado.gen
import json, base64
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date    : 2015-03-17 12:06:02
# @Author  : yml_bright@163.com


class LectureNoticeHandler(tornado.web.RequestHandler):

    @property
    def db(self):
        return self.application.db

    def get(self):
        self.write('Herald Web Service')

    def post(self):
        retjson = {'code':500, 'content':u'暂无'}
        date = mktime(strptime(strftime('%Y-%m-%d' ,localtime(time())), '%Y-%m-%d'))

        # read from db
        try:

# Path: mod/models/lecturedb.py
# class LectureDB(Base):
#     __tablename__ = 'db_lecture'
#     lid = Column(Integer, primary_key=True)
#     date = Column(Integer, index=True)
#     speaker = Column(String(128))
#     time = Column(String(128))
#     location = Column(String(256))
#     topic = Column(String(256))
#     detail = Column(String(256))


# Path: mod/lecture/noticehandler.py
from config import *
from ..models.lecturedb import LectureDB
from sqlalchemy.orm.exc import NoResultFound
from time import time, strftime, mktime, localtime, strptime
import tornado.web
import tornado.gen
import json, base64

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date    : 2015-03-17 12:06:02
# @Author  : yml_bright@163.com


class LectureNoticeHandler(tornado.web.RequestHandler):

    @property
    def db(self):
        return self.application.db

    def get(self):
        self.write('Herald Web Service')

    def post(self):
        retjson = {'code':500, 'content':u'暂无'}
        date = mktime(strptime(strftime('%Y-%m-%d' ,localtime(time())), '%Y-%m-%d'))

        # read from db
        try:

            status = self.db.query(LectureDB).filter( LectureDB.date >=  date ).all()