You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
1.9 KiB
76 lines
1.9 KiB
from minibase.blueprints.company.models import Companies, Company_legal_entities, Company_types, Company_status, Company_relations
|
|
import minibase.blueprints.database.utils as dbUtils
|
|
|
|
|
|
def queryByNameFirst(cname):
|
|
return Companies.query.filter_by(name=cname).first()
|
|
|
|
|
|
def queryById(cid):
|
|
return Companies.query.filter_by(id=cid).first()
|
|
|
|
|
|
def queryNameById(cid):
|
|
selected = Companies.query.filter_by(id=cid).first()
|
|
return selected.name
|
|
|
|
|
|
def queryNamesWithDefault(defId):
|
|
choices = dbUtils.queryNameWithDefaultId(Companies, defId)
|
|
return choices
|
|
|
|
|
|
def queryStreetById(cid):
|
|
selected = Companies.query.filter_by(id=cid).first()
|
|
return selected.street
|
|
|
|
|
|
def queryStreetNoById(cid):
|
|
selected = Companies.query.filter_by(id=cid).first()
|
|
return selected.street_no
|
|
|
|
|
|
def queryImageById(cid):
|
|
selected = Companies.query.filter_by(id=cid).first()
|
|
return selected.image_file
|
|
|
|
|
|
def queryLegalEntityNames():
|
|
choices = Company_legal_entities.query.order_by(Company_legal_entities.name.asc())
|
|
return choices
|
|
|
|
|
|
def queryLegalEntityNamesWithDefault(defId):
|
|
choices = dbUtils.queryNameWithDefaultId(Company_legal_entities, defId)
|
|
return choices
|
|
|
|
|
|
def queryTypeNames():
|
|
choices = Company_types.query.order_by(Company_types.name.asc())
|
|
return choices
|
|
|
|
|
|
def queryTypeNamesWithDefault(defId):
|
|
choices = dbUtils.queryNameWithDefaultId(Company_types, defId)
|
|
return choices
|
|
|
|
|
|
def queryRelationNames():
|
|
choices = Company_relations.query.order_by(Company_relations.name.asc())
|
|
return choices
|
|
|
|
|
|
def queryRelationNamesWithDefault(defId):
|
|
choices = dbUtils.queryNameWithDefaultId(Company_relations, defId)
|
|
return choices
|
|
|
|
|
|
def queryStatusNames():
|
|
choices = Company_status.query.order_by(Company_status.name.asc())
|
|
return choices
|
|
|
|
|
|
def queryStatusNamesWithDefault(defId):
|
|
choices = dbUtils.queryNameWithDefaultId(Company_status, defId)
|
|
return choices
|