- eveai_app adapted to handle removal of complex rewrite rules in nginx.conf, which cannot be achieved in Ingress
This commit is contained in:
@@ -48,7 +48,7 @@ def tenant():
|
||||
if not UserServices.can_user_create_tenant():
|
||||
current_app.logger.error(f'User {current_user.email} cannot create tenant')
|
||||
flash(f"You don't have the appropriate permissions to create a tenant", 'danger')
|
||||
return redirect(prefixed_url_for('user_bp.tenants'))
|
||||
return redirect(prefixed_url_for('user_bp.tenants', for_redirect=True))
|
||||
form = TenantForm()
|
||||
if request.method == 'GET':
|
||||
code = f"TENANT-{str(uuid.uuid4())}"
|
||||
@@ -107,7 +107,7 @@ def tenant():
|
||||
current_app.logger.info(f"Creating MinIO bucket for tenant {new_tenant.id}")
|
||||
minio_client.create_tenant_bucket(new_tenant.id)
|
||||
|
||||
return redirect(prefixed_url_for('user_bp.tenants'))
|
||||
return redirect(prefixed_url_for('user_bp.tenants', for_redirect=True))
|
||||
else:
|
||||
form_validation_failed(request, form)
|
||||
|
||||
@@ -155,14 +155,14 @@ def tenants():
|
||||
def handle_tenant_selection():
|
||||
action = request.form['action']
|
||||
if action == 'create_tenant':
|
||||
return redirect(prefixed_url_for('user_bp.tenant'))
|
||||
return redirect(prefixed_url_for('user_bp.tenant', for_redirect=True))
|
||||
|
||||
tenant_identification = request.form['selected_row']
|
||||
tenant_id = ast.literal_eval(tenant_identification).get('value')
|
||||
if not UserServices.can_user_edit_tenant(tenant_id):
|
||||
current_app.logger.info(f"User not authenticated to edit tenant {tenant_id}.")
|
||||
flash(f"You are not authenticated to manage tenant {tenant_id}", 'danger')
|
||||
return redirect(prefixed_url_for('user_bp.tenants'))
|
||||
return redirect(prefixed_url_for('user_bp.tenants', for_redirect=True))
|
||||
the_tenant = Tenant.query.get(tenant_id)
|
||||
|
||||
# set tenant information in the session
|
||||
@@ -173,12 +173,12 @@ def handle_tenant_selection():
|
||||
|
||||
match action:
|
||||
case 'edit_tenant':
|
||||
return redirect(prefixed_url_for('user_bp.edit_tenant', tenant_id=tenant_id))
|
||||
return redirect(prefixed_url_for('user_bp.edit_tenant', tenant_id=tenant_id, for_redirect=True))
|
||||
case 'select_tenant':
|
||||
return redirect(prefixed_url_for('user_bp.tenant_overview'))
|
||||
return redirect(prefixed_url_for('user_bp.tenant_overview', for_redirect=True))
|
||||
|
||||
# Add more conditions for other actions
|
||||
return redirect(prefixed_url_for('tenants'))
|
||||
return redirect(prefixed_url_for('tenants', for_redirect=True))
|
||||
|
||||
|
||||
@user_bp.route('/tenant_overview', methods=['GET'])
|
||||
@@ -244,7 +244,7 @@ def user():
|
||||
flash('User added successfully, but failed to send confirmation email. '
|
||||
'Please contact the administrator.', 'warning')
|
||||
|
||||
return redirect(prefixed_url_for('user_bp.view_users'))
|
||||
return redirect(prefixed_url_for('user_bp.view_users', for_redirect=True))
|
||||
except Exception as e:
|
||||
current_app.logger.error(f'Failed to add user with name {new_user.user_name}. Error: {str(e)}')
|
||||
db.session.rollback()
|
||||
@@ -286,13 +286,13 @@ def edit_user(user_id):
|
||||
flash('Trying to assign unauthorized roles', 'danger')
|
||||
current_app.logger.error(f"Trying to assign unauthorized roles by user {user_id},"
|
||||
f"tenant {session['tenant']['id']}")
|
||||
return redirect(prefixed_url_for('user_bp.edit_user', user_id=user_id))
|
||||
return redirect(prefixed_url_for('user_bp.edit_user', user_id=user_id, for_redirect=True))
|
||||
|
||||
db.session.commit()
|
||||
flash('User updated successfully.', 'success')
|
||||
return redirect(
|
||||
prefixed_url_for('user_bp.edit_user',
|
||||
user_id=user.id)) # Assuming there's a user profile view to redirect to
|
||||
user_id=user.id, for_redirect=True)) # Assuming there's a user profile view to redirect to
|
||||
else:
|
||||
form_validation_failed(request, form)
|
||||
|
||||
@@ -314,14 +314,14 @@ def view_users():
|
||||
def handle_user_action():
|
||||
action = request.form['action']
|
||||
if action == 'create_user':
|
||||
return redirect(prefixed_url_for('user_bp.user'))
|
||||
return redirect(prefixed_url_for('user_bp.user', for_redirect=True))
|
||||
|
||||
user_identification = request.form['selected_row']
|
||||
user_id = ast.literal_eval(user_identification).get('value')
|
||||
user = User.query.get_or_404(user_id)
|
||||
|
||||
if action == 'edit_user':
|
||||
return redirect(prefixed_url_for('user_bp.edit_user', user_id=user_id))
|
||||
return redirect(prefixed_url_for('user_bp.edit_user', user_id=user_id, for_redirect=True))
|
||||
elif action == 'resend_confirmation_email':
|
||||
send_confirmation_email(user)
|
||||
flash(f'Confirmation email sent to {user.email}.', 'success')
|
||||
@@ -332,7 +332,7 @@ def handle_user_action():
|
||||
reset_uniquifier(user)
|
||||
flash(f'Uniquifier reset for {user.user_name}.', 'success')
|
||||
|
||||
return redirect(prefixed_url_for('user_bp.view_users'))
|
||||
return redirect(prefixed_url_for('user_bp.view_users', for_redirect=True))
|
||||
|
||||
|
||||
# Tenant Domain Management (Probably obsolete )------------------------------------------------------------------------
|
||||
@@ -349,15 +349,15 @@ def tenant_domains():
|
||||
def handle_tenant_domain_action():
|
||||
action = request.form['action']
|
||||
if action == 'create_tenant_domain':
|
||||
return redirect(prefixed_url_for('user_bp.tenant_domain'))
|
||||
return redirect(prefixed_url_for('user_bp.tenant_domain', for_redirect=True))
|
||||
|
||||
tenant_domain_identification = request.form['selected_row']
|
||||
tenant_domain_id = ast.literal_eval(tenant_domain_identification).get('value')
|
||||
|
||||
if action == 'edit_tenant_domain':
|
||||
return redirect(prefixed_url_for('user_bp.edit_tenant_domain', tenant_domain_id=tenant_domain_id))
|
||||
return redirect(prefixed_url_for('user_bp.edit_tenant_domain', tenant_domain_id=tenant_domain_id, for_redirect=True))
|
||||
# Add more conditions for other actions
|
||||
return redirect(prefixed_url_for('tenant_domains'))
|
||||
return redirect(prefixed_url_for('tenant_domains', for_redirect=True))
|
||||
|
||||
|
||||
@user_bp.route('/tenant_domain', methods=['GET', 'POST'])
|
||||
@@ -410,7 +410,7 @@ def edit_tenant_domain(tenant_domain_id):
|
||||
f'Error: {str(e)}')
|
||||
return redirect(
|
||||
prefixed_url_for('user_bp.tenant_domains',
|
||||
tenant_id=session['tenant']['id'])) # Assuming there's a user profile view to redirect to
|
||||
tenant_id=session['tenant']['id'], for_redirect=True)) # Assuming there's a user profile view to redirect to
|
||||
else:
|
||||
form_validation_failed(request, form)
|
||||
|
||||
@@ -461,7 +461,7 @@ def tenant_project():
|
||||
|
||||
current_app.logger.info(f'Tenant Project {new_tenant_project.name} added for tenant '
|
||||
f'{session['tenant']['id']}.')
|
||||
return redirect(prefixed_url_for('user_bp.tenant_projects'))
|
||||
return redirect(prefixed_url_for('user_bp.tenant_projects', for_redirect=True))
|
||||
except SQLAlchemyError as e:
|
||||
db.session.rollback()
|
||||
flash(f'Failed to create Tenant Project. Error: {str(e)}', 'danger')
|
||||
@@ -484,13 +484,13 @@ def tenant_projects():
|
||||
def handle_tenant_project_selection():
|
||||
action = request.form.get('action')
|
||||
if action == 'create_tenant_project':
|
||||
return redirect(prefixed_url_for('user_bp.tenant_project'))
|
||||
return redirect(prefixed_url_for('user_bp.tenant_project', for_redirect=True))
|
||||
tenant_project_identification = request.form.get('selected_row')
|
||||
tenant_project_id = ast.literal_eval(tenant_project_identification).get('value')
|
||||
tenant_project = TenantProject.query.get_or_404(tenant_project_id)
|
||||
|
||||
if action == 'edit_tenant_project':
|
||||
return redirect(prefixed_url_for('user_bp.edit_tenant_project', tenant_project_id=tenant_project_id))
|
||||
return redirect(prefixed_url_for('user_bp.edit_tenant_project', tenant_project_id=tenant_project_id, for_redirect=True))
|
||||
elif action == 'invalidate_tenant_project':
|
||||
tenant_project.active = False
|
||||
try:
|
||||
@@ -505,9 +505,9 @@ def handle_tenant_project_selection():
|
||||
current_app.logger.error(f"Failed to invalidate Tenant Project for tenant {session['tenant']['id']}. "
|
||||
f"Error: {str(e)}")
|
||||
elif action == 'delete_tenant_project':
|
||||
return redirect(prefixed_url_for('user_bp.delete_tenant_project', tenant_project_id=tenant_project_id))
|
||||
return redirect(prefixed_url_for('user_bp.delete_tenant_project', tenant_project_id=tenant_project_id, for_redirect=True))
|
||||
|
||||
return redirect(prefixed_url_for('user_bp.tenant_projects'))
|
||||
return redirect(prefixed_url_for('user_bp.tenant_projects', for_redirect=True))
|
||||
|
||||
|
||||
@user_bp.route('/tenant_project/<int:tenant_project_id>', methods=['GET', 'POST'])
|
||||
@@ -527,7 +527,7 @@ def edit_tenant_project(tenant_project_id):
|
||||
db.session.commit()
|
||||
flash('Tenant Project updated successfully.', 'success')
|
||||
current_app.logger.info(f'Tenant Project {tenant_project.name} updated for tenant {tenant_id}.')
|
||||
return redirect(prefixed_url_for('user_bp.tenant_projects'))
|
||||
return redirect(prefixed_url_for('user_bp.tenant_projects', for_redirect=True))
|
||||
except SQLAlchemyError as e:
|
||||
db.session.rollback()
|
||||
flash(f'Failed to update Tenant Project. Error: {str(e)}', 'danger')
|
||||
@@ -545,7 +545,7 @@ def delete_tenant_project(tenant_project_id):
|
||||
# Ensure project belongs to current tenant
|
||||
if tenant_project.tenant_id != tenant_id:
|
||||
flash('You do not have permission to delete this project.', 'danger')
|
||||
return redirect(prefixed_url_for('user_bp.tenant_projects'))
|
||||
return redirect(prefixed_url_for('user_bp.tenant_projects', for_redirect=True))
|
||||
|
||||
if request.method == 'GET':
|
||||
return render_template('user/confirm_delete_tenant_project.html',
|
||||
@@ -562,7 +562,7 @@ def delete_tenant_project(tenant_project_id):
|
||||
flash(f'Failed to delete Tenant Project. Error: {str(e)}', 'danger')
|
||||
current_app.logger.error(f'Failed to delete Tenant Project {tenant_project_id}. Error: {str(e)}')
|
||||
|
||||
return redirect(prefixed_url_for('user_bp.tenant_projects'))
|
||||
return redirect(prefixed_url_for('user_bp.tenant_projects', for_redirect=True))
|
||||
|
||||
|
||||
# Tenant Make Management --------------------------------------------------------------------------
|
||||
@@ -589,7 +589,7 @@ def tenant_make():
|
||||
current_app.logger.info(f'Tenant Make {new_tenant_make.name}, id {new_tenant_make.id} successfully added '
|
||||
f'for tenant {tenant_id}!')
|
||||
# Enable step 2 of creation of retriever - add configuration of the retriever (dependent on type)
|
||||
return redirect(prefixed_url_for('user_bp.edit_tenant_make', tenant_make_id=new_tenant_make.id))
|
||||
return redirect(prefixed_url_for('user_bp.edit_tenant_make', tenant_make_id=new_tenant_make.id, for_redirect=True))
|
||||
except SQLAlchemyError as e:
|
||||
db.session.rollback()
|
||||
flash(f'Failed to add Tenant Make. Error: {e}', 'danger')
|
||||
@@ -647,7 +647,7 @@ def edit_tenant_make(tenant_make_id):
|
||||
current_app.logger.error(f'Failed to update tenant make {tenant_make_id}. Error: {str(e)}')
|
||||
return render_template('user/edit_tenant_make.html', form=form, tenant_make_id=tenant_make_id)
|
||||
|
||||
return redirect(prefixed_url_for('user_bp.tenant_makes'))
|
||||
return redirect(prefixed_url_for('user_bp.tenant_makes', for_redirect=True))
|
||||
else:
|
||||
form_validation_failed(request, form)
|
||||
|
||||
@@ -659,12 +659,12 @@ def edit_tenant_make(tenant_make_id):
|
||||
def handle_tenant_make_selection():
|
||||
action = request.form['action']
|
||||
if action == 'create_tenant_make':
|
||||
return redirect(prefixed_url_for('user_bp.tenant_make'))
|
||||
return redirect(prefixed_url_for('user_bp.tenant_make', for_redirect=True))
|
||||
tenant_make_identification = request.form.get('selected_row')
|
||||
tenant_make_id = ast.literal_eval(tenant_make_identification).get('value')
|
||||
|
||||
if action == 'edit_tenant_make':
|
||||
return redirect(prefixed_url_for('user_bp.edit_tenant_make', tenant_make_id=tenant_make_id))
|
||||
return redirect(prefixed_url_for('user_bp.edit_tenant_make', tenant_make_id=tenant_make_id, for_redirect=True))
|
||||
elif action == 'set_as_default':
|
||||
# Set this make as the default for the tenant
|
||||
tenant_id = session['tenant']['id']
|
||||
@@ -682,7 +682,7 @@ def handle_tenant_make_selection():
|
||||
current_app.logger.error(f'Failed to update default tenant make. Error: {str(e)}')
|
||||
|
||||
# Altijd teruggaan naar de tenant_makes pagina
|
||||
return redirect(prefixed_url_for('user_bp.tenant_makes'))
|
||||
return redirect(prefixed_url_for('user_bp.tenant_makes', for_redirect=True))
|
||||
|
||||
|
||||
@user_bp.route('/tenant_partner_services', methods=['GET', 'POST'])
|
||||
|
||||
Reference in New Issue
Block a user