Exemplo n.º 1
0
def show(id_num):
    try:
        store = Store.get_by_id(id_num)
        return render_template('show.html', store=store)
    except:
        flash("No such store! Trash!")
        return redirect("/stores")
Exemplo n.º 2
0
def warehouse_create():
    store = Store.get_by_id(request.form['store_id'])
    w = Warehouse(location=request.form['warehouse_location'], store=store)
    w.save()
    if w.save():
        flash("Warehouse created")
    return redirect(url_for('warehouse_new'))
Exemplo n.º 3
0
def store_delete(id):
    store = Store.get_by_id(id)
    query = Warehouse.delete().where(Warehouse.store_id == id)
    query.execute()
    store.delete_instance()

    return redirect('/')
Exemplo n.º 4
0
def warehouse_create():
    location = request.form.get('location')
    store = Store.get_by_id(request.form['store_id'])
    warehouse = Warehouse(location=location, store=store)
    if warehouse.save():
        flash("Warehouse created!", "success")
        return redirect(url_for('warehouse_new'))
Exemplo n.º 5
0
def delete_shop(): 
    store_to_delete_id = request.form.get('store_to_delete')
    store_delete = Store.get_by_id(store_to_delete_id)
    Warehouse.delete().where(Warehouse.store_id == store_to_delete_id).execute()
    store_delete.delete_instance()
    

    return redirect(url_for("shop_index"))
Exemplo n.º 6
0
def store_update(store_id):
    store = Store.get_by_id(store_id)
    store.name = request.form.get('store_name')
    if store.save():
        flash("Updated!", "success")
    else:
        flash("Unable to update store.", "danger")
    return redirect(url_for("store_show", store_id=store.id))
Exemplo n.º 7
0
def store_update(store_id):
    store = Store.get_by_id(store_id)
    store.name = request.form.get("store_name")
    if store.save():
        flash("Store name successfully updated.", "success")
    else:
        flash("The name entered is same as the previous", "danger")
    return redirect(url_for('store_show', store_id=store.id))
Exemplo n.º 8
0
def view_shop(store_id_view):
    stores_id = Store.get_by_id(store_id_view)
    # if request.method == "GET":
    no_warehouse = [0]
    for i in stores_id.warehouses:
        no_warehouse.append(i)
        
    no_warehouse = len(no_warehouse) - 1
    return render_template('shop_view.html', stores_id = stores_id, no_warehouse = no_warehouse)
Exemplo n.º 9
0
def update(id):
    store = Store.update(name=request.form['store_name']).where(Store.id == id)
    store_id = Store.get_by_id(id)
    if store.execute():
        flash('Succesfully updated store name!', 'success')
        return redirect(url_for('edit', store=store, id=store_id))
    else:
        flash('Failed to update store name :/', 'danger')
        return redirect(url_for('update'))
Exemplo n.º 10
0
def store_update(storeid):
    s_new = Store.get_by_id(storeid)
    s_new.name = request.form.get('edit_store_name')

    if s_new.save():
        flash(f"Successfully saved {s_new.name}")
        return redirect(url_for('id_store', sid=storeid))
    else:
        return render_template('id_store')
Exemplo n.º 11
0
    def get(self, _id):
        store = Store.get_by_id(int(_id))       
        store.key.delete()

        html = '''
        <script>
        window.close();
        </script>
        '''
        self.response.out.write(html)
def update(id):
    store = Store.get_by_id(id)
    new_name = request.form.get('newname')
    store.name = new_name
    if not store.save():
        flash('Unable to update store!')
        return render_template('storespage.html', store=store)

    flash(f'Successfully updated store name to {new_name}')
    return redirect(url_for('edit_store', id=store.id))
Exemplo n.º 13
0
def store_delete(id):
    s_del = Store.get_by_id(id)
    query = Warehouse.delete().where(Warehouse.store_id == id)
    query.execute()

    if s_del.delete_instance():
        flash(f"Successfully deleted {s_del.name}")
        return redirect(url_for('stores'))
    else:
        return render_template('stores')
Exemplo n.º 14
0
def w_create():
    store_id = Store.get_by_id(request.form.get('s_id'))
    warehouse_name = request.form.get('warehouse_name')
    w = Warehouse(location=warehouse_name, store=store_id)

    if w.save():
        flash(f"Successfully saved {warehouse_name}")
        return redirect(url_for('warehouse'))
    else:
        return render_template('warehouse', location=warehouse_name)
Exemplo n.º 15
0
def destroy_store(store_id):
    store_list = Store.select()

    if request.method == "POST":
        store = Store.get_by_id(store_id)
        flash(f"Closed {store.name}.")
        store.delete_instance()
        return redirect(url_for('index_stores'))
    else:
        return render_template('stores.html', store_list=store_list)
Exemplo n.º 16
0
def destroy(id):
    # breakpoint()
    x = Store.get_by_id(id)

    #can use delete or delete instance

    if x.delete_instance():
        flash("Store deleted")
        return redirect(url_for('show_stores'))
    else:
        return render_template('stores.html')
