Finished schema creation
Added Navbar functionality Added header
This commit is contained in:
@@ -4,6 +4,7 @@ from flask import request, redirect, url_for, flash, render_template, Blueprint
|
||||
from ..models.user import User, Tenant
|
||||
from ..extensions import db, bcrypt
|
||||
from .user_forms import TenantForm, UserForm
|
||||
from ..utils.database import Database
|
||||
|
||||
user_bp = Blueprint('user_bp', __name__, url_prefix='/user')
|
||||
|
||||
@@ -31,9 +32,9 @@ def tenant():
|
||||
monthly = request.form.get('allowed_monthly_interactions')
|
||||
|
||||
if lic_start != '':
|
||||
new_tenant.license_start_date = dt.strptime(lic_start, '%d-%m-%Y')
|
||||
new_tenant.license_start_date = dt.strptime(lic_start, '%Y-%m-%d')
|
||||
if lic_end != '':
|
||||
new_tenant.license_end_date = dt.strptime(lic_end, '%d-%m-%Y')
|
||||
new_tenant.license_end_date = dt.strptime(lic_end, '%Y-%m-%d')
|
||||
if monthly != '':
|
||||
new_tenant.allowed_monthly_interactions = int(monthly)
|
||||
|
||||
@@ -43,13 +44,17 @@ def tenant():
|
||||
new_tenant.updated_at = timestamp
|
||||
|
||||
# Add the new tenant to the database and commit the changes
|
||||
|
||||
try:
|
||||
db.session.add(new_tenant)
|
||||
db.session.commit()
|
||||
except Exception as e:
|
||||
error = e.args
|
||||
|
||||
# Create schema for new tenant
|
||||
if error is None:
|
||||
print(new_tenant.id)
|
||||
Database(new_tenant.id).create_tenant_schema()
|
||||
|
||||
flash(error) if error else flash('Tenant added successfully.')
|
||||
|
||||
form = TenantForm()
|
||||
@@ -81,7 +86,8 @@ def user():
|
||||
password_hash = bcrypt.generate_password_hash(password).decode('utf-8')
|
||||
|
||||
# Create new user if there is no error
|
||||
new_user = User(user_name=username, email=email, password=password_hash, first_name=first_name, last_name=last_name)
|
||||
new_user = User(user_name=username, email=email, password=password_hash, first_name=first_name,
|
||||
last_name=last_name)
|
||||
|
||||
# Handle optional attributes
|
||||
new_user.is_active = bool(request.form.get('is_active'))
|
||||
|
||||
Reference in New Issue
Block a user