items_API.getItemLink updated to new schema
This commit is contained in:
parent
780c43cd73
commit
3c30adcd49
Binary file not shown.
Binary file not shown.
@ -148,6 +148,23 @@ def getPrefixes(site:str, payload:tuple, convert:bool=True):
|
|||||||
except (Exception, psycopg2.DatabaseError) as error:
|
except (Exception, psycopg2.DatabaseError) as error:
|
||||||
raise postsqldb.DatabaseError(error, payload, sql)
|
raise postsqldb.DatabaseError(error, payload, sql)
|
||||||
|
|
||||||
|
def getItemLink(site: str, payload:tuple, convert:bool=True):
|
||||||
|
database_config = config.config()
|
||||||
|
item_link = ()
|
||||||
|
sql = f"SELECT * FROM {site}_itemlinks WHERE id=%s;"
|
||||||
|
try:
|
||||||
|
with psycopg2.connect(**database_config) as conn:
|
||||||
|
with conn.cursor() as cur:
|
||||||
|
cur.execute(sql, payload)
|
||||||
|
rows = cur.fetchone()
|
||||||
|
if rows and convert:
|
||||||
|
item_link = postsqldb.tupleDictionaryFactory(cur.description, rows)
|
||||||
|
elif rows and not convert:
|
||||||
|
item_link = rows
|
||||||
|
return item_link
|
||||||
|
except Exception as error:
|
||||||
|
raise postsqldb.DatabaseError(error, payload, sql)
|
||||||
|
|
||||||
def paginateZonesBySku(site: str, payload: tuple, convert=True):
|
def paginateZonesBySku(site: str, payload: tuple, convert=True):
|
||||||
database_config = config.config()
|
database_config = config.config()
|
||||||
zones, count = (), 0
|
zones, count = (), 0
|
||||||
|
|||||||
@ -463,15 +463,27 @@ def getPossibleLocations():
|
|||||||
@items_api.route('/item/getLinkedItem', methods=["GET"])
|
@items_api.route('/item/getLinkedItem', methods=["GET"])
|
||||||
@login_required
|
@login_required
|
||||||
def getLinkedItem():
|
def getLinkedItem():
|
||||||
|
""" GET itemlink from system by passing an ID
|
||||||
|
---
|
||||||
|
parameters:
|
||||||
|
- in: query
|
||||||
|
name: id
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
default: 1
|
||||||
|
required: true
|
||||||
|
description: item link to get from the system
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: Item Link GET successful.
|
||||||
|
"""
|
||||||
linked_item = {}
|
linked_item = {}
|
||||||
if request.method == "GET":
|
if request.method == "GET":
|
||||||
id = int(request.args.get('id', 1))
|
id = int(request.args.get('id', 1))
|
||||||
database_config = config()
|
|
||||||
site_name = session['selected_site']
|
site_name = session['selected_site']
|
||||||
with psycopg2.connect(**database_config) as conn:
|
linked_item = database_items.getItemLink(site_name, (id, ))
|
||||||
linked_item = database.__selectTuple(conn, site_name, f"{site_name}_itemlinks", (id, ), convert=True)
|
|
||||||
return jsonify({'linked_item': linked_item, 'error': False, 'message': 'Linked Item added!!'})
|
return jsonify({'linked_item': linked_item, 'error': False, 'message': 'Linked Item added!!'})
|
||||||
return jsonify({'linked_item': linked_item, 'error': True, 'message': 'These was an error with adding to the linked list!'})
|
return jsonify({'linked_item': linked_item, 'error': True, 'message': f'method {request.method} not allowed'})
|
||||||
|
|
||||||
@items_api.route('/item/addLinkedItem', methods=["POST"])
|
@items_api.route('/item/addLinkedItem', methods=["POST"])
|
||||||
def addLinkedItem():
|
def addLinkedItem():
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user