def POST(self, food_id): i = web.input(name='', description='', foodpic={}) food_id = int(food_id) food = model.Foods() if 'foodpic' in i: filepath = i.foodpic.filename.replace( '\\', '/') # 将Windows风格的斜杠转换为Linux风格 filename = filepath.split('/')[-1] # 文件名(带后缀) ext = filename.split('.')[-1] # 扩展名 # 扩展名不为空时才更新头像 if ext: # 网站主页的相对路径 rel_filename = settings.IMG_DIR + '/' + str(food_id) + ext # 服务器上的绝对路径 abs_filename = curdir + '/' + rel_filename # 1.更新头像路径和简介 if food.update(food_id, picture=rel_filename): # 2.更新数据库成功后,保存头像 fout = open(abs_filename, 'w') fout.write(i.foodpic.file.read()) fout.close() food.update(food_id, name=i.name) food.update(food_id, description=i.description) raise web.seeother("/view/%d" % food_id)
def GET(self): i = web.input(page='1') page = int(i.page) page_foods, page_count = model.Foods().show(111, page) bulletin = model.BulletinBoard().show(111) return titled_render('清真食堂').QZcanteen(bulletin, page_foods, page_count, page)
def GET(self, food_id): food_id = int(food_id) food = model.Foods().view(food_id) if food: comment = model.Comment().list(food_id) return titled_render().view(food, comment) else: raise web.seeother('/')
def GET(self, food_id): food_id = int(food_id) model.Comment().ddel(food_id) model.Foods().ddel(food_id) manager_id = model.Manager().current_id() if manager_id: raise web.seeother('/manager/%d' % manager_id) else: raise web.notfound()
def GET(self, manager_id): manager_id = int(manager_id) status = model.Manager().status(manager_id) if status['managername']: if manager_id == model.Manager().current_id(): page_bulletins = model.BulletinBoard().show(manager_id) page_foods = model.Foods().show_all(manager_id) return titled_render(status['managername']).manager_canteen( status['managername'], status['email'], page_bulletins, page_foods) else: raise web.notfound()
def POST(self): i = web.input(name='', description='', foodpic={}) if 'foodpic' in i: filepath = i.foodpic.filename.replace( '\\', '/') # 将Windows风格的斜杠转换为Linux风格 filename = filepath.split('/')[-1] # 文件名(带后缀) ext = filename.split('.')[-1] # 扩展名 # 扩展名不为空时才更新头像 if ext: # 网站主页的相对路径 rel_filename = settings.IMG_DIR + '/' + str(i.name) + ext # 服务器上的绝对路径 abs_filename = curdir + '/' + rel_filename food_id = model.Foods().new(i.name, i.description, model.Manager().current_id(), rel_filename) fout = open(abs_filename, 'w') fout.write(i.foodpic.file.read()) fout.close() raise web.seeother("/view/%d" % food_id)
def POST(self): i = web.input(name='') foodname = i.name.decode('utf-8') food_id = model.Foods().find(foodname) raise web.seeother("/view/%d" % food_id)
def GET(self): page_bulletins = model.BulletinBoard().show_all() page_messages = model.MessageBoard().show_all() page_foods = model.Foods().list() return titled_render('admin').admin(page_bulletins, page_foods, page_messages)
def GET(self, food_id): food_id = int(food_id) food = model.Foods().view(food_id) return titled_render().edit(food)