You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
1.6 KiB
28 lines
1.6 KiB
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
|
|
|
|
|
|
class companyForm(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(), 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()])
|
|
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()])
|
|
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')
|
|
|