- Consent giving UI introduced

- Possibility to view the document version the consent is given to
- Blocking functionality is no valid consent
This commit is contained in:
Josako
2025-10-15 18:35:28 +02:00
parent 3ea3a06de6
commit eeb76d57b7
22 changed files with 803 additions and 126 deletions

View File

@@ -177,52 +177,6 @@ class TenantServices:
@staticmethod
def get_consent_status(tenant_id: int) -> ConsentStatus:
cts = current_app.config.get("CONSENT_TYPES")
status = ConsentStatus.CONSENTED
for ct in cts:
consent = (TenantConsent.query.filter_by(tenant_id=tenant_id, consent_type=ct)
.order_by(desc(TenantConsent.id))
.first())
if not consent:
status = ConsentStatus.NOT_CONSENTED
break
cv = ConsentVersion.query.filter_by(consent_type=ct, consent_version=consent.consent_version).first()
if not cv:
current_app.logger.error(f"Consent version {consent.consent_version} not found checking tenant {tenant_id}")
status = ConsentStatus.UNKNOWN_CONSENT_VERSION
break
if cv.consent_valid_to:
if cv.consent_valid_to.date() >= dt.now(tz.utc).date():
status = ConsentStatus.RENEWAL_REQUIRED
break
else:
status = ConsentStatus.NOT_CONSENTED
break
return status
@staticmethod
def get_consent_status_details(tenant_id: int) -> Dict[str, str]:
cts = current_app.config.get("CONSENT_TYPES")
details = {}
for ct in cts:
ct = cv.consent_type
consent = (TenantConsent.query.filter_by(tenant_id=tenant_id, consent_type=ct)
.order_by(desc(TenantConsent.id))
.first())
if not consent:
details[ct] = {
'status': str(ConsentStatus.NOT_CONSENTED),
'version': str(cv.consent_version)
}
continue
if cv.consent_valid_to.date >= dt.now(tz.utc).date():
details[ct] = {
'status': str(ConsentStatus.RENEWAL_REQUIRED),
'version': str(cv.consent_version)
}
details[ct] = {
'status': str(ConsentStatus.CONSENTED),
'version': str(cv.consent_version)
}
# Delegate to centralized ConsentService to ensure consistent logic
from common.services.user.consent_service import ConsentService
return ConsentService.get_consent_status(tenant_id)