Files
KMH_IT_Assets/assets/context_processors.py
nuexn0x-9 f28983011c feat: implement consumable inventory module, network LAN access, and CI/CD enhancements
- Modul Consumable Item: model master, buku besar transaksi (stock ledger), purchase unit conversion, stock opname, dan transaction reversal
- Integrasi ke Employee Management, Asset Unit, dan tiket/work order
- Konfigurasi akses jaringan lokal (LAN) via 0.0.0.0:8000, ALLOWED_HOSTS, dan CSRF_TRUSTED_ORIGINS otomatis
- Script pembuka firewall Windows (buka_firewall_lan.bat) dan menu interaktif run.bat
- Skema migrasi 0019_consumableitem_consumabletransaction
- Seeder 11 item consumable riil (seed_consumables.py)
- Test suite komprehensif (41 automated tests, 100% lulus)
- Pipeline CI/CD GitHub Actions (.github/workflows/ci.yml)
2026-10-27 09:42:15 +07:00

21 lines
674 B
Python

from assets.permissions import get_user_role, ROLE_ADMIN, ROLE_OPERATOR, ROLE_AUDITOR
def role_context(request):
"""Menyediakan variabel otorisasi role untuk seluruh template antarmuka pengguna."""
if not hasattr(request, 'user') or not request.user.is_authenticated:
return {
'user_role': 'anonymous',
'is_admin': False,
'is_operator': False,
'is_read_only': True,
}
role = get_user_role(request.user)
return {
'user_role': role,
'is_admin': role == ROLE_ADMIN,
'is_operator': role in (ROLE_ADMIN, ROLE_OPERATOR),
'is_read_only': role == ROLE_AUDITOR,
}