diff --git a/webinterface/$ b/webinterface/$ new file mode 100644 index 00000000..834e0dc8 --- /dev/null +++ b/webinterface/$ @@ -0,0 +1,269 @@ +from minibase.database.models import Company, Company_relation, Company_legal_entity +from minibase.database.models import Industry, Countries +from minibase.database.models import Person, Person_role, Person_competence +from minibase.database.models import Project, Project_element +from minibase import db +from numpy import genfromtxt + + +# 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 + +################################################################################################### +# CSV manipulation +################################################################################################### + +def openCsv(filename): + data = genfromtxt(filename, + delimiter=',', + skip_header=1, + dtype=None, + encoding='UTF-8') + return data.tolist() + + +def db_add_name_and_description(csv, table): + try: + csv_list = openCsv(csv) + for i in csv_list: + record = table(**{ + 'name': i[0], + 'description': i[1]}) + db.session.add(record) # Add all the records + db.session.commit() # Attempt to commit all the records + except: + db.session.rollback() # Rollback the changes on error + print("Error Ocured during <> upload to DB") + + +def db_add_company(csv): + try: + csv_list = openCsv(csv) + for i in csv_list: + record = Company(**{ + 'name': i[0], + 'legal_entity_id': i[1], + 'relation_id': i[2], + 'industry_id': i[3], + 'status_id': i[4], + 'website': i[5], + 'street_bill': i[6], + 'street_no_bill': i[7], + 'city_bill': i[8], + 'post_code_bill': i[9], + 'state_bill': i[10], + 'country_bill': i[11], + 'street_ship': i[12], + 'street_no_ship': i[13], + 'city_ship': i[14], + 'post_code_ship': i[15], + 'state_ship': i[16], + 'country_ship': i[17]}) + db.session.add(record) # Add all the records + db.session.commit() # Attempt to commit all the records + except Exception as error: + db.session.rollback() # Rollback the changes on error + print("Error Ocured during <> upload to DB") + print(error) + + +def db_add_person(csv): + try: + csv_list = openCsv(csv) + print(csv_list) + for i in csv_list: + record = Person(**{ + 'name': i[0], + 'last_name': i[1], + 'company_id': i[2], + 'role_id': i[3], + 'competence_id': i[4], + 'mail_prof': i[5], + 'mail_priv': i[6], + 'tel_prof_mobile': i[7], + 'street_name': i[8], + 'street_no': i[9], + 'city': i[10], + 'post_code': i[11], + 'state': i[12], + 'country': i[13] + }) + db.session.add(record) # Add all the records + db.session.commit() # Attempt to commit all the records + except Exception as error: + db.session.rollback() # Rollback the changes on error + print("Error Ocured during <> upload to DB") + print(error) + + +def db_add_project(csv): + try: + csv_list = openCsv(csv) + print(csv_list) + for i in csv_list: + record = Project(**{ + 'name': i[0], + 'description': i[1], + 'company_id': i[2], + 'status_id': i[3], + 'industry_id': i[4], + 'owner_id': i[5], + 'qte_prototype': i[6], + 'qte_start': i[7], + 'qte_production': i[8], + }) + db.session.add(record) # Add all the records + db.session.commit() # Attempt to commit all the records + except Exception as error: + db.session.rollback() # Rollback the changes on error + print(csv) + print("Error Ocured during <> upload to DB") + print(error) + +def db_add_project_element(csv): + try: + csv_list = openCsv(csv) + print(csv_list) + for i in csv_list: + record = Project_element(**{ + 'name': i[0], + 'description': i[1], + 'qte_per_project': i[2], + 'project_id': i[3], + 'owner_id': i[4], + 'status_id': i[5], + }) + db.session.add(record) # Add all the records + db.session.commit() # Attempt to commit all the records + except Exception as error: + db.session.rollback() # Rollback the changes on error + print(csv) + print("Error Ocured during <> upload to DB") + print(error) diff --git a/webinterface/minibase/admin/__pycache__/forms.cpython-311.pyc b/webinterface/minibase/admin/__pycache__/forms.cpython-311.pyc index 423654a0..fb85d01f 100644 Binary files a/webinterface/minibase/admin/__pycache__/forms.cpython-311.pyc and b/webinterface/minibase/admin/__pycache__/forms.cpython-311.pyc differ diff --git a/webinterface/minibase/admin/__pycache__/routes.cpython-311.pyc b/webinterface/minibase/admin/__pycache__/routes.cpython-311.pyc index 13f51ee3..8214fbc8 100644 Binary files a/webinterface/minibase/admin/__pycache__/routes.cpython-311.pyc and b/webinterface/minibase/admin/__pycache__/routes.cpython-311.pyc differ diff --git a/webinterface/minibase/admin/__pycache__/utils.cpython-311.pyc b/webinterface/minibase/admin/__pycache__/utils.cpython-311.pyc index e54c2662..8d9728b6 100644 Binary files a/webinterface/minibase/admin/__pycache__/utils.cpython-311.pyc and b/webinterface/minibase/admin/__pycache__/utils.cpython-311.pyc differ diff --git a/webinterface/minibase/admin/forms.py b/webinterface/minibase/admin/forms.py index 912edc7b..7fdd3e58 100644 --- a/webinterface/minibase/admin/forms.py +++ b/webinterface/minibase/admin/forms.py @@ -1,12 +1,15 @@ from flask_wtf import FlaskForm from wtforms import StringField, SubmitField from wtforms.validators import DataRequired, ValidationError -from minibase.database.models import Person_role -from minibase.database.models import Company_legal_entity, Company_relation -from minibase.database.models import Industry +from minibase.database.models import Person_role, Person_competence +from minibase.database.models import Company_legal_entity, Company_relation, Company_status +from minibase.database.models import Industry, Note_status +from minibase.database.models import Project_status +from minibase.database.models import Product_status, Product_physical, Product_packaging, Product_eligibility, Product_classification, Product_domain, Product_category, Product_sub_category +import minibase.admin.utils as adminUtils -class compIndustryForm(FlaskForm): # Defines the form class to be used for the user registretion +class industryRegisterForm(FlaskForm): # Defines the form class to be used for the user registretion # Decalarion of the fields for the form and it's propereties name = StringField('Name', validators=[DataRequired()]) description = StringField('Description', validators=[DataRequired()]) @@ -14,8 +17,7 @@ class compIndustryForm(FlaskForm): # Defines the form class to be used for the # Queries to be made in order to validate the form : If Relation Type exitst # Case Insensistive def validate_name(self, name): - industry_query = Industry.query.filter(Industry.name.ilike(name.data)).first() # Database Querry ilike means case insessitive - if industry_query: + if adminUtils.doesNameExistsCi(Product_status, name.data): raise ValidationError('That Industry Type is already registered') @@ -23,38 +25,46 @@ class compRelationForm(FlaskForm): # Defines the form class to be used for the # Decalarion of the fields for the form and it's propereties name = StringField('Name', validators=[DataRequired()]) description = StringField('Description', validators=[DataRequired()]) - submit = SubmitField('Register Relation') + submit = SubmitField('Register Company Relation') # Queries to be made in order to validate the form : If Relation Type exitst # Case Insensistive def validate_name(self, name): - relation_query = Company_relation.query.filter(Company_relation.name.ilike(name.data)).first() # Database Querry ilike means case insessitive - if relation_query: - raise ValidationError('That Relation Type is already registered') + if adminUtils.doesNameExistsCi(Company_relation, name.data): + raise ValidationError('That Company Relation Type is already registered') class compLegalEntityForm(FlaskForm): # Defines the form class to be used for the user registretion # Decalarion of the fields for the form and it's propereties name = StringField('Name', validators=[DataRequired()]) description = StringField('Description', validators=[DataRequired()]) - submit = SubmitField('Register Legal Entity') + submit = SubmitField('Register Company Legal Entity') # Queries to be made in order to validate the form : If Legal Entity exitst # Case Insensistive def validate_name(self, name): - legal_entity_query = Company_legal_entity.query.filter(Company_legal_entity.name.ilike(name.data)).first() # Database Querry ilike means case insessitive - if legal_entity_query: - raise ValidationError('That Legal Entity is already registered') + if adminUtils.doesNameExistsCi(Company_legal_entity, name.data): + raise ValidationError('That Company Legal Entity is already registered') + +class compStatusForm(FlaskForm): # Defines the form class to be used for the user registretion + # Decalarion of the fields for the form and it's propereties + name = StringField('Name', validators=[DataRequired()]) + description = StringField('Description', validators=[DataRequired()]) + submit = SubmitField('Register Company Status') + + # Queries to be made in order to validate the form : If Person Role exitst # Case Insensistive + def validate_name(self, name): + if adminUtils.doesNameExistsCi(Company_status, name.data): + raise ValidationError('That Company Status is already registered') class personRoleForm(FlaskForm): # Defines the form class to be used for the user registretion # Decalarion of the fields for the form and it's propereties name = StringField('Name', validators=[DataRequired()]) description = StringField('Description', validators=[DataRequired()]) - submit = SubmitField('Register Role') + submit = SubmitField('Register Person Role') # Queries to be made in order to validate the form : If Person Role exitst # Case Insensistive def validate_name(self, name): - person_role_query = Person_role.query.filter(Person_role.name.ilike(name.data)).first() # Database Querry ilike means case insessitive - if person_role_query: + if adminUtils.doesNameExistsCi(Person_role, name.data): raise ValidationError('That Person Role is already registered') @@ -62,23 +72,105 @@ class personCompetenceForm(FlaskForm): # Defines the form class to be used for # Decalarion of the fields for the form and it's propereties name = StringField('Name', validators=[DataRequired()]) description = StringField('Description', validators=[DataRequired()]) - submit = SubmitField('Register Role') + submit = SubmitField('Register Person Competence') # Queries to be made in order to validate the form : If Person Role exitst # Case Insensistive def validate_name(self, name): - person_competence_query = Person_role.query.filter(Person_role.name.ilike(name.data)).first() # Database Querry ilike means case insessitive - if person_competence_query: + if adminUtils.doesNameExistsCi(Person_competence, name.data): raise ValidationError('That Person Conpetence is already registered') -class statusRegisterForm(FlaskForm): # Defines the form class to be used for the user registretion +class noteStatusForm(FlaskForm): # Defines the form class to be used for the user registretion + # Decalarion of the fields for the form and it's propereties + name = StringField('Name', validators=[DataRequired()]) + description = StringField('Description', validators=[DataRequired()]) + submit = SubmitField('Register Note Status') + + # Queries to be made in order to validate the form : If Person Role exitst # Case Insensistive + def validate_name(self, name): + if adminUtils.doesNameExistsCi(Note_status, name.data): + raise ValidationError('That Note Status is already registered') + + +class projectStatusForm(FlaskForm): # Defines the form class to be used for the user registretion + # Decalarion of the fields for the form and it's propereties + name = StringField('Name', validators=[DataRequired()]) + description = StringField('Description', validators=[DataRequired()]) + submit = SubmitField('Register Project Status') + + # Queries to be made in order to validate the form : If Person Role exitst # Case Insensistive + def validate_name(self, name): + if adminUtils.doesNameExistsCi(Project_status, name.data): + raise ValidationError('That Project Status is already registered') + + +class productStatusForm(FlaskForm): + # Decalarion of the fields for the form and it's propereties + name = StringField('Name', validators=[DataRequired()]) + description = StringField('Description', validators=[DataRequired()]) + submit = SubmitField('Register Product Status') + + # Queries to be made in order to validate the form : If Person Role exitst # Case Insensistive + def validate_name(self, name): + if adminUtils.doesNameExistsCi(Product_status, name.data): + raise ValidationError('That Product Status is already registered') + + +class productEligibilityForm(FlaskForm): + # Decalarion of the fields for the form and it's propereties + name = StringField('Name', validators=[DataRequired()]) + description = StringField('Description', validators=[DataRequired()]) + submit = SubmitField('Register Product Eligibility') + + # Queries to be made in order to validate the form : If Person Role exitst # Case Insensistive + def validate_name(self, name): + if adminUtils.doesNameExistsCi(Product_eligibility, name.data): + raise ValidationError('That Product Eligibility is already registered') + + +class productDomainForm(FlaskForm): + # Decalarion of the fields for the form and it's propereties + name = StringField('Name', validators=[DataRequired()]) + description = StringField('Description', validators=[DataRequired()]) + submit = SubmitField('Register Product Domain') + + # Queries to be made in order to validate the form : If Person Role exitst # Case Insensistive + def validate_name(self, name): + if adminUtils.doesNameExistsCi(Product_domain, name.data): + raise ValidationError('That Product domain is already registered') + + +class productClassificationForm(FlaskForm): + # Decalarion of the fields for the form and it's propereties + name = StringField('Name', validators=[DataRequired()]) + description = StringField('Description', validators=[DataRequired()]) + submit = SubmitField('Register Prodcut Classification') + + # Queries to be made in order to validate the form : If Person Role exitst # Case Insensistive + def validate_name(self, name): + if adminUtils.doesNameExistsCi(Product_classification, name.data): + raise ValidationError('That Product Classification is already registered') + + +class productCategoryForm(FlaskForm): + # Decalarion of the fields for the form and it's propereties + name = StringField('Name', validators=[DataRequired()]) + description = StringField('Description', validators=[DataRequired()]) + submit = SubmitField('Register Product Category') + + # Queries to be made in order to validate the form : If Person Role exitst # Case Insensistive + def validate_name(self, name): + if adminUtils.doesNameExistsCi(Product_category, name.data): + raise ValidationError('That Product Category is already registered') + + +class productSubCategoryForm(FlaskForm): # Decalarion of the fields for the form and it's propereties name = StringField('Name', validators=[DataRequired()]) description = StringField('Description', validators=[DataRequired()]) - submit = SubmitField('Register Status') + submit = SubmitField('Register Product Sub Category') # Queries to be made in order to validate the form : If Person Role exitst # Case Insensistive def validate_name(self, name): - person_competence_query = Status.query.filter(Status.name.ilike(name.data)).first() # Database Querry ilike means case insessitive - if person_competence_query: - raise ValidationError('That Status is already registered') + if adminUtils.doesNameExistsCi(Product_sub_category, name.data): + raise ValidationError('That Product Sub Category is already registered') diff --git a/webinterface/minibase/admin/routes.py b/webinterface/minibase/admin/routes.py index e2dc41fc..dd879c6d 100644 --- a/webinterface/minibase/admin/routes.py +++ b/webinterface/minibase/admin/routes.py @@ -1,165 +1,414 @@ from flask import render_template, url_for, flash, redirect, request, Blueprint from minibase import db from minibase.config import themeMinibase -from minibase.database.models import Company, Company_legal_entity, Company_relation -from minibase.database.models import Industry +from minibase.database.models import Company, Company_legal_entity, Company_relation,Company_status +from minibase.database.models import Industry, Note_status from minibase.database.models import Person_role, Person_competence -from minibase.admin.forms import compLegalEntityForm, compRelationForm, compIndustryForm,personRoleForm, personCompetenceForm, statusRegisterForm - +from minibase.database.models import Product_status, Product_physical, Product_packaging, Product_eligibility, Product_classification, Product_domain, Product_category, Product_sub_category +from minibase.admin.forms import compLegalEntityForm, compRelationForm, compStatusForm +from minibase.admin.forms import personRoleForm, personCompetenceForm +from minibase.admin.forms import industryRegisterForm, noteStatusForm +from minibase.admin.forms import projectStatusForm +from minibase.admin.forms import productStatusForm, productEligibilityForm, productDomainForm, productClassificationForm, productCategoryForm, productSubCategoryForm # Declaring a blueprint admin = Blueprint('admin', __name__) @admin.route("/company_register_legal_entity", methods=['GET', 'POST']) def company_register_legal_entity(): + toPrint = "Company Legal Entity" form = compLegalEntityForm() - legal_entities = Company_legal_entity.query.order_by(Company_legal_entity.name.asc()) + query = Company_legal_entity.query.order_by(Company_legal_entity.name.asc()) if form.validate_on_submit(): - companyLegal = Company_legal_entity( + dbRow = Company_legal_entity( name=form.name.data, description=form.description.data) # Here we need to give the id of thr role as this is a foreign key - db.session.add(companyLegal) + db.session.add(dbRow) db.session.commit() - flash(f'{"Company Legal Entity registered!"}', 'success') - return render_template('admin/company_register_legal_entity.html', - title='Register Company Legal Entity', - legal_entities=legal_entities, + flash(f' {toPrint} {" registered!"}', 'success') + return render_template('admin/register_name_and_desc.html', + title='Register ' + toPrint, + tableTitle='Existing ' + toPrint, + dbTable=query, theme=themeMinibase, form=form) - return render_template('admin/company_register_legal_entity.html', - title='Register Company Legal Entity', - legal_entities=legal_entities, + return render_template('admin/register_name_and_desc.html', + title='Register ' + toPrint, + tableTitle='Existing ' + toPrint, + dbTable=query, theme=themeMinibase, form=form) @admin.route("/company_register_relation", methods=['GET', 'POST']) def company_register_relation(): + toPrint = "Company Relation" form = compRelationForm() - relations = Company_relation.query.order_by(Company_relation.name.asc()) + query = Company_relation.query.order_by(Company_relation.name.asc()) if form.validate_on_submit(): - companyRelation = Company_relation( + dbRow = Company_relation( name=form.name.data, description=form.description.data) # Here we need to give the id of thr role as this is a foreign key - db.session.add(companyRelation) + db.session.add(dbRow) db.session.commit() - flash(f'{"Company Relation registered!"}', 'success') - return render_template('admin/company_register_relation.html', - title='Register Company Relation', - relations=relations, + flash(f' {toPrint} {" registered!"}', 'success') + return render_template('admin/register_name_and_desc.html', + title='Register ' + toPrint, + tableTitle='Existing ' + toPrint, + dbTable=query, theme=themeMinibase, form=form) - return render_template('admin/company_register_relation.html', - title='Register Company Relation', + return render_template('admin/register_name_and_desc.html', + title='Register ' + toPrint, + tableTitle='Existing ' + toPrint, + dbTable=query, theme=themeMinibase, - relations=relations, form=form) -@admin.route("/company_register_industry", methods=['GET', 'POST']) -def company_register_industry(): - form = compIndustryForm() - industries = Industry.query.order_by(Industry.name.asc()) +@admin.route("/company_register_status", methods=['GET', 'POST']) +def company_register_status(): + toPrint = "Company Status" + form = compStatusForm() + query = Company_status.query.order_by(Company_status.name.asc()) if form.validate_on_submit(): - companyIndustry = Industry( + dbRow = Company_status( name=form.name.data, description=form.description.data) # Here we need to give the id of thr role as this is a foreign key - db.session.add(companyIndustry) + db.session.add(dbRow) db.session.commit() - flash(f'{"Company Idustry registered!"}', 'success') - return render_template('admin/company_register_industry.html', - title='Register Company Industry', - industries=industries, + flash(f' {toPrint} {" registered!"}', 'success') + return render_template('admin/register_name_and_desc.html', + title='Register ' + toPrint, + tableTitle='Existing ' + toPrint, + dbTable=query, theme=themeMinibase, form=form) - return render_template('admin/company_register_industry.html', - title='Register Company Industry', - industries=industries, + return render_template('admin/register_name_and_desc.html', + title='Register ' + toPrint, + tableTitle='Existing ' + toPrint, + dbTable=query, + theme=themeMinibase, + form=form) + + + +@admin.route("/register_industry", methods=['GET', 'POST']) +def register_industry(): + toPrint = "Company Industry" + form = industryRegisterForm() + query = Industry.query.order_by(Industry.name.asc()) + if form.validate_on_submit(): + dbRow = Industry( + name=form.name.data, + description=form.description.data) + # Here we need to give the id of thr role as this is a foreign key + db.session.add(dbRow) + db.session.commit() + + flash(f' {toPrint} {" registered!"}', 'success') + return render_template('admin/register_name_and_desc.html', + title='Register ' + toPrint, + tableTitle='Existing ' + toPrint, + dbTable=query, + theme=themeMinibase, + form=form) + + return render_template('admin/register_name_and_desc.html', + title='Register ' + toPrint, + tableTitle='Existing ' + toPrint, + dbTable=query, theme=themeMinibase, form=form) @admin.route("/person_register_role", methods=['GET', 'POST']) def person_register_role(): + toPrint = "Person Role" form = personRoleForm() - roles = Person_role.query.order_by(Person_role.name.asc()) + query = Person_role.query.order_by(Person_role.name.asc()) if form.validate_on_submit(): - personRole = Person_role( + dbRow = Person_role( name=form.name.data, description=form.description.data) # Here we need to give the id of thr role as this is a foreign key - db.session.add(personRole) + db.session.add(dbRow) db.session.commit() - flash(f'{"Person Role registered!"}', 'success') - return render_template('admin/person_register_role.html', - title='Register Person_role', + flash(f' {toPrint} {" registered!"}', 'success') + return render_template('admin/register_name_and_desc.html', + title='Register ' + toPrint, + tableTitle='Existing ' + toPrint, + dbTable=query, theme=themeMinibase, - roles=roles, form=form) - return render_template('admin/person_register_role.html', - title='Register Person Role', + return render_template('admin/register_name_and_desc.html', + title='Register ' + toPrint, + tableTitle='Existing ' + toPrint, + dbTable=query, theme=themeMinibase, - roles=roles, form=form) @admin.route("/person_register_competence", methods=['GET', 'POST']) def person_register_competence(): + toPrint = "Person Competence" form = personCompetenceForm() - competences = Person_competence.query.order_by(Person_competence.name.asc()) + query = Person_competence.query.order_by(Person_competence.name.asc()) if form.validate_on_submit(): - personCompetence = Person_competence( + dbRow = Person_competence( name=form.name.data, description=form.description.data) # Here we need to give the id of thr role as this is a foreign key - db.session.add(personCompetence) + db.session.add(dbRow) db.session.commit() - flash(f'{"Person Competence registered!"}', 'success') - return render_template('admin/person_register_competence.html', - title='Register Person Competence', - competences=competences, + flash(f' {toPrint} {" registered!"}', 'success') + return render_template('admin/register_name_and_desc.html', + title='Register ' + toPrint, + tableTitle='Existing ' + toPrint, + dbTable=query, theme=themeMinibase, form=form) - return render_template('admin/person_register_competence.html', - title='Register Person Competence', + return render_template('admin/register_name_and_desc.html', + title='Register ' + toPrint, + tableTitle='Existing ' + toPrint, + dbTable=query, theme=themeMinibase, - competences=competences, form=form) -@admin.route("/status_register", methods=['GET', 'POST']) -def status_register(): - form = statusRegisterForm() - statuses = Status.query.order_by(Status.name.asc()) + +@admin.route("/note_register_status", methods=['GET', 'POST']) +def note_register_status(): + toPrint = "Note Status" + form = noteStatusForm() + query = Note_status.query.order_by(Note_status.name.asc()) if form.validate_on_submit(): - statusRegister = Status( + dbRow = Company_status( name=form.name.data, description=form.description.data) # Here we need to give the id of thr role as this is a foreign key - db.session.add(statusRegister) + db.session.add(dbRow) + db.session.commit() + + flash(f' {toPrint} {" registered!"}', 'success') + return render_template('admin/register_name_and_desc.html', + title='Register ' + toPrint, + tableTitle='Existing ' + toPrint, + dbTable=query, + theme=themeMinibase, + form=form) + + return render_template('admin/register_name_and_desc.html', + title='Register ' + toPrint, + tableTitle='Existing ' + toPrint, + dbTable=query, + theme=themeMinibase, + form=form) + + +@admin.route("/project_register_status", methods=['GET', 'POST']) +def project_register_status(): + toPrint = "Project Status" + form = projectStatusForm() + query = Project_status.query.order_by(Project_status.name.asc()) + if form.validate_on_submit(): + dbRow = Project_status( + name=form.name.data, + description=form.description.data) + db.session.add(dbRow) + db.session.commit() + + flash(f' {toPrint} {" registered!"}', 'success') + return render_template('admin/register_name_and_desc.html', + title='Register ' + toPrint, + tableTitle='Existing ' + toPrint, + dbTable=query, + theme=themeMinibase, + form=form) + + return render_template('admin/register_name_and_desc.html', + title='Register ' + toPrint, + tableTitle='Existing ' + toPrint, + dbTable=query, + theme=themeMinibase, + form=form) + + +@admin.route("/product_register_status", methods=['GET', 'POST']) +def product_register_status(): + toPrint = "Product Status" + form = productStatusForm() + query = Product_status.query.order_by(Product_status.name.asc()) + if form.validate_on_submit(): + dbRow = Product_status( + name=form.name.data, + description=form.description.data) + db.session.add(dbRow) + db.session.commit() + + flash(f' {toPrint} {" registered!"}', 'success') + return render_template('admin/register_name_and_desc.html', + title='Register ' + toPrint, + tableTitle='Existing ' + toPrint, + dbTable=query, + theme=themeMinibase, + form=form) + + return render_template('admin/register_name_and_desc.html', + title='Register ' + toPrint, + tableTitle='Existing ' + toPrint, + dbTable=query, + theme=themeMinibase, + form=form) + + +@admin.route("/product_register_eligibility", methods=['GET', 'POST']) +def product_register_eligibility(): + toPrint = "Product Eligibility" + form = productEligibilityForm() + query = Product_eligibility.query.order_by(Product_eligibility.name.asc()) + if form.validate_on_submit(): + dbRow = Product_eligibility( + name=form.name.data, + description=form.description.data) + db.session.add(dbRow) + db.session.commit() + + flash(f' {toPrint} {" registered!"}', 'success') + return render_template('admin/register_name_and_desc.html', + title='Register ' + toPrint, + tableTitle='Existing ' + toPrint, + dbTable=query, + theme=themeMinibase, + form=form) + + return render_template('admin/register_name_and_desc.html', + title='Register ' + toPrint, + tableTitle='Existing ' + toPrint, + dbTable=query, + theme=themeMinibase, + form=form) + + +@admin.route("/product_register_domain", methods=['GET', 'POST']) +def product_register_domain(): + toPrint = "Product Domain" + form = productEligibilityForm() + query = Product_domain.query.order_by(Product_domain.name.asc()) + if form.validate_on_submit(): + dbRow = Product_domain( + name=form.name.data, + description=form.description.data) + db.session.add(dbRow) + db.session.commit() + + flash(f' {toPrint} {" registered!"}', 'success') + return render_template('admin/register_name_and_desc.html', + title='Register ' + toPrint, + tableTitle='Existing ' + toPrint, + dbTable=query, + theme=themeMinibase, + form=form) + + return render_template('admin/register_name_and_desc.html', + title='Register ' + toPrint, + tableTitle='Existing ' + toPrint, + dbTable=query, + theme=themeMinibase, + form=form) + + +@admin.route("/product_register_classification", methods=['GET', 'POST']) +def product_register_classification(): + toPrint = "Product Classification" + form = productEligibilityForm() + query = Product_classification.query.order_by(Product_classification.name.asc()) + if form.validate_on_submit(): + dbRow = Product_classification( + name=form.name.data, + description=form.description.data) + db.session.add(dbRow) + db.session.commit() + + flash(f' {toPrint} {" registered!"}', 'success') + return render_template('admin/register_name_and_desc.html', + title='Register ' + toPrint, + tableTitle='Existing ' + toPrint, + dbTable=query, + theme=themeMinibase, + form=form) + + return render_template('admin/register_name_and_desc.html', + title='Register ' + toPrint, + tableTitle='Existing ' + toPrint, + dbTable=query, + theme=themeMinibase, + form=form) + + +@admin.route("/product_register_category", methods=['GET', 'POST']) +def product_register_category(): + toPrint = "Product Category" + form = productEligibilityForm() + query = Product_category.query.order_by(Product_category.name.asc()) + if form.validate_on_submit(): + dbRow = Product_category( + name=form.name.data, + description=form.description.data) + db.session.add(dbRow) + db.session.commit() + + flash(f' {toPrint} {" registered!"}', 'success') + return render_template('admin/register_name_and_desc.html', + title='Register ' + toPrint, + tableTitle='Existing ' + toPrint, + dbTable=query, + theme=themeMinibase, + form=form) + + return render_template('admin/register_name_and_desc.html', + title='Register ' + toPrint, + tableTitle='Existing ' + toPrint, + dbTable=query, + theme=themeMinibase, + form=form) + + +@admin.route("/product_register_sub_category", methods=['GET', 'POST']) +def product_register_sub_category(): + toPrint = "Product Sub Category" + form = productEligibilityForm() + query = Product_sub_category.query.order_by(Product_sub_category.name.asc()) + if form.validate_on_submit(): + dbRow = Product_sub_category( + name=form.name.data, + description=form.description.data) + db.session.add(dbRow) db.session.commit() - flash(f'{"New Status registered!"}', 'success') - return render_template('admin/status_register.html', - title='Register Status', - statuses=statuses, + flash(f' {toPrint} {" registered!"}', 'success') + return render_template('admin/register_name_and_desc.html', + title='Register ' + toPrint, + tableTitle='Existing ' + toPrint, + dbTable=query, theme=themeMinibase, form=form) - return render_template('admin/status_register.html', - title='Register Status', - statuses=statuses, + return render_template('admin/register_name_and_desc.html', + title='Register ' + toPrint, + tableTitle='Existing ' + toPrint, + dbTable=query, theme=themeMinibase, form=form) diff --git a/webinterface/minibase/admin/utils.py b/webinterface/minibase/admin/utils.py index 8b137891..8dec0b43 100644 --- a/webinterface/minibase/admin/utils.py +++ b/webinterface/minibase/admin/utils.py @@ -1 +1,6 @@ +def doesNameExistsCi(table, name): + exists = table.query.filter(table.name.ilike(name.data)).first() # Database Querry ilike means case insessitive + if exists: + return 1 + return 0 diff --git a/webinterface/minibase/database/__pycache__/models.cpython-311.pyc b/webinterface/minibase/database/__pycache__/models.cpython-311.pyc index 929751e5..c3e87c67 100644 Binary files a/webinterface/minibase/database/__pycache__/models.cpython-311.pyc and b/webinterface/minibase/database/__pycache__/models.cpython-311.pyc differ diff --git a/webinterface/minibase/database/__pycache__/utils.cpython-311.pyc b/webinterface/minibase/database/__pycache__/utils.cpython-311.pyc index 8db3dfb0..b46f2571 100644 Binary files a/webinterface/minibase/database/__pycache__/utils.cpython-311.pyc and b/webinterface/minibase/database/__pycache__/utils.cpython-311.pyc differ diff --git a/webinterface/minibase/database/company.csv b/webinterface/minibase/database/company.csv new file mode 100644 index 00000000..1f4b34f1 --- /dev/null +++ b/webinterface/minibase/database/company.csv @@ -0,0 +1,5 @@ +name,legal_entity_id,relation_id,industry_id,status_id,website,street_bill,street_no_bill,city_bill,post_code_bill,state_bill,country_bill,street_ship,street_no_ship,city_ship,post_code_ship,state_ship,country_ship +Steinel,1,1,1,1,www.steinel.ch,Almeinstrasse,10,Einsiedeln,8406,Schwyz,Switzerland,Almeinstrasse,10,Einsiedeln,8406,Schwyz,Switzerland +Kynsight,2,2,3,1,www.kynsight.com,Meierackerestrasse,10,Uster,8610,Zürich,Switzerland,Meierackerestrasse,10,Uster,8610,Zürich,Switzerland +V-zug,3,1,2,1,www.v-zug.com,Industriestrasse,66,Zug,6302,Zug,Switzerland,Industriestrasse,66,Zug,6302,Zug,Switzerland +Stmicroelectronics,1,2,1,1,www.stm.com,Champ-des-Filles,39,Plan-les-Ouates,1228,Geneva,Switzerland,Champ-des-Filles,39,Plan-les-Ouates,1228,Geneva,Switzerland diff --git a/webinterface/minibase/database/company_legal_entity.csv b/webinterface/minibase/database/company_legal_entity.csv new file mode 100644 index 00000000..7319a702 --- /dev/null +++ b/webinterface/minibase/database/company_legal_entity.csv @@ -0,0 +1,9 @@ +name,description +AG,Aktiengesellschaft +GmbH,Gesellschaft mit beschränkter Haftung +SA,Société anonyme +SARL,Société à responsabilité limitée +EINZEL F.,Einzelfirma +KOLLEKTIV,Kollektivgesellschaft +E. INDIVIDIUEL,Entreprise individuel +COLLECTIF,Société en nom collectif diff --git a/webinterface/minibase/database/company_relation.csv b/webinterface/minibase/database/company_relation.csv new file mode 100644 index 00000000..8af917f1 --- /dev/null +++ b/webinterface/minibase/database/company_relation.csv @@ -0,0 +1,5 @@ +name,description +Customer,Buying company +Supplier,Selling company +Producer,Main producer may sell directly or trough a second channel +Collaborator,Whith whom we work together. Buying and Selling diff --git a/webinterface/minibase/database/company_status.csv b/webinterface/minibase/database/company_status.csv new file mode 100644 index 00000000..97cf78aa --- /dev/null +++ b/webinterface/minibase/database/company_status.csv @@ -0,0 +1,5 @@ +name,description +Activ,Actively making business +Closed,Out ob business +Bankrupt,Went bankrupt +Ignoring,Company with whom we don’t want to do business diff --git a/webinterface/minibase/database/industry.csv b/webinterface/minibase/database/industry.csv new file mode 100644 index 00000000..72614390 --- /dev/null +++ b/webinterface/minibase/database/industry.csv @@ -0,0 +1,8 @@ +name,description +Industrial,Active in industrial area tend to ask for long life components +Medical,Very long engineering time. Life sensitive devices may be prone to get rejects from certain manufactures +Consumer,High volume and short life cycles +Defence,May not be subjected to the same restrictions as Military but please discuss it with manufacturers. +Military,The most difficult type of customer as many manufacturers does not desire to work with them +Automotive,High volumes High life cycle +Aerospatial,Low volume very long lifecycles and price does rarely play a role diff --git a/webinterface/minibase/database/models.py b/webinterface/minibase/database/models.py index a94770c2..36249d2d 100644 --- a/webinterface/minibase/database/models.py +++ b/webinterface/minibase/database/models.py @@ -253,6 +253,7 @@ class Company(db.Model): employees = db.relationship('Person', backref='employer', lazy=True) projects = db.relationship('Project', backref='belongs_to', lazy=True) notes = db.relationship('Company_note', backref='company', lazy=True) + products = db.relationship('Product', backref='manufacturer', lazy=True) # returns a more information-rich, or official, string representation of an object @@ -334,11 +335,11 @@ class Project_element(db.Model): id = db.Column(db.Integer, nullable=False, primary_key=True) name = db.Column(db.String(100), nullable=False) description = db.Column(db.String(300), nullable=False) - qte_per_project = db.Column(db.Integer, nullable=False, default='0') + qte_per_project = db.Column(db.Integer, nullable=False, default='1') upload_date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) last_update_date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow, onupdate=datetime.utcnow) - project_id = db.Column(db.Integer, db.ForeignKey('project.id'), nullable=True) + project_id = db.Column(db.Integer, db.ForeignKey('project.id'), nullable=False) owner_id = db.Column(db.Integer, db.ForeignKey('person.id'), nullable=False) status_id = db.Column(db.Integer, db.ForeignKey('project_status.id'), nullable=False) @@ -366,9 +367,11 @@ class Project_status(db.Model): class Product(db.Model): id = db.Column(db.Integer, nullable=False, primary_key=True) + name = db.Column(db.String(100), nullable=False) + ordering_code = db.Column(db.String(100), nullable=False) buy_cost = db.Column(db.Float, nullable=False) - comment = db.Column(db.String(300), nullable=False) - comment_manufacturer = db.Column(db.String(300), nullable=False) + comment = db.Column(db.String(300), nullable=True) + comment_manufacturer = db.Column(db.String(300), nullable=True) currency = db.Column(db.String(50), nullable=False) description = db.Column(db.String(300), nullable=False) last_time_buy_date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) @@ -377,26 +380,30 @@ class Product(db.Model): minimum_order_quantity = db.Column(db.Integer, nullable=False) minimum_quote_quantity = db.Column(db.Integer, nullable=False) obsolete_date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) - ordering_code = db.Column(db.String(100), nullable=False) pollution_level = db.Column(db.String(50), nullable=True) - price_change_flag = db.Column(db.Boolean, nullable=False, default='0') - pricing_scheme = db.Column(db.String(300), nullable=False) - proposed_margin = db.Column(db.Float, nullable=False) + price_change_flag = db.Column(db.Boolean, nullable=False, default=False) + proposed_margin = db.Column(db.Float, nullable=True) + production_country = db.Column(db.String(75), nullable=True, default='') upload_date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) last_update_date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow, onupdate=datetime.utcnow) + classification_id = db.Column(db.Integer, db.ForeignKey('product_classification.id'), nullable=True) + domain_id = db.Column(db.Integer, db.ForeignKey('product_domain.id'), nullable=True) + category_id = db.Column(db.Integer, db.ForeignKey('product_category.id'), nullable=True) + sub_category_id = db.Column(db.Integer, db.ForeignKey('product_sub_category.id'), nullable=True) + status_id = db.Column(db.Integer, db.ForeignKey('product_status.id'), nullable=False) - classification_id = db.Column(db.Integer, db.ForeignKey('product_classification.id'), nullable=False) - packaging_id = db.Column(db.Integer, db.ForeignKey('product_packaging.id'), nullable=False) - physical_id = db.Column(db.Integer, db.ForeignKey('product_physical.id'), nullable=False) + eligibility_id = db.Column(db.Integer, db.ForeignKey('product_eligibility.id'), nullable=False) + + packaging_id = db.Column(db.Integer, db.ForeignKey('product_packaging.id'), nullable=True) + physical_id = db.Column(db.Integer, db.ForeignKey('product_physical.id'), nullable=True) + manufacturer_id = db.Column(db.Integer, db.ForeignKey('company.id'), nullable=False) class Product_status(db.Model): id = db.Column(db.Integer, nullable=False, primary_key=True) name = db.Column(db.String(50), nullable=False) description = db.Column(db.String(300), nullable=False) - upload_date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) - last_update_date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow, onupdate=datetime.utcnow) products = db.relationship('Product', backref='status', lazy=True) @@ -405,6 +412,18 @@ class Product_status(db.Model): return f"{self.name}" +class Product_eligibility(db.Model): + id = db.Column(db.Integer, nullable=False, primary_key=True) + name = db.Column(db.String(50), nullable=False) + description = db.Column(db.String(300), nullable=False) + + products = db.relationship('Product', backref='eligibility', lazy=True) + + # returns a more information-rich, or official, string representation of an object + def __repr__(self): + return f"{self.name}" + + class Product_classification(db.Model): id = db.Column(db.Integer, nullable=False, primary_key=True) name = db.Column(db.String(50), nullable=False) @@ -417,13 +436,48 @@ class Product_classification(db.Model): return f"{self.name}" +class Product_domain(db.Model): + id = db.Column(db.Integer, nullable=False, primary_key=True) + name = db.Column(db.String(50), nullable=False) + description = db.Column(db.String(300), nullable=False) + + products = db.relationship('Product', backref='domain', lazy=True) + + # returns a more information-rich, or official, string representation of an object + def __repr__(self): + return f"{self.name}" + + +class Product_category(db.Model): + id = db.Column(db.Integer, nullable=False, primary_key=True) + name = db.Column(db.String(50), nullable=False) + description = db.Column(db.String(300), nullable=False) + + products = db.relationship('Product', backref='category', lazy=True) + + # returns a more information-rich, or official, string representation of an object + def __repr__(self): + return f"{self.name}" + + +class Product_sub_category(db.Model): + id = db.Column(db.Integer, nullable=False, primary_key=True) + name = db.Column(db.String(50), nullable=False) + description = db.Column(db.String(300), nullable=False) + + products = db.relationship('Product', backref='sub_category', lazy=True) + + # returns a more information-rich, or official, string representation of an object + def __repr__(self): + return f"{self.name}" + + class Product_packaging(db.Model): id = db.Column(db.Integer, nullable=False, primary_key=True) name = db.Column(db.String(50), nullable=False) description = db.Column(db.String(300), nullable=False) unit = db.Column(db.Integer) quantity = db.Column(db.Integer) - total = db.Column(db.Integer) products = db.relationship('Product', backref='packaging', lazy=True) @@ -436,23 +490,14 @@ class Product_physical(db.Model): id = db.Column(db.Integer, nullable=False, primary_key=True) name = db.Column(db.String(50), nullable=False) description = db.Column(db.String(300), nullable=False) - image_file = db.Column(db.String(20), nullable=False, default='default_company.jpg') + image_file = db.Column(db.String(20), nullable=False, default='default_product.jpg') pitch_x = db.Column(db.Float, nullable=True) pitch_y = db.Column(db.Float, nullable=True) size_x = db.Column(db.Float, nullable=True) size_y = db.Column(db.Float, nullable=True) size_z = db.Column(db.Float, nullable=True) - type = db.Column(db.String(50), nullable=False) products = db.relationship('Product', backref='physical', lazy=True) # returns a more information-rich, or official, string representation of an object def __repr__(self): return f"{self.name}" - -''' - physical (MUL, int) - container (varchar) - favourite (tinyint, NULL, nullable) - manufacturer (varchar) - production_site (varchar) -''' diff --git a/webinterface/minibase/database/note_status.csv b/webinterface/minibase/database/note_status.csv new file mode 100644 index 00000000..1cdc7c79 --- /dev/null +++ b/webinterface/minibase/database/note_status.csv @@ -0,0 +1,5 @@ +name,description +Open,Open and need action +Pending,Pending We are waiting on someone +Done,Done we have solved the issue +Closed,Closed as no action is required anymore diff --git a/webinterface/minibase/database/person.csv b/webinterface/minibase/database/person.csv new file mode 100644 index 00000000..41ae2d9b --- /dev/null +++ b/webinterface/minibase/database/person.csv @@ -0,0 +1,3 @@ +name,last_name,company_id,role_id,competence_id,mail_prof,mail_priv,tel_prof_mobile,street_name,street_no,city,post_code,state,country +Kerem,Yollu,2,3,1,kerem.yollu_at_kynsight.com,kerem.yollu@gmail.com,41789716697,Meierackerstrasse,10,Uster,8610,Zürich,Switzerland +Stefan,Walker,1,2,2,stefan.walker_at_steinel.ch,stefan.walker@gmail.com,41789716697,Almeinderstrasse,10,Einsiedeln,8410,Schwyz,Switzerland diff --git a/webinterface/minibase/database/person_competence.csv b/webinterface/minibase/database/person_competence.csv new file mode 100644 index 00000000..68518a31 --- /dev/null +++ b/webinterface/minibase/database/person_competence.csv @@ -0,0 +1,6 @@ +name,description +Embedded Software,Embedded Software +Embedded Hardware,Embedded Hardware +Hardware,Electronics Hardware +Software,Electronics Software +Mechanical,Mechanical Engineer diff --git a/webinterface/minibase/database/person_role.csv b/webinterface/minibase/database/person_role.csv new file mode 100644 index 00000000..5d6c8b95 --- /dev/null +++ b/webinterface/minibase/database/person_role.csv @@ -0,0 +1,12 @@ +name,description +Engineer,An engineer in any domain +Engineering Manager,Engineering Responsible +Sales,Too much blabla +Sales Manager,Manages sales +Purchasing,Purchases required Material +Purchasing Manager,Manages purchasing team +Purchasing Strategical,Strategically Purchases required Materials on specific domain +CEO,Chief Executive Officer +CTO,Chief Technology Officer +Human Resources,Human Trafikers +Secretary,Knows Everything diff --git a/webinterface/minibase/database/product.csv b/webinterface/minibase/database/product.csv new file mode 100644 index 00000000..a16ee01d --- /dev/null +++ b/webinterface/minibase/database/product.csv @@ -0,0 +1,3 @@ +name,ordering_code,buy_cost,currency,description,lead_time_days,minimum_awarding_quantity,minimum_order_quantity,minimum_quote_quantity,classification_id,domain_id,category_id,sub_category_id,status_id,eligibility_id,packaging_id,physical_id,manufacturer_id +SMT32F031FQH,SMT32F031FQH,3,USD,SMT32F031FQH MCU,64,1000,500,500,1,1,1,1,1,1,1,1,3 +SMT32F456QQA,SMT32F456QQA,10,USD,SMT32F456QQA MCU,180,1000,250,250,2,2,2,2,2,2,2,2,3 diff --git a/webinterface/minibase/database/product_category.csv b/webinterface/minibase/database/product_category.csv new file mode 100644 index 00000000..f47e5e61 --- /dev/null +++ b/webinterface/minibase/database/product_category.csv @@ -0,0 +1,10 @@ +mane,description +Transistor,A transistor is a miniature semiconductor that regulates or controls current or voltage flow in addition amplifying and generating these electrical signals and acting as a switch/gate for them. +Op-amp ,A op-amp is an analog circuit block that takes a differential voltage input and produces a single-ended voltage output +MCU,A microcontroller (μC) or microcontroller unit (MCU) is a small computer on a single integrated circuit. +FPGA,Field Programmable Gate Arrays +CPLD,A Complex Programmable Logic Device +Resistor,Resistor +Connector,Connector +Cable,Cable +Logic,Logic diff --git a/webinterface/minibase/database/product_classification.csv b/webinterface/minibase/database/product_classification.csv new file mode 100644 index 00000000..dc539e18 --- /dev/null +++ b/webinterface/minibase/database/product_classification.csv @@ -0,0 +1,6 @@ +name,description +Passive,Passive components like resistors +Active ,Active components like transistors of op-amps +Electromechanical,Electromechanical components like connectors +Mechanical,Purely Mechanical components like PCB or housings +Hardware,general hardware like Screws and so diff --git a/webinterface/minibase/database/product_domain.csv b/webinterface/minibase/database/product_domain.csv new file mode 100644 index 00000000..f56ecf56 --- /dev/null +++ b/webinterface/minibase/database/product_domain.csv @@ -0,0 +1,8 @@ +name,description +Power,Power Components like IGBTs +Precision,Precision Components like precision op-amps +Ev-Charging,Components for ev-chaging like charging cables +Security,Security Components like e-fuses +Programmable,Programmable Components +High speed,High speed relevant components rj45 and os on +Radio,telecommunication components diff --git a/webinterface/minibase/database/product_eligibility.csv b/webinterface/minibase/database/product_eligibility.csv new file mode 100644 index 00000000..e8453d29 --- /dev/null +++ b/webinterface/minibase/database/product_eligibility.csv @@ -0,0 +1,5 @@ +name,description +Standard,Standard products do not have a pricing plan or scheme +Design Registrable,Products with special pricing schemes (manufacturer rules apply and differs for each component) +Restricted,This product is restricted to o given market or Region in the world +Mutli source,This component is produced by may manufacturers diff --git a/webinterface/minibase/database/product_packaging.csv b/webinterface/minibase/database/product_packaging.csv new file mode 100644 index 00000000..bae36be3 --- /dev/null +++ b/webinterface/minibase/database/product_packaging.csv @@ -0,0 +1,7 @@ +name,description,unit,quantity +Tape,Taped packaging,1,1000 +Reel,Reeled packaging,1,1000 +Tape and Reel,Taped and Reeled packaging,1,5000 +Box,Box,5,1000 +Single,Single Unit,1,1 +Tray,Tray units,1,250 diff --git a/webinterface/minibase/database/product_physical.csv b/webinterface/minibase/database/product_physical.csv new file mode 100644 index 00000000..dbe1314e --- /dev/null +++ b/webinterface/minibase/database/product_physical.csv @@ -0,0 +1,8 @@ +name,description +SOP-18,Small-outline package +CSOP-24,Ceramic small-outline package +DSOP-18,Dual small-outline package +HSOP-32,Thermally-enhanced small-outline package +HSSOP-18,Thermally-enhanced shrink small-outline package +HTSSOP-18,Thermally-enhanced thin shrink small-outline package +MSOP-8,Mini small-outline package diff --git a/webinterface/minibase/database/product_status.csv b/webinterface/minibase/database/product_status.csv new file mode 100644 index 00000000..3bd5e570 --- /dev/null +++ b/webinterface/minibase/database/product_status.csv @@ -0,0 +1,11 @@ +name,description +New,Newly put on data base (Default) +Pending,Registration request sent to Manufacturer and we are waiting for an answer +Accepted,Registration was successful +Denied,Registration was denied ( Negotiation is possible) +Already registered,Competitor has it already registered +Closed,Closed by us +Rejected,Registration was rejected (no Negotiation is possible) +Fulfillment,Only a margin will be given but no registration process +Open For all,Everyone get the same margin for this component +Not Registrable,Not par of a special pricing scheme diff --git a/webinterface/minibase/database/product_sub_category.csv b/webinterface/minibase/database/product_sub_category.csv new file mode 100644 index 00000000..28cb1c7e --- /dev/null +++ b/webinterface/minibase/database/product_sub_category.csv @@ -0,0 +1,12 @@ +name,description +Mosfet NPN,Mosfet NPN Transistor +Mosfet PNP,Mosfet PNP Transistor +Bipolar NPN,Bipolar NPN Transistor +Bipolar NPN,Bipolar NPN Transistor +Rail to Rial,Rail to Rail Op-amp +Cortex M4,Cortex M4 Core MCU +Cortex M0,Cortex M0 Core MCU +Thick film,Thick film Resistor +Thin film,Thin film Resistor +Metal film,Metal film Resistor +Carbon,Carbon Resistor diff --git a/webinterface/minibase/database/project.csv b/webinterface/minibase/database/project.csv new file mode 100644 index 00000000..b0581036 --- /dev/null +++ b/webinterface/minibase/database/project.csv @@ -0,0 +1,3 @@ +name,description,company_id,status_id,industry_id,owner_id,qte_prototype,qte_start,qte_production +STWA-HS,Aküsprühgerät für hautmittel,1,1,1,1,10,5000,10000 +Kolibri,Shisha Heat element,2,1,2,1,5,500,1000 diff --git a/webinterface/minibase/database/project_element.csv b/webinterface/minibase/database/project_element.csv new file mode 100644 index 00000000..63aabcf3 --- /dev/null +++ b/webinterface/minibase/database/project_element.csv @@ -0,0 +1,3 @@ +name,description,qte_per_project,project_id,owner_id,atatus_id +Power Board,Dc-Dc regulation fo batteries,8,1,1,1 +Ui,user input,1,1,1,1 diff --git a/webinterface/minibase/database/project_status.csv b/webinterface/minibase/database/project_status.csv new file mode 100644 index 00000000..e18bec48 --- /dev/null +++ b/webinterface/minibase/database/project_status.csv @@ -0,0 +1,8 @@ +name,description +Open,Ongoing project +Pending,Waiting on something +Closed,Closed project that did not go to production +Production,Is in production +Prototyping,Is in prototyping phase +End Of Life,End of Lifed projects. +Redesign,An old project being redone it must be linked to another project diff --git a/webinterface/minibase/database/utils.py b/webinterface/minibase/database/utils.py index 9738ca57..2f6a7285 100644 --- a/webinterface/minibase/database/utils.py +++ b/webinterface/minibase/database/utils.py @@ -1,7 +1,9 @@ from minibase.database.models import Company, Company_relation, Company_legal_entity -from minibase.database.models import Industry +from minibase.database.models import Industry, Countries from minibase.database.models import Person, Person_role, Person_competence -from minibase.database.models import Countries +from minibase.database.models import Project, Project_element, Product +from minibase import db +from numpy import genfromtxt # Gets the id of company from the formated output defined at models.py for the Company Model @@ -17,6 +19,7 @@ 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() @@ -133,3 +136,167 @@ def country_choices(): choices = Countries.query.all() return choices +################################################################################################### +# CSV manipulation +################################################################################################### + +def openCsv(filename): + data = genfromtxt(filename, + delimiter=',', + skip_header=1, + dtype=None, + encoding='UTF-8') + return data.tolist() + + +def db_add_name_and_description(csv, table): + try: + csv_list = openCsv(csv) + for i in csv_list: + record = table(**{ + 'name': i[0], + 'description': i[1]}) + db.session.add(record) # Add all the records + db.session.commit() # Attempt to commit all the records + except Exception as error: + db.session.rollback() # Rollback the changes on error + print(csv) + print("Error Ocured during <> upload to DB") + print(error) + + +def db_add_company(csv): + try: + csv_list = openCsv(csv) + for i in csv_list: + record = Company(**{ + 'name': i[0], + 'legal_entity_id': i[1], + 'relation_id': i[2], + 'industry_id': i[3], + 'status_id': i[4], + 'website': i[5], + 'street_bill': i[6], + 'street_no_bill': i[7], + 'city_bill': i[8], + 'post_code_bill': i[9], + 'state_bill': i[10], + 'country_bill': i[11], + 'street_ship': i[12], + 'street_no_ship': i[13], + 'city_ship': i[14], + 'post_code_ship': i[15], + 'state_ship': i[16], + 'country_ship': i[17]}) + db.session.add(record) # Add all the records + db.session.commit() # Attempt to commit all the records + except Exception as error: + db.session.rollback() # Rollback the changes on error + print("Error Ocured during <> upload to DB") + print(error) + + +def db_add_person(csv): + try: + csv_list = openCsv(csv) + for i in csv_list: + record = Person(**{ + 'name': i[0], + 'last_name': i[1], + 'company_id': i[2], + 'role_id': i[3], + 'competence_id': i[4], + 'mail_prof': i[5], + 'mail_priv': i[6], + 'tel_prof_mobile': i[7], + 'street_name': i[8], + 'street_no': i[9], + 'city': i[10], + 'post_code': i[11], + 'state': i[12], + 'country': i[13] + }) + db.session.add(record) # Add all the records + db.session.commit() # Attempt to commit all the records + except Exception as error: + db.session.rollback() # Rollback the changes on error + print("Error Ocured during <> upload to DB") + print(error) + + +def db_add_project(csv): + try: + csv_list = openCsv(csv) + for i in csv_list: + record = Project(**{ + 'name': i[0], + 'description': i[1], + 'company_id': i[2], + 'status_id': i[3], + 'industry_id': i[4], + 'owner_id': i[5], + 'qte_prototype': i[6], + 'qte_start': i[7], + 'qte_production': i[8] + }) + db.session.add(record) # Add all the records + db.session.commit() # Attempt to commit all the records + except Exception as error: + db.session.rollback() # Rollback the changes on error + print(csv) + print("Error Ocured during <> upload to DB") + print(error) + + +def db_add_project_element(csv): + try: + csv_list = openCsv(csv) + for i in csv_list: + record = Project_element(**{ + 'name': i[0], + 'description': i[1], + 'qte_per_project': i[2], + 'project_id': i[3], + 'owner_id': i[4], + 'status_id': i[5]}) + db.session.add(record) # Add all the records + db.session.commit() # Attempt to commit all the records + except Exception as error: + db.session.rollback() # Rollback the changes on error + print(csv) + print("Error Ocured during <> upload to DB") + print(error) + +def db_add_product(csv): + try: + csv_list = openCsv(csv) + for i in csv_list: + record = Product(**{ + 'name': i[0], + 'ordering_code': i[1], + 'buy_cost': i[2], + 'currency': i[3], + 'description': i[4], + 'lead_time_days': i[5], + 'minimum_awarding_quantity': i[6], + 'minimum_order_quantity': i[7], + 'minimum_quote_quantity': i[8], + 'classification_id': i[9], + 'domain_id': i[10], + 'category_id': i[11], + 'sub_category_id': i[12], + 'status_id': i[13], + 'eligibility_id': i[14], + 'packaging_id': i[15], + 'physical_id': i[16], + 'manufacturer_id': i[17]}) + db.session.add(record) # Add all the records + db.session.commit() # Attempt to commit all the records + except Exception as error: + db.session.rollback() # Rollback the changes on error + print(csv) + print("Error Ocured during <> upload to DB") + print(error) + + + diff --git a/webinterface/minibase/product/forms.py b/webinterface/minibase/product/forms.py new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/webinterface/minibase/product/forms.py @@ -0,0 +1 @@ + diff --git a/webinterface/minibase/product/routes.py b/webinterface/minibase/product/routes.py new file mode 100644 index 00000000..e69de29b diff --git a/webinterface/minibase/project/routes.py b/webinterface/minibase/project/routes.py index e69de29b..026bad8e 100644 --- a/webinterface/minibase/project/routes.py +++ b/webinterface/minibase/project/routes.py @@ -0,0 +1,37 @@ +from flask import render_template, url_for, flash, redirect, request, Blueprint +from minibase import db +from minibase.config import themeMinibase +from minibase.database.models import Company, Company_legal_entity, Company_relation,Company_status +from minibase.database.models import Industry, Note_status +from minibase.database.models import Person_role, Person_competence +from minibase.database.models import Project_status +from minibase.admin.forms import compLegalEntityForm, compRelationForm, industryRegisterForm,personRoleForm, personCompetenceForm, compStatusForm, noteStatusForm +from minibase.admin.forms import projectStatusForm +# Declaring a blueprint +project = Blueprint('project', __name__) + + +@admin.route("/register", methods=['GET', 'POST']) +def register(): + form = register() + legal_entities = Company_legal_entity.query.order_by(Company_legal_entity.name.asc()) + if form.validate_on_submit(): + companyLegal = Company_legal_entity( + name=form.name.data, + description=form.description.data) + # Here we need to give the id of thr role as this is a foreign key + db.session.add(companyLegal) + db.session.commit() + + flash(f'{"Company Legal Entity registered!"}', 'success') + return render_template('admin/company_register_legal_entity.html', + title='Register Company Legal Entity', + legal_entities=legal_entities, + theme=themeMinibase, + form=form) + + return render_template('admin/company_register_legal_entity.html', + title='Register Company Legal Entity', + legal_entities=legal_entities, + theme=themeMinibase, + form=form) diff --git a/webinterface/minibase/site.db b/webinterface/minibase/site.db index 6ccc2b3c..aaf4d73b 100644 Binary files a/webinterface/minibase/site.db and b/webinterface/minibase/site.db differ diff --git a/webinterface/minibase/static/pics/default_product.jpg b/webinterface/minibase/static/pics/default_product.jpg new file mode 100644 index 00000000..38f286f6 Binary files /dev/null and b/webinterface/minibase/static/pics/default_product.jpg differ diff --git a/webinterface/minibase/templates/admin/company_register_industry.html b/webinterface/minibase/templates/admin/company_register_industry.html deleted file mode 100644 index 3ee67fde..00000000 --- a/webinterface/minibase/templates/admin/company_register_industry.html +++ /dev/null @@ -1,65 +0,0 @@ -{% extends "layout.html" %} -{% block content %} -
-
- {{ form.hidden_tag() }} -
- Register Company Endustry - - -
- {{ form.name.label(class="form-control-label") }} - {% if form.name.errors %} - {{ form.name(class="form-control form-control-lg is-invalid") }} -
- {% for error in form.name.errors %} - {{ error }} - {% endfor %} -
- {% else %} - {{ form.name(class="form-control form-control-lg") }} - {% endif %} -
- - -
- {{ form.description.label(class="form-control-label") }} - {% if form.description.errors %} - {{ form.description(class="form-control form-control-lg is-invalid") }} -
- {% for error in form.description.errors %} - {{ error }} - {% endfor %} -
- {% else %} - {{ form.description(class="form-control form-control-lg") }} - {% endif %} -
- - -
- {{ form.submit(class="btn btn-outline-info") }} -
- -
-
-
-

