- Show markdown when signing a document
- Introduce consent history - Centralise consent and content services and config
This commit is contained in:
@@ -4,11 +4,12 @@ from sqlalchemy.exc import SQLAlchemyError
|
||||
import ast
|
||||
|
||||
from common.models.user import Tenant, User, TenantDomain, TenantProject, TenantMake, PartnerTenant, PartnerService, \
|
||||
ConsentVersion
|
||||
ConsentVersion, TenantConsent, Partner
|
||||
from common.services.user import UserServices, PartnerServices
|
||||
from common.utils.eveai_exceptions import EveAINoSessionPartner, EveAINoManagementPartnerService
|
||||
from common.utils.security_utils import current_user_has_role
|
||||
from eveai_app.views.list_views.list_view_utils import render_list_view
|
||||
from common.extensions import db
|
||||
|
||||
# Tenant list view helper
|
||||
def get_tenants_list_view():
|
||||
@@ -376,3 +377,63 @@ def get_consent_versions_list_view():
|
||||
'description': f'Consent Versions'
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Tenant Consents history list view helper
|
||||
|
||||
def get_tenant_consents_list_view(tenant_id):
|
||||
"""Generate the tenant consents history list view configuration for a specific tenant"""
|
||||
# Build query joining optional partner->tenant for partner name and user for user name
|
||||
q = db.session.query(
|
||||
TenantConsent.id,
|
||||
TenantConsent.consent_type,
|
||||
TenantConsent.consent_date,
|
||||
TenantConsent.consent_version,
|
||||
User.user_name.label('user_name'),
|
||||
Tenant.name.label('partner_name')
|
||||
).join(User, User.id == TenantConsent.user_id)
|
||||
# Left join Partner and its Tenant to get the partner tenant name
|
||||
q = q.outerjoin(Partner, Partner.id == TenantConsent.partner_id)
|
||||
q = q.outerjoin(Tenant, Tenant.id == Partner.tenant_id)
|
||||
q = q.filter(TenantConsent.tenant_id == tenant_id).order_by(TenantConsent.consent_date.desc())
|
||||
|
||||
rows = q.all()
|
||||
|
||||
data = []
|
||||
for r in rows:
|
||||
partner_name = r.partner_name if r.partner_name else '-'
|
||||
data.append({
|
||||
'id': r.id,
|
||||
'consent_type': r.consent_type,
|
||||
'consent_date': r.consent_date.isoformat() if hasattr(r.consent_date, 'isoformat') else str(r.consent_date),
|
||||
'consent_version': r.consent_version,
|
||||
'user_name': r.user_name,
|
||||
'partner_name': partner_name,
|
||||
})
|
||||
|
||||
columns = [
|
||||
{'title': 'ID', 'field': 'id', 'width': 80},
|
||||
{'title': 'Type', 'field': 'consent_type'},
|
||||
{'title': 'Date', 'field': 'consent_date'},
|
||||
{'title': 'Version', 'field': 'consent_version'},
|
||||
{'title': 'User', 'field': 'user_name'},
|
||||
{'title': 'Partner', 'field': 'partner_name'},
|
||||
]
|
||||
|
||||
# Only a view action as records are immutable; handled via a POST -> redirect in the view handler
|
||||
actions = [
|
||||
{'value': 'view_consent_document', 'text': 'Bekijk document', 'class': 'btn-outline-secondary', 'requiresSelection': True},
|
||||
]
|
||||
|
||||
initial_sort = [{'column': 'consent_date', 'dir': 'desc'}]
|
||||
|
||||
return {
|
||||
'title': 'Tenant Consents History',
|
||||
'data': data,
|
||||
'columns': columns,
|
||||
'actions': actions,
|
||||
'initial_sort': initial_sort,
|
||||
'table_id': 'tenant_consents_history_table',
|
||||
'form_action': url_for('user_bp.handle_tenant_consents_history_selection'),
|
||||
'description': f'Consent history for tenant {tenant_id}'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user