def GET(self):
     if model.current_id():
         table = alltable['user']
         user = model.get_item(table, model.current_id())
         return render.index(user,
                             datetime.datetime.now().strftime('%Y-%m'))
     else:
         return render.login()
 def GET(self, cid):
     c = model.get_classes('where cid=' + cid)[0]
     begin = c['begindate'].day + 1 / 2 * c['begintime']
     end = c['enddate'].day + 1 / 2 * c['endtime']
     year = c['begindate'].year
     month = c['begindate'].month
     place = c['place']
     classroom = c['classroom']
     wh = 'where (DAYOFMONTH(begindate)+1/2*begintime between '+str(begin)+' and '+str(end)\
     +' or DAYOFMONTH(enddate)+1/2*endtime between '+str(begin)+' and '+str(end)\
     +' or (DAYOFMONTH(begindate)+1/2*begintime<'+str(begin)+' and DAYOFMONTH(enddate)+1/2*endtime>'+str(end)+'))'\
     +' and MONTH(begindate)='+str(month)+' and YEAR(begindate)='+str(year)\
     +' and classroom.place=\''+place+'\''+' and classroom.classroom=\''+classroom+'\''\
     +' and approve!=\''+'不通过'.decode('utf-8')+'\''+' order by begindate'
     classes = list(model.get_classes(wh))
     date = classes[0]['begindate'].strftime('%Y-%m')
     uid = int(model.current_id())
     user_type = model.get_item(alltable['user'], uid)['usertype']
     return render.conflict_class(classes, date, cid, user_type)
 def POST(self, cid):
     form = web.input()
     form['mid'] = int(model.current_id())
     model.update_class_approve(form['cid'], form['mid'], form['approve'])
     raise web.seeother('/approve_class/' +
                        datetime.datetime.now().strftime('%Y-%m'))
 def POST(self):
     table = alltable['project']
     form = web.input()
     form['oid'] = int(model.current_id())
     model.new_item(table, form)
     raise web.seeother('/index_project')
 def GET(self):
     if model.current_id():  # 用户已登录
         # 取消cookie
         web.setcookie('uid', '', -1)
     raise web.seeother('/')