Existing Industries

- - - - - - - - - {% for item in industries %} - - - - - {% endfor %} - -
NameDescription
{{ item.name }}{{ item.description}}
-
-{% endblock content %} diff --git a/webinterface/minibase/templates/admin/company_register_legal_entity.html b/webinterface/minibase/templates/admin/company_register_legal_entity.html deleted file mode 100644 index a2fe24c7..00000000 --- a/webinterface/minibase/templates/admin/company_register_legal_entity.html +++ /dev/null @@ -1,65 +0,0 @@ -{% extends "layout.html" %} -{% block content %} -
-
- {{ form.hidden_tag() }} -
- Register Company Legal Entity - - -
- {{ form.name.label(class="form-control-label") }} - {% if form.name.errors %} - {{ form.name(class="form-control form-control-lg is-invalid") }} -
- {% for error in form.name.errors %} - {{ error }} - {% endfor %} -
- {% else %} - {{ form.name(class="form-control form-control-lg") }} - {% endif %} -
- - -
- {{ form.description.label(class="form-control-label") }} - {% if form.description.errors %} - {{ form.description(class="form-control form-control-lg is-invalid") }} -
- {% for error in form.description.errors %} - {{ error }} - {% endfor %} -
- {% else %} - {{ form.description(class="form-control form-control-lg") }} - {% endif %} -
- - -
- {{ form.submit(class="btn btn-outline-info") }} -
- -
-
-
-