Exemplo n.º 17
0
def delete(id_num):
    store = Store.get_by_id(id_num)
    delete_warehouses = Warehouse.delete().where(
        Warehouse.store_id == store.id)
    try:
        delete_warehouses.execute()
        store.delete_instance()
        flash("Store has been deleted! :(")
        return redirect("/stores")
    except:
        flash("Attempt unsuccessful! >:(")
        return redirect("/stores")
Exemplo n.º 18
0
def create_warehouse():
    if request.method == "POST":
        store = Store.get_by_id(request.form['store_id'])
        w = Warehouse(location=request.form['warehouse_location'], store=store)
        if w.save():
            flash(
                f"{store.name} added a new warehouse at {request.form['warehouse_location']}."
            )
            return redirect(url_for('new_warehouse'))
    else:
        return render_template('warehouse.html',
                               location=request.form['warehouse_location'])
Exemplo n.º 19
0
def create_warehouse():
    w_location = request.form.get('w_location')
    s_id = Store.get_by_id(request.form.get('s_id'))
    w = Warehouse(location=w_location, store=s_id)

    if w.save():
        flash("successfully saved")
        return redirect(url_for('warehouse'))
    else:
        return render_template('warehouse.html',
                               name=request.form['name'],
                               errors=s.errors)
Exemplo n.º 20
0
def update_store(store_id):
    store = Store.get_by_id(store_id)

    if request.method == "POST":
        store.name = request.form.get('store_name')
        if store.save():
            flash(f"Updated store name to {store.name}.")
            return redirect(url_for('edit_store', store_id=store.id))
        else:
            return render_template('store.html',
                                   store=store,
                                   errors=store.errors)
Exemplo n.º 21
0
def edit_store(store_id):
    store = Store.get_by_id(store_id)

    if request.method == 'POST':
        tag_name = request.form['tag_name']
        query = json.loads(request.form['query'])

        store.tag_name = tag_name
        store.query = query
        store.update_mongo(store_id)

        return redirect(url_for('.index'))

    return render_template('stores/edit_store.html', store=store)
Exemplo n.º 22
0
def store_delete(id):
    del_st = Store.get_by_id(id)
    wh_checking = Warehouse.get_or_none(Warehouse.store_id == del_st)

    if wh_checking:
        wh_checking.delete().where(
            Warehouse.store_id == wh_checking.store_id).execute()

    if del_st.delete_instance():
        flash('Successfully deleted!', 'success')
    else:
        flash('Something went wrong, check your internet and try again',
              'danger')

    return redirect(url_for('stores_list'))
Exemplo n.º 23
0
    def get(self, _id):
        _id = int(_id)
        action = self.request.get('action')
        

        url = self.request.get('url')
        s = Store.get_by_id(int(_id))
        imgs = s.imgs


        f = True
        tmp = []
        if action == 'delete':

            for img in imgs:
                if f and img.image == url:
                    f = False
                else:
                    tmp.append(img)

            s.imgs = tmp
            s.put()


        tag = self.request.get('tag')
        if action == 'set':
            for img in imgs:
                if img.image == url:
                    img.tag = tag
                tmp.append(img)

            s.imgs = tmp
            s.put()
        html = '''
        <script>
        window.close();
        </script>
        '''
        self.response.out.write(html)
Exemplo n.º 24
0
def show_stores_about(id):
    store = Store.get_by_id(id)
    #can have the
    return render_template('stores_about.html', store=store)
Exemplo n.º 25
0
def edit_store(store_id):
    store = Store.get_by_id(store_id)
    return render_template('store.html', store=store)
Exemplo n.º 26
0
def warehouse_add():
   print(request.form["store_id"]) 
   store = Store.get_by_id(request.form["store_id"])
   Warehouse.create(location=request.form.get("warehouse_location"),store=store)
   return redirect("/warehouse")
Exemplo n.º 27
0
def store_delete(id):
    store = Store.get_by_id(id)
    store.delete_instance()
    return redirect(url_for('store'))
Exemplo n.º 28
0
def store_show(id):
    store = Store.get_by_id(id)
    return render_template('store_show.html', store=store)
Exemplo n.º 29
0
def warehouse_create():
    # print(request.form['store_id'])
    store = Store.get_by_id(request.form['store_id'])
    w = Warehouse(location=request.form['warehouse_location'], store=store)
    w.save()
    return redirect(url_for('warehouse_new'))
Exemplo n.º 30
0
def store_info(id):
    store = Store.get_by_id(id)
    return render_template('store_info.html', store=store)
Exemplo n.º 31
0
def store_delete(id):
    store = Store.get_by_id(id)
    store.delete_instance(recursive=True)
    # store_del = Store.delete().where(Store.id == id)
    # store_del.execute()
    return redirect(url_for('store_select'))
Exemplo n.º 32
0
def edit_shop(store_id_view):
    stores_id = Store.get_by_id(store_id_view)
    new_store_name = request.form.get('store_name_update')
    stores_id.name = new_store_name 
    if stores_id.save():
        return redirect(url_for("view_shop", store_id_view = store_id_view))