fix(zopk): Use is_admin instead of role=='admin' for admin gating
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Role field stores uppercase 'ADMIN' (from SystemRole enum). Use is_admin boolean property which is synced by set_role() for reliable checks. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
30bb960a03
commit
c681cbbea2
@ -115,7 +115,7 @@ def index():
|
||||
|
||||
# ZOPK Knowledge facts — admin only widget
|
||||
zopk_facts = []
|
||||
if current_user.role == 'admin':
|
||||
if current_user.is_admin:
|
||||
try:
|
||||
from database import ZOPKKnowledgeFact, ZOPKNews
|
||||
zopk_facts = db.query(ZOPKKnowledgeFact).join(ZOPKNews).filter(
|
||||
|
||||
@ -102,7 +102,7 @@ def zopk_index():
|
||||
|
||||
# Knowledge data — admin only
|
||||
knowledge_data = None
|
||||
if current_user.is_authenticated and current_user.role == 'admin':
|
||||
if current_user.is_authenticated and current_user.is_admin:
|
||||
knowledge_data = {
|
||||
'total_facts': db.query(func.count(ZOPKKnowledgeFact.id)).scalar(),
|
||||
'total_entities': db.query(func.count(ZOPKKnowledgeEntity.id)).filter(
|
||||
|
||||
@ -953,7 +953,7 @@
|
||||
</div>
|
||||
|
||||
<!-- ZOPK Knowledge Widget — admin only -->
|
||||
{% if current_user.is_authenticated and current_user.role == 'admin' and zopk_facts %}
|
||||
{% if current_user.is_authenticated and current_user.is_admin and zopk_facts %}
|
||||
<div style="background: linear-gradient(135deg, #059669 0%, #047857 50%, #065f46 100%); border-radius: var(--radius-lg); padding: var(--spacing-lg); margin-bottom: var(--spacing-xl); color: white;" data-animate="fadeIn">
|
||||
<div style="display: flex; align-items: center; gap: var(--spacing-sm); margin-bottom: var(--spacing-md);">
|
||||
<span style="font-size: 1.5rem;">💡</span>
|
||||
|
||||
@ -979,7 +979,7 @@
|
||||
</div>
|
||||
|
||||
<!-- Knowledge Section — admin only -->
|
||||
{% if current_user.is_authenticated and current_user.role == 'admin' and knowledge_data %}
|
||||
{% if current_user.is_authenticated and current_user.is_admin and knowledge_data %}
|
||||
<section>
|
||||
<div class="section-header">
|
||||
<h2>Wiedza o regionie (baza wiedzy AI)</h2>
|
||||
@ -1345,7 +1345,7 @@
|
||||
{% endif %}
|
||||
|
||||
<!-- Knowledge Graph — admin only -->
|
||||
{% if current_user.is_authenticated and current_user.role == 'admin' and knowledge_data %}
|
||||
{% if current_user.is_authenticated and current_user.is_admin and knowledge_data %}
|
||||
<section>
|
||||
<div class="section-header">
|
||||
<h2>Graf współwystępowania encji</h2>
|
||||
@ -1375,7 +1375,7 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_js %}
|
||||
{% if current_user.is_authenticated and current_user.role == 'admin' and knowledge_data %}
|
||||
{% if current_user.is_authenticated and current_user.is_admin and knowledge_data %}
|
||||
// Knowledge Graph — D3.js
|
||||
(function() {
|
||||
if (typeof d3 === 'undefined') {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user