Existing Legal Entities

- - - - - - - - - {% for item in legal_entities %} - - - - - {% endfor %} - -
NameDescription
{{ item.name }}{{ item.description}}
-
-{% endblock content %} diff --git a/webinterface/minibase/templates/admin/company_register_relation.html b/webinterface/minibase/templates/admin/company_register_relation.html deleted file mode 100644 index b9985672..00000000 --- a/webinterface/minibase/templates/admin/company_register_relation.html +++ /dev/null @@ -1,67 +0,0 @@ -{% extends "layout.html" %} - - -{% block content %} -
-
- {{ form.hidden_tag() }} -
- Register Company Relation - - -
- {{ form.name.label(class="form-control-label") }} - {% if form.name.errors %} - {{ form.name(class="form-control form-control-lg is-invalid") }} -
- {% for error in form.name.errors %} - {{ error }} - {% endfor %} -
- {% else %} - {{ form.name(class="form-control form-control-lg") }} - {% endif %} -
- - -
- {{ form.description.label(class="form-control-label") }} - {% if form.description.errors %} - {{ form.description(class="form-control form-control-lg is-invalid") }} -
- {% for error in form.description.errors %} - {{ error }} - {% endfor %} -
- {% else %} - {{ form.description(class="form-control form-control-lg") }} - {% endif %} -
- - -
- {{ form.submit(class="btn btn-outline-info") }} -
- -
-
-
-

