from minibase.database.models import Company, Company_relation, Company_legal_entity from minibase.database.models import Industry from minibase.database.models import Person, Person_role, Person_competence from minibase.database.models import Countries # Gets the id of company from the formated output defined at models.py for the Company Model # The argument formatedCompanySelection is formated by SQLAlchemy in models.py files # Please look there before changing anything here. def getCompanyId(formatedCompanySelection): text = formatedCompanySelection.split(",") return text[2] # Corresponds to the ID of the Company # Gets the id of Person's role def getPersonRoleId(nameForId): selection = Person_role.query.filter_by(name=nameForId).first() return selection.id # Gets the id of Person's competence def getPersonCompetenceId(nameForId): selection = Person_competence.query.filter_by(name=nameForId).first() return selection.id # Gets the country of the company based on it's id def getCompanyCountry(companyId): selection = Company.query.filter_by(id=companyId).first() return selection.country_bill # Gets the state of the company based on it's id def getCompanyState(companyId): selection = Company.query.filter_by(id=companyId).first() return selection.street_bill # Gets the city of the company based on it's id def getCompanyCity(companyId): selection = Company.query.filter_by(id=companyId).first() return selection.city_bill # Gets the Postal Code of the company based on it's id def getCompanyPostCode(companyId): selection = Company.query.filter_by(id=companyId).first() return selection.post_code_bill # Gets the Name of the street of the company based on it's id def getCompanyStreetName(companyId): selection = Company.query.filter_by(id=companyId).first() return selection.street_bill # Gets the Number of the street of the company based on it's id def getCompanyStreetNo(companyId): selection = Company.query.filter_by(id=companyId).first() return selection.street_no_bill # Returns the query of all awailable companie names on the table named Company # Note that the formating is done during the SQLAlchemy Table declaration. def person_role_choices(): choices = Person_role.query.all() return choices # Returns the query of all awailable companie names on the table named Company # Note that the formating is done during the SQLAlchemy Table declaration. def person_competence_choices(): choices = Person_competence.query.all() return choices # Returns the query of all awailable companie names on the table named Company # Note that the formating is done during the SQLAlchemy Table declaration. def company_choices(): choices = Company.query.all() return choices # Retunrs the qurry of all awailable industrie names on the table named Industry # 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 # Retunrs the query of all awailable Country names on the table named Countries # Note that the formating is done during the SQLAlchemy Table declaration. # Important note This table is ImporteD externally from a modifier SQL version of # Github : https://github.com/dr5hn/countries-states-cities-database def country_choices(): choices = Countries.query.all() return choices