diff --git a/eveai_app/extensions.py b/eveai_app/extensions.py index cadcac6..a7299c9 100644 --- a/eveai_app/extensions.py +++ b/eveai_app/extensions.py @@ -5,13 +5,10 @@ from flask_security import Security from flask_mailman import Mail from flask_login import LoginManager - - # Create extensions - db = SQLAlchemy() migrate = Migrate() bootstrap = Bootstrap() security = Security() mail = Mail() -login_manager = LoginManager() \ No newline at end of file +login_manager = LoginManager() diff --git a/eveai_app/templates/navbar.html b/eveai_app/templates/navbar.html index ac44fa4..8064a98 100644 --- a/eveai_app/templates/navbar.html +++ b/eveai_app/templates/navbar.html @@ -1,68 +1,22 @@ - +{% from "navbar_macros.html" import nav_link, dropdown %} + \ No newline at end of file diff --git a/eveai_app/templates/navbar_macros.html b/eveai_app/templates/navbar_macros.html new file mode 100644 index 0000000..9831363 --- /dev/null +++ b/eveai_app/templates/navbar_macros.html @@ -0,0 +1,43 @@ +{% macro nav_link(name, url, icon=None) %} + +{% endmacro %} + +{% macro dropdown(title, icon, children) %} + +{% endmacro %} \ No newline at end of file diff --git a/eveai_app/templates/user/select_tenant.html b/eveai_app/templates/user/select_tenant.html new file mode 100644 index 0000000..ddb5097 --- /dev/null +++ b/eveai_app/templates/user/select_tenant.html @@ -0,0 +1,33 @@ +{% extends 'base.html' %} +{% from "macros.html" import render_field %} + +{% block title %}Tenant Selection{% endblock %} + +{% block content_title %}Select a Tenant{% endblock %} +{% block content_description %}Select the active tenant for the current session{% endblock %} + +{% block content %} +
+ + + + + + + + + + {% for tenant in tenants %} + + + + + + {% endfor %} + +
SelectTenant NameTenant ID
{{ tenant.name }}{{ tenant.id }}
+ + + +
+{% endblock %} diff --git a/eveai_app/templates/user/view_users.html b/eveai_app/templates/user/view_users.html new file mode 100644 index 0000000..a5c505a --- /dev/null +++ b/eveai_app/templates/user/view_users.html @@ -0,0 +1,55 @@ +{% extends 'base.html' %} +{% from "macros.html" import render_field %} + +{% block title %}View Users{% endblock %} + +{% block content_title %}Select a user{% endblock %} +{% block content_description %}Select the user you'd like to action upon{% endblock %} + +{% block content %} +

Users for Selected Tenant

+
+ + + + + + + + + + + {% for user in users %} + + + + + + + {% endfor %} + +
SelectUser IDNameEmail
{{ user.id }}{{ user.name }}{{ user.email }}
+
+ + +
+
+ + + +{% endblock %} diff --git a/eveai_app/views/user_views.py b/eveai_app/views/user_views.py index 29a3b04..f2f4871 100644 --- a/eveai_app/views/user_views.py +++ b/eveai_app/views/user_views.py @@ -2,7 +2,7 @@ import uuid from datetime import datetime as dt, timezone as tz from flask import request, redirect, url_for, flash, render_template, Blueprint, session -from flask_security import hash_password +from flask_security import hash_password, current_user from ..models.user import User, Tenant, Role, RolesUsers from ..extensions import db @@ -162,3 +162,44 @@ def edit_user(user_id): form.roles.data = [role.id for role in user.roles] return render_template('user/edit_user.html', form=form, user_id=user_id) + + +@user_bp.route('/select_tenant') +def select_tenant(): + tenants = Tenant.query.all() # Fetch all tenants from the database + return render_template('user/select_tenant.html', tenants=tenants) + + +@user_bp.route('/handle_tenant_selection', methods=['POST']) +def handle_tenant_selection(): + tenant_id = request.form['tenant_id'] + session['tenant_id'] = request.form['tenant_id'] + action = request.form['action'] + + if action == 'view_users': + return redirect(url_for('user_bp.view_users', tenant_id=tenant_id)) + elif action == 'edit_tenant': + return redirect(url_for('user_bp.edit_tenant', tenant_id=tenant_id)) + # Add more conditions for other actions + return redirect(url_for('select_tenant')) + + +@user_bp.route('/view_users/') +def view_users(tenant_id): + print(tenant_id) + tenant_id = int(tenant_id) + users = User.query.filter_by(tenant_id=tenant_id).all() + + # Render the users in a template + return render_template('user/view_users.html', users=users) + + +@user_bp.route('/handle_user_action', methods=['POST']) +def handle_user_action(): + user_id = request.form['user_id'] + action = request.form['action'] + + if action == 'edit_user': + return redirect(url_for('user_bp.edit_user', user_id=user_id)) + # Add more conditions for other actions + return redirect(url_for('view_users')) diff --git a/requirements.txt b/requirements.txt index e691aec..41d2125 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ Flask~=3.0.3 WTForms~=3.1.2 SQLAlchemy~=2.0.29 -alembic~=1.13.1 \ No newline at end of file +alembic~=1.13.1 +Werkzeug~=3.0.2 \ No newline at end of file