34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
from django.db import models
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
|
|
class ReportingContractConfig(models.Model):
|
|
"""
|
|
Liste globale des contrats activés pour le reporting.
|
|
Visible et configurable dans la section "Reporting" de l'admin Django.
|
|
|
|
Logique d'accès :
|
|
- admin / top_manager / operator / superuser → voient tous les contrats enabled
|
|
- autres utilisateurs → intersection avec leur UserContractAccess
|
|
"""
|
|
|
|
contract = models.OneToOneField(
|
|
"contracts.Contract",
|
|
on_delete=models.CASCADE,
|
|
related_name="reporting_config",
|
|
verbose_name=_("Contrat"),
|
|
)
|
|
is_enabled = models.BooleanField(
|
|
default=True,
|
|
verbose_name=_("Activé pour le reporting"),
|
|
help_text=_("Si coché, ce contrat est visible dans le dashboard de reporting."),
|
|
)
|
|
|
|
class Meta:
|
|
verbose_name = _("Contrat reportable")
|
|
verbose_name_plural = _("Contrats reportables")
|
|
ordering = ["contract__contract_number"]
|
|
|
|
def __str__(self):
|
|
status = "✓" if self.is_enabled else "✗"
|
|
return f"{status} {self.contract}"
|