def register_post(): username = request.forms.get('username') password = request.forms.get('password') passwordr = request.forms.get('passwordr') if password != passwordr: return render('register.html')(register=True, error="password error") status, info = register(username=username, password=password) if not status: return render('register.html')(regisetr=True, error=info) redirect('/')
def sign_in_post(): username = request.forms.get('username') password = request.forms.get('password') user = authenticate(username, password) if user: redirect('/') return render('signin.html')(error="Wrong username or password")
def index_item_list(): desserts = Dessert.get_all() render_info = { 'user' : request.user, 'dessert_list' : desserts, 'dtypes' : DessertType.get_all(), } return render('core/dessert_list.html')(**render_info)
def role_item(role_id): role = Role.get(role_id) perms = Permission.get_all() render_argv = { 'role' : role, 'perms' : perms, } return render('admin/role/item-detail.html')(**render_argv)
def item_admin(module): render_argv = { 'user' : request.user, 'admin_' + module : True, 'module' : module, 'module_l' : modules[module], } return render('admin/item_admin_index.html')(**render_argv)
def user_item(user_id): u = User.get_by_id(user_id) roles = Role.get_all() render_argv = { 'user' : u, 'roles' : roles, 'type_list' : UserType.get_all(), } return render('admin/user/item-detail.html')(**render_argv)
def confirm_reserve(res_id): user = request.user res = Order.get(res_id) if res.send_date: send_date= date2str(res.send_date) else: send_date= None return render('base/reservation_confirm.html')( user=user, res=res, send_date=send_date)
def order_table(): page = int(request.GET.get('page', '0')) start = page * table_count + 1 end = (page + 1) * table_count + 1 item_list= Order.get_mul(range(start, end)) render_argv = { 'orders' : item_list, 'page' : page, } return render('admin/order/order_list.html')(**render_argv)
def user_table(): page = int(request.GET.get('page', '0')) start = page * table_count + 1 end = (page + 1) * table_count + 1 user_list = User.get_mul(range(start, end)) render_argv = { 'user_list' : user_list, 'page' : page, } return render('admin/user/item-table.html')(**render_argv)
def dessert_table(): page = int(request.GET.get('page', '0')) start = page * table_count + 1 end = (page + 1) * table_count + 1 dessert_list = Dessert.get_mul(range(start, end)) render_argv = { 'dessert_list' : dessert_list, 'page' : page, } return render('admin/dessert/item-table.html')(**render_argv)
def item_table(module): page = int(request.GET.get('page', '0')) start = page * table_count + 1 end = (page + 1) * table_count + 1 obj = globals()[modules[module]] item_list= obj.get_mul(range(start, end)) render_argv = { 'item_list' : item_list, 'table_show': obj.show, 'module' : module, 'page' : page, } return render('admin/item_table.html')(**render_argv)
def account_info(): argv = { 'user' : request.user, } if request.GET.get("signin", None): argv['signin'] = True else: argv['signin'] = False if request.GET.get("register", None): argv['register'] = True else: argv['register'] = False return render('base/account_info.html')(**argv)
def user_reserve(): if not request.user: return "" user = request.user res = user.orders res = [ x for x in res if not x.is_confirmed and not x.is_order] if res: res = res[0] else: res = Order(user.id, is_order=False) if user.usertype: res.discount = user.usertype.discount res.add() user.res = res return render('base/reservation.html')(user=user, num=len(res.order_items))
def user_cart(): if not request.user: return "" user = request.user orders = user.orders order = [ x for x in orders if not x.is_complete and x.is_order] if order: order = order[0] else: order = Order(user.id) if user.usertype: order.discount = user.usertype.discount order.add() user.cart = order return render('base/cart.html')(user=user, num=len(order.order_items))
def item_pagination(module): obj = globals()[modules[module]] page = int(request.GET.get('page', '0')) count = obj.count() page_max = count / table_count if page_max != 0 and count % table_count == 0: page_max = page_max - 1 if page <= 5 and page_max > 9: pages = range(0, 10) elif page <= 5 and page_max <= 9: pages = range(0, page_max + 1) elif page >= 5 and page_max < page + 5: pages = range(page_max - 9, page_max + 1) else: pages = range(page - 5, page + 5) render_argv = { 'page' : page, 'pages': pages, 'page_max': page_max, 'module' : module, } return render('admin/table_pagination.html')(**render_argv)
def index(): render_info = { 'user' : request.user, 'index' : True, } return render('index.html')(**render_info)
def type_item(type_id): usertype = UserType.get(type_id) render_argv = { 'type' : usertype, } return render('admin/type/item-detail.html')(**render_argv)
def activate_pie(): render_argv = { 'title' : 'Activate Share Chart', 'datas' : get_activate_share(), } return render('analysis/pie.js')(**render_argv)
def char_nav(): return render('analysis/chart_nav.html')()
def res_day_line(): items=get_order_line_day('reservation') return render('analysis/line.js')(title='Reservation Day Line', items=items["result"], linear=items["linear"])
def overview(): items = get_order_line_day(delta=11) return render('analysis/line.js')(title='Overview', items=items["result"], linear=items["linear"])
def member_center_stuff(): return render('member/orders.html')(user=request.user)
def dessert_item(dessert_id): render_argv = { 'dessert' : Dessert.get(dessert_id), 'type_list' : DessertType.get_all(), } return render('admin/dessert/item-detail.html')(**render_argv)
def check_out(order_id): user = request.user order = Order.get(order_id) return render('base/order_confirm.html')(user=user, order=order)
def register_get(): return render('base/register.html')()
def signin_get(): return render('base/signin.html')()
def decision_item(decision_id): render_argv = { 'decision' : Decision.get(decision_id), } return render('admin/decision/item-detail.html')(**render_argv)
def register_get(): return render('register.html')(register=True)
def member_center(): render_argv = { 'user': request.user, 'member_center': True, } return render('member/index.html')(**render_argv)
def index_item(dessert_id): render_info = { 'user' : request.user, 'dessert' : Dessert.get(dessert_id), } return render('core/dessert_item.html')(**render_info)
def order_day_line(): items = get_order_line_day('order') return render('analysis/line.js')(title='Order Day Line', items=items["result"], linear=items["linear"])
def perm_item(perm_id): perm = Permission.get(perm_id) render_argv = { 'perm' : perm, } return render('admin/perm/item-detail.html')(**render_argv)
def dst_pie(): render_argv = { 'title' : 'Dessert Share Chart', 'datas' : get_dessert_share(), } return render('analysis/pie.js')(**render_argv)
def index_rec_list(): render_info = { 'user' : request.user, 'rec_list' : Dessert.get_all(), } return render('core/dessert_rec_list.html')(**render_info)
def gender_pie(): render_argv = { 'title' : 'Gender Share Chart', 'datas' : get_gender_share(), } return render('analysis/pie.js')(**render_argv)
def sign_in_get(): return render('signin.html')(signin=True)
def address_pie(): render_argv = { 'title' : 'Address Share Chart', 'datas' : get_address_share(), } return render('analysis/pie.js')(**render_argv)
def dtype_item(dtype_id): render_argv = { 'type' : DessertType.get(dtype_id), } return render('admin/dtype/item-detail.html')(**render_argv)