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)