Existing Relations

- - - - - - - - - {% for item in relations %} - - - - - {% endfor %} - -
NameDescription
{{ item.name }}{{ item.description}}
-
-{% endblock content %} diff --git a/webinterface/minibase/templates/admin/person_register_competence.html b/webinterface/minibase/templates/admin/person_register_competence.html deleted file mode 100644 index 4ea4a7b2..00000000 --- a/webinterface/minibase/templates/admin/person_register_competence.html +++ /dev/null @@ -1,65 +0,0 @@ -{% extends "layout.html" %} -{% block content %} -
-
- {{ form.hidden_tag() }} -
- Register Person Competence - - -
- {{ form.name.label(class="form-control-label") }} - {% if form.name.errors %} - {{ form.name(class="form-control form-control-lg is-invalid") }} -
- {% for error in form.name.errors %} - {{ error }} - {% endfor %} -
- {% else %} - {{ form.name(class="form-control form-control-lg") }} - {% endif %} -
- - -
- {{ form.description.label(class="form-control-label") }} - {% if form.description.errors %} - {{ form.description(class="form-control form-control-lg is-invalid") }} -
- {% for error in form.description.errors %} - {{ error }} - {% endfor %} -
- {% else %} - {{ form.description(class="form-control form-control-lg") }} - {% endif %} -
- - -
- {{ form.submit(class="btn btn-outline-info") }} -
- -
-
-
-

