2025-09-07 20:52:19 +02:00
|
|
|
from django.apps import AppConfig
|
Refactor risk management application with enhanced localization, user authentication, and UI improvements
- Added verbose names for Incident and ResidualRisk models for better clarity in admin interface.
- Updated impact choices for ResidualRisk and Risk models to ensure consistency and clarity.
- Implemented gettext_lazy for translatable strings in models and choices.
- Enhanced the Risk, ResidualRisk, Control, AuditLog, and Incident models with Meta options for better admin representation.
- Added login required decorators to views for improved security.
- Introduced new CSS variables and classes for better visual representation of risk levels.
- Created custom template tags for dynamic CSS class assignment based on risk likelihood and impact.
- Improved dashboard and statistics views with user authentication checks.
- Updated templates for risks, controls, incidents, and admin interface to include edit and delete options for staff users.
- Added new login and logout templates for user authentication.
- Enhanced list views for risks, controls, and incidents to include action buttons for staff users.
- Improved overall UI/UX with Bulma CSS framework for a more modern look and feel.
2025-09-09 14:25:59 +02:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2025-09-07 20:52:19 +02:00
|
|
|
|
2025-09-12 13:04:04 +02:00
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
# Risks AppConfig
|
|
|
|
# ---------------------------------------------------------------------------
|
2025-09-07 20:52:19 +02:00
|
|
|
class RisksConfig(AppConfig):
|
2025-09-12 13:04:04 +02:00
|
|
|
"""App configuration for the risks module."""
|
Refactor risk management application with enhanced localization, user authentication, and UI improvements
- Added verbose names for Incident and ResidualRisk models for better clarity in admin interface.
- Updated impact choices for ResidualRisk and Risk models to ensure consistency and clarity.
- Implemented gettext_lazy for translatable strings in models and choices.
- Enhanced the Risk, ResidualRisk, Control, AuditLog, and Incident models with Meta options for better admin representation.
- Added login required decorators to views for improved security.
- Introduced new CSS variables and classes for better visual representation of risk levels.
- Created custom template tags for dynamic CSS class assignment based on risk likelihood and impact.
- Improved dashboard and statistics views with user authentication checks.
- Updated templates for risks, controls, incidents, and admin interface to include edit and delete options for staff users.
- Added new login and logout templates for user authentication.
- Enhanced list views for risks, controls, and incidents to include action buttons for staff users.
- Improved overall UI/UX with Bulma CSS framework for a more modern look and feel.
2025-09-09 14:25:59 +02:00
|
|
|
default_auto_field = "django.db.models.BigAutoField"
|
|
|
|
name = "risks"
|
|
|
|
verbose_name = _("Risk Management")
|
2025-09-07 20:52:19 +02:00
|
|
|
|
|
|
|
def ready(self):
|
2025-09-12 13:04:04 +02:00
|
|
|
"""
|
|
|
|
Initialize signals and ensure NotificationRules exist for all
|
|
|
|
NotificationKind choices. Ignores database errors during migration.
|
|
|
|
"""
|
|
|
|
import risks.signals # noqa: F401 (ensure signal handlers are loaded)
|
2025-09-10 14:26:29 +02:00
|
|
|
|
|
|
|
try:
|
|
|
|
from django.db.utils import OperationalError, ProgrammingError
|
|
|
|
from .models import NotificationRule, NotificationKind
|
2025-09-12 13:04:04 +02:00
|
|
|
|
|
|
|
# Test DB availability
|
2025-09-10 14:26:29 +02:00
|
|
|
NotificationRule.objects.count()
|
|
|
|
except (OperationalError, ProgrammingError):
|
2025-09-12 13:04:04 +02:00
|
|
|
# Happens during migrate or before tables exist
|
2025-09-10 14:26:29 +02:00
|
|
|
return
|
2025-09-12 13:04:04 +02:00
|
|
|
|
|
|
|
# Ensure all NotificationKind values have a corresponding NotificationRule
|
2025-09-10 14:26:29 +02:00
|
|
|
existing = set(NotificationRule.objects.values_list("kind", flat=True))
|
|
|
|
for kind, _label in NotificationKind.choices:
|
|
|
|
if kind not in existing:
|
2025-09-12 13:04:04 +02:00
|
|
|
NotificationRule.objects.create(kind=kind)
|