parent
c4f3892707
commit
aa2fb21444
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,69 @@
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import StringField, SubmitField
|
||||
from wtforms.validators import DataRequired, ValidationError
|
||||
from minibase.models import Company_legal_entity, Company_industry, Company_relation, Person_role, Person_competence
|
||||
|
||||
|
||||
class compIndustryForm(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 Industry')
|
||||
|
||||
# Queries to be made in order to validate the form : If Relation Type exitst # Case Insensistive
|
||||
def validate_name(self, name):
|
||||
industry_query = Company_industry.query.filter(Company_industry.name.ilike(name.data)).first() # Database Querry ilike means case insessitive
|
||||
if industry_query:
|
||||
raise ValidationError('That Industry Type is already registered')
|
||||
|
||||
|
||||
class compRelationForm(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 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')
|
||||
|
||||
|
||||
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')
|
||||
|
||||
# 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')
|
||||
|
||||
|
||||
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')
|
||||
|
||||
# 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:
|
||||
raise ValidationError('That Person Role is already registered')
|
||||
|
||||
|
||||
class personCompetenceForm(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')
|
||||
|
||||
# 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:
|
||||
raise ValidationError('That Person Conpewtence is already registered')
|
@ -0,0 +1,123 @@
|
||||
from flask import render_template, url_for, flash, redirect, request, Blueprint
|
||||
from minibase import db
|
||||
from minibase.config import themeMinibase
|
||||
from minibase.models import Company, Company_industry, Company_legal_entity, Company_relation, Person_role, Person_competence
|
||||
from minibase.admin.forms import compLegalEntityForm, compRelationForm, compIndustryForm,personRoleForm, personCompetenceForm
|
||||
|
||||
# Declaring a blueprint
|
||||
admin = Blueprint('admin', __name__)
|
||||
|
||||
|
||||
@admin.route("/company_register_legal_entity", methods=['GET', 'POST'])
|
||||
def company_register_legal_entity():
|
||||
form = compLegalEntityForm()
|
||||
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',
|
||||
theme=themeMinibase,
|
||||
form=form)
|
||||
|
||||
return render_template('admin/company_register_legal_entity.html',
|
||||
title='Register Company Legal Entity',
|
||||
theme=themeMinibase,
|
||||
form=form)
|
||||
|
||||
|
||||
@admin.route("/company_register_relation", methods=['GET', 'POST'])
|
||||
def company_register_relation():
|
||||
form = compRelationForm()
|
||||
if form.validate_on_submit():
|
||||
companyRelation = 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.commit()
|
||||
|
||||
flash(f'{"Company Relation registered!"}', 'success')
|
||||
return render_template('admin/company_register_relation.html',
|
||||
title='Register Company Relation',
|
||||
theme=themeMinibase,
|
||||
form=form)
|
||||
|
||||
return render_template('admin/company_register_relation.html',
|
||||
title='Register Company Relation',
|
||||
theme=themeMinibase,
|
||||
form=form)
|
||||
|
||||
|
||||
@admin.route("/company_register_industry", methods=['GET', 'POST'])
|
||||
def company_register_industry():
|
||||
form = compIndustryForm()
|
||||
if form.validate_on_submit():
|
||||
companyIndustry = Company_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(companyIndustry)
|
||||
db.session.commit()
|
||||
|
||||
flash(f'{"Company Idustry registered!"}', 'success')
|
||||
return render_template('admin/company_register_industry.html',
|
||||
title='Register Company Industry',
|
||||
theme=themeMinibase,
|
||||
form=form)
|
||||
|
||||
return render_template('admin/company_register_industry.html',
|
||||
title='Register Company Industry',
|
||||
theme=themeMinibase,
|
||||
form=form)
|
||||
|
||||
|
||||
@admin.route("/person_register_role", methods=['GET', 'POST'])
|
||||
def person_register_role():
|
||||
form = personRoleForm()
|
||||
if form.validate_on_submit():
|
||||
personRole = 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.commit()
|
||||
|
||||
flash(f'{"Person Role registered!"}', 'success')
|
||||
return render_template('admin/person_register_role.html',
|
||||
title='Register Person_role',
|
||||
theme=themeMinibase,
|
||||
form=form)
|
||||
|
||||
return render_template('admin/person_register_role.html',
|
||||
title='Register Person Role',
|
||||
theme=themeMinibase,
|
||||
form=form)
|
||||
|
||||
|
||||
@admin.route("/person_register_competence", methods=['GET', 'POST'])
|
||||
def person_register_competence():
|
||||
form = personCompetenceForm()
|
||||
if form.validate_on_submit():
|
||||
personCompetence = 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.commit()
|
||||
|
||||
flash(f'{"Person Competence registered!"}', 'success')
|
||||
return render_template('admin/person_register_competence.html',
|
||||
title='Register Person Competence',
|
||||
theme=themeMinibase,
|
||||
form=form)
|
||||
|
||||
return render_template('admin/person_register_competence.html',
|
||||
title='Register Person Competence',
|
||||
theme=themeMinibase,
|
||||
form=form)
|
@ -0,0 +1 @@
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,31 +0,0 @@
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import StringField, SubmitField
|
||||
from wtforms.validators import DataRequired
|
||||
|
||||
|
||||
class compIndustryForm(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 Industry')
|
||||
|
||||
|
||||
class compRelationForm(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 Relation')
|
||||
|
||||
|
||||
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')
|
||||
|
||||
|
||||
class personRole(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')
|
@ -1,77 +0,0 @@
|
||||
from flask import render_template, url_for, flash, redirect, request, Blueprint
|
||||
from minibase import db
|
||||
from minibase.config import themeMinibase
|
||||
from minibase.models import Company, Company_industry, Company_legal_entity, Company_relation
|
||||
from minibase.administration.forms import compLegalEntityForm, compRelationForm, compIndustryForm
|
||||
|
||||
# Declaring a blueprint
|
||||
administration = Blueprint('administration', __name__)
|
||||
|
||||
|
||||
@administration.route("/administration_company_legal_entity", methods=['GET', 'POST'])
|
||||
def administration_company_legal_entity():
|
||||
form = compLegalEntityForm()
|
||||
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('administration_company_legal_entity.html',
|
||||
title='Register Company Legal Entity',
|
||||
theme=themeMinibase,
|
||||
form=form)
|
||||
|
||||
return render_template('administration_company_legal_entity.html',
|
||||
title='Register Company Legal Entity',
|
||||
theme=themeMinibase,
|
||||
form=form)
|
||||
|
||||
|
||||
@administration.route("/administration_company_relation", methods=['GET', 'POST'])
|
||||
def administration_company_relation():
|
||||
form = compRelationForm()
|
||||
if form.validate_on_submit():
|
||||
companyLegal = 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(companyLegal)
|
||||
db.session.commit()
|
||||
|
||||
flash(f'{"Company Relation registered!"}', 'success')
|
||||
return render_template('administration_company_relation.html',
|
||||
title='Register Company Relation',
|
||||
theme=themeMinibase,
|
||||
form=form)
|
||||
|
||||
return render_template('administration_company_relation.html',
|
||||
title='Register Company Relation',
|
||||
theme=themeMinibase,
|
||||
form=form)
|
||||
|
||||
|
||||
@administration.route("/administration_company_industry", methods=['GET', 'POST'])
|
||||
def administration_company_industry():
|
||||
form = compIndustryForm()
|
||||
if form.validate_on_submit():
|
||||
companyLegal = Company_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(companyLegal)
|
||||
db.session.commit()
|
||||
|
||||
flash(f'{"Company Idustry registered!"}', 'success')
|
||||
return render_template('administration_company_industry.html',
|
||||
title='Register Company Industry',
|
||||
theme=themeMinibase,
|
||||
form=form)
|
||||
|
||||
return render_template('administration_company_industry.html',
|
||||
title='Register Company Industry',
|
||||
theme=themeMinibase,
|
||||
form=form)
|
@ -1,11 +0,0 @@
|
||||
from minibase.models import Countries
|
||||
|
||||
# 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
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
@ -1,27 +1,31 @@
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import StringField, SubmitField, IntegerField, SelectField
|
||||
from wtforms.validators import DataRequired, Length, ValidationError
|
||||
from minibase.models import Company, Company_relation
|
||||
import minibase.company.utils as utils
|
||||
import minibase.administration.utils as adminUtils
|
||||
from wtforms.validators import DataRequired, Length, ValidationError, Optional
|
||||
from minibase.models import Company
|
||||
import minibase.database.utils as DbUtils
|
||||
|
||||
|
||||
class companyForm(FlaskForm): # Defines the form class to be used for the user registretion
|
||||
# Defines the form class to be used for the user registretion
|
||||
class companyForm(FlaskForm):
|
||||
# Decalarion of the fields for the form and it's propereties
|
||||
name = StringField('Name', validators=[DataRequired(), Length(min=3, max=100)])
|
||||
legal_entity = SelectField('Legal Entity', choices=utils.company_legal_entity_choices, validators=[DataRequired()])
|
||||
relation = SelectField('Relation', choices=utils.company_relation_choices, validators=[DataRequired()])
|
||||
country = SelectField('Country', choices=adminUtils.country_choices, validators=[DataRequired()])
|
||||
company_name = StringField('Name', validators=[DataRequired(), Length(min=3, max=20)])
|
||||
legal_entity_id = SelectField('Legal Entity', choices=DbUtils.company_legal_entity_choices, validators=[DataRequired()])
|
||||
relation_id = SelectField('Relation', choices=DbUtils.company_relation_choices, validators=[DataRequired()])
|
||||
website = StringField('Website', validators=[Optional(), Length(min=3, max=100)])
|
||||
country = SelectField('Country', choices=DbUtils.country_choices,validators=[DataRequired()])
|
||||
state = StringField('State', validators=[DataRequired()])
|
||||
city = StringField('City', validators=[DataRequired()])
|
||||
post = IntegerField('Zip', validators=[DataRequired()])
|
||||
street = StringField('Street', validators=[DataRequired()])
|
||||
no = IntegerField('No', validators=[DataRequired()])
|
||||
industry = SelectField('Area', choices=utils.company_industry_choices, validators=[DataRequired()])
|
||||
industry_id = SelectField('Area', choices=DbUtils.company_industry_choices, validators=[DataRequired()])
|
||||
submit = SubmitField('Register Company')
|
||||
|
||||
def validate_company_duplicate(self, name, country, relation):
|
||||
companyName = Company.query.filter_by(name=name.data).first()
|
||||
if companyName:
|
||||
raise ValidationError('That Company Allredy Exitst Please modify it instead')
|
||||
|
||||
# Queries to be made in order to validate the form : If Company name exitst within the same country
|
||||
# Case Insensistive
|
||||
def validate_company_name(self, company_name):
|
||||
company_query = Company.query.filter(Company.name.ilike(self.company_name.data)) # Database Querry ilike means case insessitive
|
||||
for company in company_query:
|
||||
if company.name:
|
||||
if company.country_bill == self.country.data:
|
||||
raise ValidationError('This company in this contry alredy exist')
|
||||
|
Binary file not shown.
@ -0,0 +1,133 @@
|
||||
from minibase.models import Company, Company_industry, Company_relation, Company_legal_entity
|
||||
from minibase.models import Countries, Person, Person_role, Person_competence
|
||||
|
||||
|
||||
# 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 Company_industry
|
||||
# Note that the formating is done during the SQLAlchemy Table declaration.
|
||||
def company_industry_choices():
|
||||
choices = Company_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 = Company_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
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,33 @@
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import StringField, SubmitField, SelectField, DateField
|
||||
from wtforms.validators import DataRequired, Length, ValidationError, Email, Optional
|
||||
from minibase.models import Person
|
||||
import minibase.database.utils as DbUtils
|
||||
|
||||
|
||||
# Defines the form class to be used for the user registretion
|
||||
class personForm(FlaskForm):
|
||||
# Decalarion of the fields for the form and it's propereties
|
||||
name = StringField('Name', validators=[DataRequired(), Length(min=3, max=20)])
|
||||
last_name = StringField('Last Name', validators=[DataRequired(), Length(min=3, max=20)])
|
||||
date_of_birth = DateField('Birth Date')
|
||||
mail_prof = StringField('Email Professional', validators=[DataRequired(), Email()])
|
||||
mail_priv = StringField('Email Private', validators=[Optional(), Email()])
|
||||
tel_prof_fix = StringField('Tel Professional Fix', validators=[Optional()])
|
||||
tel_prof_mobile = StringField('Tel Professional Mob', validators=[Optional()])
|
||||
tel_priv_fix = StringField('Tel Private Fix', validators=[Optional()])
|
||||
tel_priv_mobile = StringField('Tel Private Mob', validators=[Optional()])
|
||||
company_id = SelectField('Company', choices=DbUtils.company_choices, validators=[DataRequired()])
|
||||
competence_id = SelectField('Competence', choices=DbUtils.person_competence_choices, validators=[DataRequired()])
|
||||
role_id = SelectField('Role', choices=DbUtils.person_role_choices, validators=[DataRequired()])
|
||||
submit = SubmitField('Register Person')
|
||||
|
||||
# Queries to be made in order to validate the form : If person with this name exitst within the same company
|
||||
# Case Insensistive
|
||||
def validate_person(self):
|
||||
person_query = Person.query.filter(Person.name.ilike(self.name.data)) # Database Querry ilike means case insessitive
|
||||
for person in person_query:
|
||||
if person.name:
|
||||
if person.last_name.lower() == self.last_name.data.lower():
|
||||
if person.company == self.company.data:
|
||||
raise ValidationError('This person working in this company alredy exist')
|
@ -0,0 +1,50 @@
|
||||
from flask import render_template, url_for, flash, redirect, request, Blueprint
|
||||
from minibase import db
|
||||
from minibase.config import themeMinibase
|
||||
from minibase.models import Person
|
||||
from minibase.person.forms import personForm
|
||||
import minibase.database.utils as DbUtils
|
||||
|
||||
# Declaring a blueprint
|
||||
person = Blueprint('person', __name__)
|
||||
|
||||
|
||||
@person.route("/person_register", methods=['GET', 'POST'])
|
||||
def person_register():
|
||||
form = personForm()
|
||||
if form.validate_on_submit():
|
||||
companyID = DbUtils.getCompanyId(form.company_id.data)
|
||||
person = Person(
|
||||
name=form.name.data,
|
||||
last_name=form.last_name.data,
|
||||
date_of_birth=form.date_of_birth.data,
|
||||
tel_prof_fix=form.tel_prof_fix.data,
|
||||
tel_prof_mobile=form.tel_prof_mobile.data,
|
||||
tel_priv_fix=form.tel_priv_fix.data,
|
||||
tel_priv_mobile=form.tel_priv_mobile.data,
|
||||
mail_prof=form.mail_prof.data,
|
||||
mail_priv=form.mail_priv.data,
|
||||
company_id=companyID,
|
||||
country=DbUtils.getCompanyCountry(companyID),
|
||||
state=DbUtils.getCompanyState(companyID),
|
||||
city=DbUtils.getCompanyCity(companyID),
|
||||
post_code=DbUtils.getCompanyPostCode(companyID),
|
||||
street_name=DbUtils.getCompanyStreetName(companyID),
|
||||
street_no=DbUtils.getCompanyStreetNo(companyID),
|
||||
role_id=DbUtils.getPersonRoleId(form.role_id.data),
|
||||
competence_id=DbUtils.getPersonCompetenceId(form.competence_id.data))
|
||||
|
||||
db.session.add(person)
|
||||
db.session.commit()
|
||||
|
||||
flash(f'{"Company succesfull registered!"}', 'success')
|
||||
return render_template('person_register.html',
|
||||
title='Register Person',
|
||||
theme=themeMinibase,
|
||||
form=form)
|
||||
# return redirect(url_for('company.company_register'))
|
||||
|
||||
return render_template('person_register.html',
|
||||
title='Register Person',
|
||||
theme=themeMinibase,
|
||||
form=form)
|
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 11 KiB |
@ -1,4 +1,6 @@
|
||||
{% extends "layout.html" %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
<div class="{{ theme.userInputDivClass }}" style="{{ theme.userInputFormColor }}">
|
||||
<form method="POST" action="">
|
@ -0,0 +1,46 @@
|
||||
{% extends "layout.html" %}
|
||||
{% block content %}
|
||||
<div class="{{ theme.userInputDivClass }}" style="{{ theme.userInputFormColor }}">
|
||||
<form method="POST" action="">
|
||||
{{ form.hidden_tag() }}
|
||||
<fieldset class="form-group"></fieldset>
|
||||
<legend class="border-bottom mb-4">Register Person Competence</legend>
|
||||
|
||||
<!-- name of the company-->
|
||||
<div class="form-group">
|
||||
{{ form.name.label(class="form-control-label") }}
|
||||
{% if form.name.errors %}
|
||||
{{ form.name(class="form-control form-control-lg is-invalid") }}
|
||||
<div class="invalid-feedback">
|
||||
{% for error in form.name.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
{{ form.name(class="form-control form-control-lg") }}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- description of the company-->
|
||||
<div class="form-group">
|
||||
{{ form.description.label(class="form-control-label") }}
|
||||
{% if form.description.errors %}
|
||||
{{ form.description(class="form-control form-control-lg is-invalid") }}
|
||||
<div class="invalid-feedback">
|
||||
{% for error in form.description.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
{{ form.description(class="form-control form-control-lg") }}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Submit Button -->
|
||||
<div class="form-group">
|
||||
{{ form.submit(class="btn btn-outline-info") }}
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
{% endblock content %}
|
@ -0,0 +1,46 @@
|
||||
{% extends "layout.html" %}
|
||||
{% block content %}
|
||||
<div class="{{ theme.userInputDivClass }}" style="{{ theme.userInputFormColor }}">
|
||||
<form method="POST" action="">
|
||||
{{ form.hidden_tag() }}
|
||||
<fieldset class="form-group"></fieldset>
|
||||
<legend class="border-bottom mb-4">Register Person Role</legend>
|
||||
|
||||
<!-- name of the company-->
|
||||
<div class="form-group">
|
||||
{{ form.name.label(class="form-control-label") }}
|
||||
{% if form.name.errors %}
|
||||
{{ form.name(class="form-control form-control-lg is-invalid") }}
|
||||
<div class="invalid-feedback">
|
||||
{% for error in form.name.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
{{ form.name(class="form-control form-control-lg") }}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- description of the company-->
|
||||
<div class="form-group">
|
||||
{{ form.description.label(class="form-control-label") }}
|
||||
{% if form.description.errors %}
|
||||
{{ form.description(class="form-control form-control-lg is-invalid") }}
|
||||
<div class="invalid-feedback">
|
||||
{% for error in form.description.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
{{ form.description(class="form-control form-control-lg") }}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Submit Button -->
|
||||
<div class="form-group">
|
||||
{{ form.submit(class="btn btn-outline-info") }}
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
{% endblock content %}
|
@ -0,0 +1,198 @@
|
||||
{% extends "layout.html" %}
|
||||
{% block content %}
|
||||
<div class="{{ theme.userInputDivClass }}" style="{{ theme.userInputFormColor }}">
|
||||
<form method="POST" action="">
|
||||
{{ form.hidden_tag() }}
|
||||
<fieldset class="form-group">
|
||||
<legend class="border-bottom mb-4">Register Person</legend>
|
||||
|
||||
<!-- name of the person-->
|
||||
<div class="form-group">
|
||||
{{ form.name.label(class="form-control-label") }}
|
||||
{% if form.name.errors %}
|
||||
{{ form.name(class="form-control form-control-lg is-invalid") }}
|
||||
<div class="invalid-feedback">
|
||||
{% for error in form.name.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
{{ form.name(class="form-control form-control-lg") }}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- last_name of the person-->
|
||||
<div class="form-group">
|
||||
{{ form.last_name.label(class="form-control-label") }}
|
||||
{% if form.last_name.errors %}
|
||||
{{ form.last_name(class="form-control form-control-lg is-invalid") }}
|
||||
<div class="invalid-feedback">
|
||||
{% for error in form.last_name.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
{{ form.last_name(class="form-control form-control-lg") }}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Company of the person -->
|
||||
<div class="form-group">
|
||||
{{ form.company_id.label(class="form-control-label") }}
|
||||
{% if form.company_id.errors %}
|
||||
{{ form.company_id(class="form-control form-control-lg is-invalid") }}
|
||||
<div class="invalid-feedback">
|
||||
{% for error in form.company_id.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
{{ form.company_id(class="form-control form-control-lg") }}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Role on the company no of the person -->
|
||||
<div class="form-group">
|
||||
{{ form.role_id.label(class="form-control-label") }}
|
||||
{% if form.role_id.errors %}
|
||||
{{ form.role_id(class="form-control form-control-lg is-invalid") }}
|
||||
<div class="invalid-feedback">
|
||||
{% for error in form.role_id.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
{{ form.role_id(class="form-control form-control-lg") }}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Competence on the company no of the person -->
|
||||
<div class="form-group">
|
||||
{{ form.competence_id.label(class="form-control-label") }}
|
||||
{% if form.competence_id.errors %}
|
||||
{{ form.competence_id(class="form-control form-control-lg is-invalid") }}
|
||||
<div class="invalid-feedback">
|
||||
{% for error in form.competence_id.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
{{ form.competence_id(class="form-control form-control-lg") }}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- date_of_birth of the person to us-->
|
||||
<div class="form-group">
|
||||
{{ form.date_of_birth.label(class="form-control-label") }}
|
||||
{% if form.date_of_birth.errors %}
|
||||
{{ form.date_of_birth(class="form-control form-control-lg is-invalid") }}
|
||||
<div class="invalid-feedback">
|
||||
{% for error in form.date_of_birth.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
{{ form.date_of_birth(class="form-control form-control-lg") }}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- mail_prof of the person-->
|
||||
<div class="form-group">
|
||||
{{ form.mail_prof.label(class="form-control-label") }}
|
||||
{% if form.mail_prof.errors %}
|
||||
{{ form.mail_prof(class="form-control form-control-lg is-invalid") }}
|
||||
<div class="invalid-feedback">
|
||||
{% for error in form.mail_prof.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
{{ form.mail_prof(class="form-control form-control-lg") }}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- mail_priv of the person -->
|
||||
<div class="form-group">
|
||||
{{ form.mail_priv.label(class="form-control-label") }}
|
||||
{% if form.mail_priv.errors %}
|
||||
{{ form.mail_priv(class="form-control form-control-lg is-invalid") }}
|
||||
<div class="invalid-feedback">
|
||||
{% for error in form.mail_priv.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
{{ form.mail_priv(class="form-control form-control-lg") }}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Fix professional tel no of the person-->
|
||||
<div class="form-group">
|
||||
{{ form.tel_prof_fix.label(class="form-control-label") }}
|
||||
{% if form.tel_prof_fix.errors %}
|
||||
{{ form.tel_prof_fix(class="form-control form-control-lg is-invalid") }}
|
||||
<div class="invalid-feedback">
|
||||
{% for error in form.tel_prof_fix.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
{{ form.tel_prof_fix(class="form-control form-control-lg") }}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Mobile professional number of the person-->
|
||||
<div class="form-group">
|
||||
{{ form.tel_prof_mobile.label(class="form-control-label") }}
|
||||
{% if form.tel_prof_mobile.errors %}
|
||||
{{ form.tel_prof_mobile(class="form-control form-control-lg is-invalid") }}
|
||||
<div class="invalid-feedback">
|
||||
{% for error in form.tel_prof_mobile.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
{{ form.tel_prof_mobile(class="form-control form-control-lg") }}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Private fix Tel Number of the person -->
|
||||
<div class="form-group">
|
||||
{{ form.tel_priv_fix.label(class="form-control-label") }}
|
||||
{% if form.tel_priv_fix.errors %}
|
||||
{{ form.tel_priv_fix(class="form-control form-control-lg is-invalid") }}
|
||||
<div class="invalid-feedback">
|
||||
{% for error in form.tel_priv_fix.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
{{ form.tel_priv_fix(class="form-control form-control-lg") }}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Private Tel no of the person -->
|
||||
<div class="form-group">
|
||||
{{ form.tel_priv_mobile.label(class="form-control-label") }}
|
||||
{% if form.tel_priv_mobile.errors %}
|
||||
{{ form.tel_priv_mobile(class="form-control form-control-lg is-invalid") }}
|
||||
<div class="invalid-feedback">
|
||||
{% for error in form.tel_priv_mobile.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
{{ form.tel_priv_mobile(class="form-control form-control-lg") }}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
<!-- Submit Button -->
|
||||
<div class="form-group">
|
||||
{{ form.submit(class="btn btn-outline-info") }}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
|
Loading…
Reference in new issue