Existing Competences

- - - - - - - - - {% for item in competences %} - - - - - {% endfor %} - -
NameDescription
{{ item.name }}{{ item.description}}
-
-{% endblock content %} diff --git a/webinterface/minibase/templates/admin/person_register_role.html b/webinterface/minibase/templates/admin/person_register_role.html deleted file mode 100644 index b6c14921..00000000 --- a/webinterface/minibase/templates/admin/person_register_role.html +++ /dev/null @@ -1,86 +0,0 @@ -{% extends "layout.html" %} -{% block content %} -
-
- {{ form.hidden_tag() }} -
- Register Person Role - - -
- {{ form.name.label(class="form-control-label") }} - {% if form.name.errors %} - {{ form.name(class="form-control form-control-lg is-invalid") }} -
- {% for error in form.name.errors %} - {{ error }} - {% endfor %} -
- {% else %} - {{ form.name(class="form-control form-control-lg") }} - {% endif %} -
- - -
- {{ form.description.label(class="form-control-label") }} - {% if form.description.errors %} - {{ form.description(class="form-control form-control-lg is-invalid") }} -
- {% for error in form.description.errors %} - {{ error }} - {% endfor %} -
- {% else %} - {{ form.description(class="form-control form-control-lg") }} - {% endif %} -
- - -
- {{ form.submit(class="btn btn-outline-info") }} -
- -
-
- -
-
-

