Beispiel #1
0
def deliveryadddo():
    message = None
    menus, menus1, menus_id = getmenus(34)
    deliveries = Delivery.query.filter().all()
    delivery_id = request.args.get('mid')
    delivery = Delivery.query.filter_by(id=delivery_id).one()
    if request.method == "POST":  # 如果是以POST的方式才處理
        shipment_number = None
        if 'shipment_number' in request.form:
            shipment_number = request.form['shipment_number']
        (shipment_number)
        delivery.shipment_number = shipment_number
        db.session.commit()
        return render_template('/deliveries/list.html',
                               menu_id=int(menus_id),
                               segment='deliverylist',
                               menus=menus,
                               menus1=menus1,
                               deliveries=deliveries)
    else:
        message = '請輸入物流單號'
    return render_template('/deliveries/adddo.html',
                           menu_id=int(menus_id),
                           segment='',
                           menus=menus,
                           menus1=menus1,
                           delivery=delivery)
Beispiel #2
0
def inventorylist():
    user_id = None
    menus, menus1, menus_id = getmenus(31)
    inventory_id = request.args.get('mid')
    if inventory_id:
        inventories = Inventory.query.filter_by(id=inventory_id).order_by(
            desc(Inventory.id)).all()
    else:
        inventories = Inventory.query.filter().order_by(desc(
            Inventory.id)).all()
    for invertory in inventories:
        order_info = Orders.query.filter_by(
            customer_id=invertory.user_id).limit(1).all()
        if order_info:
            invertory.username = order_info[0].billing_last_name + order_info[
                0].billing_first_name
        else:
            invertory.username = '******'
        # invertory.username = order_info[0].billing_last_name + order_info[0].billing_first_name
    return render_template('/inventories/list.html',
                           menu_id=int(menus_id),
                           segment='inventorylist',
                           menus=menus,
                           menus1=menus1,
                           inventories=inventories)
Beispiel #3
0
def login():
    login_form = LoginForm(request.form)
    #menus = SysMenu.query.filter().all()
    #menus1 = SysMenu.query.filter().all()
    #url = menus1[0].menu.MenuUrl
    if 'login' in request.form:

        # read form data
        username = request.form['username']
        password = request.form['password']

        # Locate user
        user = User.query.filter_by(username=username).first()

        # Check the password
        if user and verify_pass(password, user.password):

            login_user(user)
            return redirect_dest(
                fallback=url_for('base_blueprint.route_default'))
            #return url_for(url_for('base_blueprint.route_default'))

        # Something (user or pass) is not ok
        return render_template('accounts/login.html',
                               msg='Wrong user or password',
                               form=login_form)

    if not current_user.is_authenticated:
        return render_template('accounts/login.html', form=login_form)
    if current_user.is_active:
        menus, menus1, menus_id = getmenus(3)
    else:
        menus, menus1, = getmenus_no_id()
    return redirect(url_for('home_blueprint.index', menus=menus,
                            menus1=menus1))
Beispiel #4
0
def ordercheck():
    menus, menus1, menus_id = getmenus(12)
    orders = Orders.query.filter().all()
    check_info_json = None
    historylists = []
    message = None
    order_id = request.args.get('mid')
    check_info = queryBlockChainOrder(order_id)
    history_infos = historyBlockChainOrder(order_id)
    if len(check_info) == 0:
        message = "data is not exist"
    else:
        check_info_json = json.loads(
            check_info.decode("utf-8").replace("'", '"'))
        check_info_json['isblockchain'] = True
    if len(history_infos) == 0:
        message = "data is not exist"
    else:
        historylists = json.loads(
            history_infos.decode("utf-8").replace("'", '"'))
    return render_template('/orders/check.html',
                           menu_id=int(menus_id),
                           segment='orderlist',
                           menus=menus,
                           menus1=menus1,
                           historylists=historylists,
                           checkinfo=check_info_json,
                           message=message)
