20 lines
677 B
Python
20 lines
677 B
Python
"""spec_current — текущее состояние спецификации."""
|
|
from connection import query
|
|
|
|
|
|
def list_by_contract(contract_id):
|
|
"""Return list of dicts with name_hash, name, price, qty, sum, date_start."""
|
|
return query(
|
|
"""SELECT name_hash, name, price, qty, sum, date_start
|
|
FROM spec_current WHERE contract_id = %s ORDER BY name""",
|
|
(contract_id,),
|
|
)
|
|
|
|
|
|
def get_elements_json(document_id):
|
|
"""Get elements_json for a document."""
|
|
rows = query(
|
|
"SELECT elements_json FROM documents WHERE id = %s", (document_id,)
|
|
)
|
|
return rows[0]["elements_json"] if rows and rows[0]["elements_json"] else None
|