Existing Roles

- - - - - - - - - {% for item in roles %} - - - - - {% endfor %} - -
NameDescription
{{ item.name }}{{ item.description}}
-
-

Existing Roles

- - - - - - - - - {% for item in roles %} - - - - - {% endfor %} - -
NameDescription
{{ item.name }}{{ item.description}}
-
- -{% endblock content %} diff --git a/webinterface/minibase/templates/admin/status_register.html b/webinterface/minibase/templates/admin/register_name_and_desc.html similarity index 93% rename from webinterface/minibase/templates/admin/status_register.html rename to webinterface/minibase/templates/admin/register_name_and_desc.html index 55b3c83e..59b04f68 100644 --- a/webinterface/minibase/templates/admin/status_register.html +++ b/webinterface/minibase/templates/admin/register_name_and_desc.html @@ -4,7 +4,7 @@
{{ form.hidden_tag() }}
- Register Status + {{ title }}
@@ -44,7 +44,7 @@
-

Existing Statuses

+

{{ tableTitle }}

@@ -53,7 +53,7 @@ - {% for item in statuses %} + {% for item in dbTable %} diff --git a/webinterface/minibase/templates/layout.html b/webinterface/minibase/templates/layout.html index 257c193a..658b0204 100644 --- a/webinterface/minibase/templates/layout.html +++ b/webinterface/minibase/templates/layout.html @@ -47,13 +47,24 @@ Company Regiters Legal EntityCompany Register Relation - Company Register Industry + Company Register Status - Person Register RolePerson Register Competence + Person Register Role + + Project Register Status + + Product Register Status + Product Register Eligibility + Product Register Domain + Product Register Classification + Product Register Category + Product Register Sub Category + Product Register Physical + Product Register Packaging - Status Register - Countries + Note Register Status + Register IndustryDatabase diff --git a/webinterface/prepare.py b/webinterface/prepare.py index 0ea2ea66..35eaebab 100644 --- a/webinterface/prepare.py +++ b/webinterface/prepare.py @@ -1,9 +1,10 @@ from minibase import db, create_minibase +import minibase.database.utils as dbUtils from minibase.database.models import Person, Person_role, Person_competence, Person_note from minibase.database.models import Company, Company_relation, Company_legal_entity, Company_note, Company_status from minibase.database.models import Status, Industry, Note_status from minibase.database.models import Project, Project_status, Project_element -from minibase.database.models import Product, Product_status, Project_element, Product_physical, Product_packaging +from minibase.database.models import Product, Product_status, Product_physical, Product_packaging, Product_domain, Product_eligibility, Product_category, Product_sub_category, Product_classification app = create_minibase() app.app_context().push() @@ -11,116 +12,21 @@ db.drop_all() db.create_all() - - ################################################################################################### -industry1 = Industry( - name='Industrial', - description="Active in Industrial area") -db.session.add(industry1) - -industry2 = Industry( - name='Consumer', - description="Active in Consumer area") -db.session.add(industry1) - -companyRelation1 = Company_relation( - name='Customer', - description="Only Buyiong customer") -db.session.add(companyRelation1) - -companyRelation2 = Company_relation( - name='Supplier', - description="Only Selling customer") -db.session.add(companyRelation2) - -companyRelation3 = Company_relation( - name='Collaborator', - description="Buying and Selling customer") -db.session.add(companyRelation2) -companyLegal1 = Company_legal_entity( - name='AG', - description='AktienGezelschaft') -db.session.add(companyLegal1) - -companyLegal2 = Company_legal_entity( - name='GMBH', - description='Gesellschaft mit beschränkter Haftung') -db.session.add(companyLegal2) +dbUtils.db_add_name_and_description("minibase/database/industry.csv", Industry) ################################################################################################### -companyStatus1 = Company_status( - name='Activ', - description='Company is active and business is running') -db.session.add(companyStatus1) - -companyStatus2 = Company_status( - name='Bankrupt', - description='Company is bankrupt') -db.session.add(companyStatus2) - -companyStatus3 = Company_status( - name='Closed', - description='Company is closed') -db.session.add(companyStatus3) -company1 = Company( - name='Steinel', - legal_entity_id='1', - relation_id='1', - industry_id='1', - status_id='1', - website='www.steinel.ch', - street_bill='Alemeinrstrasse', - street_no_bill='10', - city_bill='Einsiedeln', - post_code_bill='8406', - state_bill='Schyz', - country_bill='Switzerland', - street_ship='Alemeinrstrasse', - street_no_ship='10', - city_ship='Einsiedeln', - post_code_ship='8406', - state_ship='Schyz', - country_ship='Switzerland') -db.session.add(company1) +dbUtils.db_add_name_and_description("minibase/database/company_relation.csv", Company_relation) -company2 = Company( - name='Kynsight', - legal_entity_id='1', - relation_id='1', - industry_id='1', - status_id='3', - website='www.kynsight.com', - street_bill='Meierackerstrasse', - street_no_bill='10', - city_bill='Uster', - post_code_bill='8610', - state_bill='Zürich', - country_bill='Switzerland', - street_ship='Meierackerstrasse', - street_no_ship='10', - city_ship='Uster', - post_code_ship='8610', - state_ship='Zürich', - country_ship='Switzerland') -db.session.add(company2) +dbUtils.db_add_name_and_description("minibase/database/company_legal_entity.csv", Company_legal_entity) -noteStatus1 = Note_status( - name='Open', - description='Ongoing') -db.session.add(noteStatus1) +dbUtils.db_add_name_and_description("minibase/database/company_status.csv", Company_status) -noteStatus2 = Note_status( - name='Closed', - description='Ongoing') -db.session.add(noteStatus2) +dbUtils.db_add_company("minibase/database/company.csv") -noteStatus3 = Note_status( - name='Done', - description='Ongoing') -db.session.add(noteStatus3) +dbUtils.db_add_name_and_description("minibase/database/note_status.csv", Note_status) note1 = Company_note( title='Need to find a valid MCU For Stefan', @@ -148,69 +54,12 @@ db.session.add(note2) ################################################################################################### -PeresonRole1 = Person_role( - name='Engineer', - description='Standart Engineer') -db.session.add(PeresonRole1) +dbUtils.db_add_name_and_description("minibase/database/person_role.csv", Person_role) -PeresonRole2 = Person_role( - name='Engineerin Manager', - description='Manager for egineering') -db.session.add(PeresonRole2) +dbUtils.db_add_name_and_description("minibase/database/person_competence.csv", Person_competence) -PeresonRole3 = Person_role( - name='CEO', - description='Chief Executif Operation') -db.session.add(PeresonRole1) +dbUtils.db_add_person("minibase/database/person.csv") -PersonCompethence1 = Person_competence( - name='Embedded Systems', - description='Embedded Systems Engineer') -db.session.add(PersonCompethence1) - -PersonCompethence2 = Person_competence( - name='hardware', - description='Electronics Hardwre specialist') -db.session.add(PersonCompethence2) - -PersonCompethence3 = Person_competence( - name='Software', - description='Software engineer') -db.session.add(PersonCompethence1) - -person1 = Person( - name='Kerem', - last_name='Yollu', - company_id='2', - role_id='3', - competence_id='1', - mail_prof='kerem.yollu@kynsight.com', - mail_priv='kerem.yollu@gmail.com', - tel_prof_mobile='+41789716697', - street_name='Meierackerstrasse', - street_no='10', - city='Uster', - post_code='8610', - state='Zürich', - country='Switzerland') -db.session.add(person1) - -person2 = Person( - name='Stefan', - last_name='Walker', - company_id='1', - role_id='2', - competence_id='2', - mail_prof='stefan.walker@steinel.ch', - mail_priv='stefan.walker@gmail.com', - tel_prof_mobile='+4178956787', - street_name='Alemeinrstrasse', - street_no='10', - city='Einsiedeln', - post_code='8406', - state='Schyz', - country='Switzerland') -db.session.add(person2) note3 = Person_note( title='Birthday of Stefan', @@ -238,55 +87,19 @@ db.session.add(note5) ################################################################################################### +dbUtils.db_add_name_and_description("minibase/database/project_status.csv", Project_status) -projectStatus1 = Project_status( - name='Open', - description='Ongoing') -db.session.add(projectStatus1) +dbUtils.db_add_project("minibase/database/project.csv") -projectStatus2 = Project_status( - name='Closed', - description='Closed') -db.session.add(projectStatus2) +dbUtils.db_add_project_element("minibase/database/project_element.csv") -projectStatus3 = Project_status( - name='Pending', - description='Action Required') -db.session.add(projectStatus3) - - -project1 = Project( - name='STWA-HS', - description='Aküsprühgerät für hautmittel', - company_id='1', - status_id='1', - industry_id='1', - owner_id='1', - qte_prototype='10', - qte_start='5000', - qte_production='10000') -db.session.add(project1) - -element1 = Project_element( - name='Power Board', - description='Dc-Dc regulation fo batteries', - qte_per_project='8', - project_id='1', - owner_id='1', - status_id='1') - -db.session.add(element1) -''' ################################################################################################### -status1 = Status( - name='Obsolete', - description='Obsolete from Manufacturer') -db.session.add(status1) - -status2 = Status( - name='Active', - description='Everything is in order') -db.session.add(status2) -''' - -db.session.commit() +dbUtils.db_add_name_and_description("minibase/database/product_category.csv", Product_category) +dbUtils.db_add_name_and_description("minibase/database/product_classification.csv", Product_classification) +dbUtils.db_add_name_and_description("minibase/database/product_domain.csv", Product_domain) +dbUtils.db_add_name_and_description("minibase/database/product_eligibility.csv", Product_eligibility) +dbUtils.db_add_name_and_description("minibase/database/product_packaging.csv", Product_packaging) +dbUtils.db_add_name_and_description("minibase/database/product_physical.csv", Product_physical) +dbUtils.db_add_name_and_description("minibase/database/product_status.csv", Product_status) +dbUtils.db_add_name_and_description("minibase/database/product_sub_category.csv", Product_sub_category) +dbUtils.db_add_product("minibase/database/product.csv")
{{ item.name }} {{ item.description}}