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.

49 lines
1.9 KiB

import os
from minibase.database.models import Company, Company_relation, Company_legal_entity
from minibase.database.models import Industry
# Retunrs the qurry of all awailable industrie names on the table named Company_industr
# Note that the formating is done during the SQLAlchemy Table declaration.
def company_industry_choices():
choices = Industry.query.all()
return choices
# Retunrs the query of all awailable legal entity names on the table named Company_legal_entity
# Note that the formating is done during the SQLAlchemy Table declaration.
def company_legal_entity_choices():
choices = Company_legal_entity.query.all()
return choices
# Retunrs the query of all awailable Relation names on the table named Company_relation
# Note that the formating is done during the SQLAlchemy Table declaration.
def company_relation_choices():
choices = Company_relation.query.all()
return choices
# The Company Model has Industry Column as a foreign key and it requires the Industry's ID
# And not the name. so this function returns the right ID of the name shown at the
# Register Company Form
def getIndustryId(nameForId):
selection = Industry.query.filter_by(name=nameForId).first() # Gets the id of Role
return selection.id
# The Company Model has Relation Column as a foreign key and it requires the Industry's ID
# And not the name. so this function returns the right ID of the name shown at the
# Register Company Form
def getRelationId(nameForId):
selection = Company_relation.query.filter_by(name=nameForId).first() # Gets the id of Role
return selection.id
# The Company Model has Legal Entity Column as a foreign key and it requires the Industry's ID
# And not the name. so this function returns the right ID of the name shown at the
# Register Company Form
def getLegalEntityId(nameForId):
selection = Company_legal_entity.query.filter_by(name=nameForId).first() # Gets the id of Role
return selection.id