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.
44 lines
1.7 KiB
44 lines
1.7 KiB
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
|
|
from minibase.company.forms import companyForm
|
|
import minibase.company.utils as utils
|
|
|
|
# Declaring a blueprint
|
|
company = Blueprint('company', __name__)
|
|
|
|
|
|
@company.route("/company_register", methods=['GET', 'POST'])
|
|
def company_register():
|
|
form = companyForm()
|
|
if form.validate_on_submit():
|
|
company = Company(
|
|
name=form.name.data,
|
|
country_bill=form.country.data,
|
|
state_bill=form.state.data,
|
|
city_bill=form.city.data,
|
|
postal_code_bill=form.post.data,
|
|
street_bill=form.street.data,
|
|
street_no_bill=form.no.data,
|
|
country_ship=form.country.data,
|
|
state_ship=form.state.data,
|
|
city_ship=form.city.data,
|
|
postal_code_ship=form.post.data,
|
|
street_ship=form.street.data,
|
|
street_no_ship=form.no.data,
|
|
industry=utils.getIndustryId(form.industry.data),
|
|
relation=utils.getRelationId(form.relation.data),
|
|
legal_entity=utils.getLegalEntityId(form.legal_entity.data))
|
|
# Here we need to give the id of thr role as this is a foreign key
|
|
db.session.add(company)
|
|
db.session.commit()
|
|
|
|
flash(f'{"Company succesfull registered!"} { company.industry} ', 'success')
|
|
return redirect(url_for('company.company_register'))
|
|
|
|
return render_template('company_register.html',
|
|
title='Register Company',
|
|
theme=themeMinibase,
|
|
form=form)
|