Beispiel #5
0
def edit():
    menus, menus1, menus_id = getmenus(10)
    users = User.query.filter().all()
    user_id = request.args.get('mid')
    userinfo = User.query.filter_by(id=user_id).first()
    if request.method == "POST":  # 如果是以POST的方式才處理
        username = None
        email = None
        if 'username' in request.form:
            username = request.form['username']
        if 'email' in request.form:
            email = request.form['email']
        User.query.filter_by(id=user_id).update(
            dict(username=username, email=email))
        db.session.commit()
        newusers = User.query.filter().all()
        return render_template('accounts/list.html',
                               users=newusers,
                               segment='list',
                               menus=menus,
                               menus1=menus1,
                               user=userinfo)
    return render_template('accounts/edit.html',
                           users=users,
                           segment='edit',
                           menus=menus,
                           menus1=menus1,
                           user=userinfo)
Beispiel #6
0
def add():
    menus, menus1, menus_id = getmenus(10)
    users = User.query.filter().all()
    if request.method == "POST":
        username = None
        email = None
        password = None
        if 'username' in request.form:
            username = request.form['username']
        if 'email' in request.form:
            email = request.form['email']
        if 'password' in request.form:
            password = request.form['password']
        user = User(**request.form)
        db.session.add(user)
        db.session.commit()
        newusers = User.query.filter().all()
        return render_template('accounts/list.html',
                               users=newusers,
                               segment='list',
                               menus=menus,
                               menus1=menus1)
    return render_template('accounts/add1.html',
                           users=users,
                           menu_id=int(menus_id),
                           segment='add',
                           menus=menus,
                           menus1=menus1)
Beispiel #7
0
def roleadd():
    message = None
    menus, menus1, menus_id = getmenus(29)
    roles = Role.query.filter().all()
    if request.method == "POST":  # 如果是以POST的方式才處理
        role_name = None
        role_status = 1
        if 'role_name' in request.form:
            role_name = request.form['role_name']
        role_info = Role(role_name, role_status)
        db.session.add(role_info)
        db.session.commit()
        return render_template('/roles/list.html',
                               menu_id=int(menus_id),
                               segment='rolelist',
                               menus=menus,
                               menus1=menus1,
                               roles=roles)
    else:
        message = '請輸入資料(資料不作驗證)'
    return render_template('/roles/add.html',
                           menu_id=int(menus_id),
                           segment='roleadd',
                           menus=menus,
                           menus1=menus1)
Beispiel #8
0
def authorizelist():
    menus, menus1, menus_id = getmenus(26)
    authorizes = RolesMenus.query.filter().all()
    return render_template('/roles/authorizelist.html',
                           menu_id=int(menus_id),
                           segment='authorizelist',
                           menus=menus,
                           menus1=menus1,
                           authorizes=authorizes)
Beispiel #9
0
def rolelist():
    menus, menus1, menus_id = getmenus(24)
    roles = Role.query.filter().all()
    return render_template('/roles/list.html',
                           menu_id=int(menus_id),
                           segment='rolelist',
                           menus=menus,
                           menus1=menus1,
                           roles=roles)
Beispiel #10
0
def list():
    menus, menus1, menus_id = getmenus(8)
    users = User.query.filter().all()
    return render_template('accounts/list.html',
                           users=users,
                           menu_id=int(menus_id),
                           segment='list',
                           menus=menus,
                           menus1=menus1)
Beispiel #11
0
def index():
    #menus = SysMenu.query.filter().all()
    #menus1 = SysMenu.query.filter().all()
    menus, menus1, menus_id = getmenus(12)
    orders = Orders.query.filter().all()
    return render_template('/orders/list.html',
                           menu_id=int(menus_id),
                           segment='orderlist',
                           menus=menus,
                           menus1=menus1,
                           orders=orders)
Beispiel #12
0
def roleuserlist():
    menus, menus1, menus_id = getmenus(26)
    roleusers = RolesUsers.query.join(User,
                                      RolesUsers.user_id == User.id).all()

    return render_template('/roles/roleuserlist.html',
                           menu_id=int(menus_id),
                           segment='roleuserlist',
                           menus=menus,
                           menus1=menus1,
                           roleusers=roleusers)
