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.
50 lines
2.0 KiB
50 lines
2.0 KiB
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
|
|
from minibase.database.models import 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.company_name.data,
|
|
website=form.website.data,
|
|
country_bill=form.country.data,
|
|
state_bill=form.state.data,
|
|
city_bill=form.city.data,
|
|
post_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,
|
|
post_code_ship=form.post.data,
|
|
street_ship=form.street.data,
|
|
street_no_ship=form.no.data,
|
|
industry_id=utils.getIndustryId(form.industry_id.data),
|
|
relation_id=utils.getRelationId(form.relation_id.data),
|
|
legal_entity_id=utils.getLegalEntityId(form.legal_entity_id.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!"}', 'success')
|
|
return render_template('company_register.html',
|
|
title='Register Company',
|
|
theme=themeMinibase,
|
|
form=form)
|
|
# return redirect(url_for('company.company_register'))
|
|
|
|
return render_template('company_register.html',
|
|
title='Register Company',
|
|
theme=themeMinibase,
|
|
form=form)
|