示例#1
0
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('/')
示例#2
0
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") 
示例#3
0
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)
示例#4
0
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)
示例#5
0
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) 
示例#6
0
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)
示例#7
0
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)
示例#8
0
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)
示例#9
0
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)
示例#10
0
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)
示例#11
0
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)
示例#12
0
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)
示例#13
0
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))
示例#14
0
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))
示例#15
0
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)
示例#16
0
def char_nav():
    return render('analysis/chart_nav.html')()
示例#17
0
def gender_pie():
    render_argv = {
        'title'     : 'Gender Share Chart',
        'datas'     : get_gender_share(),
    }
    return render('analysis/pie.js')(**render_argv)
示例#18
0
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"])
示例#19
0
def dst_pie():
    render_argv = {
        'title'     : 'Dessert Share Chart',
        'datas'     : get_dessert_share(),
    }
    return render('analysis/pie.js')(**render_argv)
示例#20
0
def overview():
    items = get_order_line_day(delta=11)
    return render('analysis/line.js')(title='Overview', 
                                      items=items["result"], 
                                      linear=items["linear"])
示例#21
0
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"])
示例#22
0
def register_get():
    return render('register.html')(register=True)
示例#23
0
def check_out(order_id):
    user = request.user
    order = Order.get(order_id)
    return render('base/order_confirm.html')(user=user, order=order)
示例#24
0
def register_get():
    return render('base/register.html')()
示例#25
0
def activate_pie():
    render_argv = {
        'title'     : 'Activate Share Chart',
        'datas'     : get_activate_share(),
    }
    return render('analysis/pie.js')(**render_argv)
示例#26
0
def sign_in_get():
    return render('signin.html')(signin=True)
示例#27
0
def index_rec_list():
    render_info = {
        'user'    :   request.user,
        'rec_list' : Dessert.get_all(),
    }
    return render('core/dessert_rec_list.html')(**render_info) 
示例#28
0
def index_item(dessert_id):
    render_info = {
        'user'    :   request.user,
        'dessert' :   Dessert.get(dessert_id),
    }
    return render('core/dessert_item.html')(**render_info)
示例#29
0
def address_pie():
    render_argv = {
        'title'     : 'Address Share Chart',
        'datas'     : get_address_share(),
    }
    return render('analysis/pie.js')(**render_argv)
示例#30
0
def index():
    render_info = {
        'user'          :   request.user,
        'index'         :   True,
    }
    return render('index.html')(**render_info)