Beispiel #13
0
def deliverynotify():
    message = None
    menus, menus1, menus_id = getmenus(34)
    delivery_id = request.args.get('mid')
    deliverires = Delivery.query.filter().all()
    token = 'M5g5yVHMV2gc6iRvs1xu5Bsb9OEj0Wux8pQcKknldMo'
    msg = '請登入平台,輸入物流單號 https://storeapi.pyrarc.com/backend/deliverylist?mid=' + str(
        delivery_id)
    lineNotifyMessage(token, msg)
    return redirect(
        url_for('delivery.deliverylist',
                menu_id=int(menus_id),
                segment='deliverylist',
                menus=menus,
                menus1=menus1,
                deliveries=deliverires))
Beispiel #14
0
def deliverylist():
    menus, menus1, menus_id = getmenus(34)
    delivery_id = request.args.get('mid')
    if delivery_id:
        deliveries = Delivery.query.filter_by(id=delivery_id).order_by(
            desc(Delivery.id)).all()
    else:
        deliveries = Delivery.query.filter().order_by(desc(Delivery.id)).all()
    now = datetime.utcnow()
    return render_template('/deliveries/list.html',
                           menu_id=int(menus_id),
                           segment='deliverylist',
                           menus=menus,
                           menus1=menus1,
                           deliveries=deliveries,
                           now=now)
Beispiel #15
0
def inventorynotify():
    message = None
    menus, menus1, menus_id = getmenus(31)
    inventory_id = request.args.get('mid')
    inventory = Inventory.query.filter_by(id=inventory_id).all()
    inventories = Inventory.query.filter().all()
    token = 'M5g5yVHMV2gc6iRvs1xu5Bsb9OEj0Wux8pQcKknldMo'
    msg = '請登入平台,輸入物流單號 https://storeapi.pyrarc.com/backend/inventorylist?mid=' + str(
        inventory_id)
    lineNotifyMessage(token, msg)
    return render_template('/inventories/list.html',
                           menu_id=int(menus_id),
                           segment='inventorylist',
                           menus=menus,
                           menus1=menus1,
                           inventories=inventories)
Beispiel #16
0
def delete():
    message = None
    menus, menus1, menus_id = getmenus(8)
    users = User.query.filter().all()
    user_id = request.args.get('mid')
    if user_id != None:
        try:
            User.query.filter_by(id=user_id).delete()  #取得id欄位的資料
            db.session.commit()
        except:
            message = "讀取錯誤!"
    usersinfo = User.query.filter().all()
    return render_template('accounts/list.html',
                           segment='list',
                           menus=menus,
                           menus1=menus1,
                           users=usersinfo)
Beispiel #17
0
def orderlist():
    current_app.logger.info('orderlist')
    menus, menus1, menus_id = getmenus(12)
    orders = Orders.query.filter().all()
    # 確認區塊鏈是否存在
    # for order in orders:
    #     check_info = queryBlockChainOrder(order.order_id)
    #     if len(check_info) == 0:
    #         order.checkinfo = False
    #     else:
    #         order.checkinfo = True
    return render_template('/orders/list.html',
                           menu_id=int(menus_id),
                           segment='orderlist',
                           menus=menus,
                           menus1=menus1,
                           orders=orders)
Beispiel #18
0
def authorizeadd():
    menus, menus1, menus_id = getmenus(26)
    authorizes = RolesMenus.query.filter().all()
    menuinfos = SysMenu.query.filter().all()
    roles = Role.query.filter().all()
    if request.method == "POST":  # 如果是以POST的方式才處理
        menu_id = None
        role_id = None
        if 'menu' in request.form:
            menu_id = request.form['menu']
        if 'role' in request.form:
            role_id = request.form['role']
        roleuserinfo = RolesMenus.query.filter_by(menu_id=menu_id,
                                                  role_id=role_id).all()
        if not roleuserinfo:
            roleuser = RolesMenus(menu_id, role_id)
            db.session.add(roleuser)
            db.session.commit()
            message = '已添加'
        else:
            message = '已存在對應授權'
        return render_template('/roles/authorizeadd.html',
                               menu_id=int(menus_id),
                               segment='authorizeadd',
                               menus=menus,
                               menus1=menus1,
                               roles=roles,
                               message=message)
    else:
        message = ''
    return render_template('/roles/authorizeadd.html',
                           menu_id=int(menus_id),
                           segment='authorizeadd',
                           menus=menus,
                           menus1=menus1,
                           authorizes=authorizes,
                           menuinfos=menuinfos,
                           roles=roles,
                           message=message)