add contracts
This commit is contained in:
100
api/methods.py
100
api/methods.py
@ -1584,3 +1584,103 @@ SELECT
|
||||
}
|
||||
)
|
||||
|
||||
def get_contracts(user, token_info):
|
||||
return dbGetMany(user, token_info, {
|
||||
"statement": """
|
||||
SELECT
|
||||
id
|
||||
,supplier
|
||||
,content
|
||||
,identifier
|
||||
,notes
|
||||
FROM contract_t
|
||||
ORDER BY
|
||||
supplier
|
||||
,content
|
||||
""",
|
||||
"params": ()
|
||||
}
|
||||
)
|
||||
|
||||
def insert_contract(user, token_info, **args):
|
||||
try:
|
||||
body = args["body"]
|
||||
v_supplier = body["supplier"]
|
||||
v_content = body["content"]
|
||||
v_identifier = body["identifier"]
|
||||
v_notes = body["notes"]
|
||||
return dbInsert(user, token_info, {
|
||||
"statement": """
|
||||
INSERT INTO contract_t
|
||||
(
|
||||
supplier
|
||||
,content
|
||||
,identifier
|
||||
,notes
|
||||
) VALUES (
|
||||
%s
|
||||
,%s
|
||||
,%s
|
||||
,%s
|
||||
)
|
||||
RETURNING *
|
||||
""",
|
||||
"params": [
|
||||
v_supplier
|
||||
,v_content
|
||||
,v_identifier
|
||||
,v_notes
|
||||
]
|
||||
})
|
||||
except KeyError as e:
|
||||
logger.warning("insert_contract: parameter missing: {}".format(e))
|
||||
raise werkzeug.exceptions.UnprocessableEntity("parameter missing: {}".format(e))
|
||||
|
||||
|
||||
def get_contract(user, token_info, contractId=None):
|
||||
return dbGetOne(user, token_info, {
|
||||
"statement": """
|
||||
SELECT
|
||||
id
|
||||
,supplier
|
||||
,content
|
||||
,identifier
|
||||
,notes
|
||||
FROM contract_t
|
||||
WHERE id = %s
|
||||
""",
|
||||
"params": (contractId, )
|
||||
}
|
||||
)
|
||||
|
||||
def update_contract(user, token_info, contractId=None, **args):
|
||||
try:
|
||||
body = args["body"]
|
||||
v_supplier = body["supplier"]
|
||||
v_content = body["content"]
|
||||
v_identifier = body["identifier"]
|
||||
v_notes = body["notes"]
|
||||
return dbUpdate(user, token_info, {
|
||||
"statement": """
|
||||
UPDATE contract_t
|
||||
SET
|
||||
supplier = %s
|
||||
,content = %s
|
||||
,identifier = %s
|
||||
,notes = %s
|
||||
WHERE id = %s
|
||||
RETURNING *
|
||||
""",
|
||||
"params": [
|
||||
v_supplier,
|
||||
v_content,
|
||||
v_identifier,
|
||||
v_notes,
|
||||
contractId
|
||||
]
|
||||
})
|
||||
except KeyError as e:
|
||||
logger.warning("update_contract: parameter missing: {}".format(e))
|
||||
raise werkzeug.exceptions.UnprocessableEntity("parameter missing: {}".format(e))
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user