Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion conventions/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from conventions.models.choices import ConventionStatut
from conventions.models.piece_jointe import PieceJointe

from .models import AvenantType, Convention, Pret
from .models import AlerteSIAPLog, AvenantType, Convention, Pret


@admin.display(description="Programme")
Expand Down Expand Up @@ -194,3 +194,33 @@ class PretAdmin(ApilosModelAdmin):
class AvenantTypeAdmin(ApilosModelAdmin):
staff_user_can_change = False
staff_user_can_add = False


@admin.register(AlerteSIAPLog)
class AlerteSIAPLogAdmin(ApilosModelAdmin):
staff_user_can_change = False
staff_user_can_add = False
list_display = (
"cree_le",
"convention",
"operation",
"statut",
"description",
"etiquette",
"user_login",
)
list_filter = ("statut", "operation", "cree_le")
search_fields = ("convention__uuid", "description", "user_login", "erreur")
readonly_fields = (
"convention",
"operation",
"statut",
"description",
"destinataires",
"etiquette",
"user_login",
"habilitation_id",
"erreur",
"payload",
"cree_le",
)
67 changes: 67 additions & 0 deletions conventions/migrations/0106_alerte_siap_log.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Generated by Django 5.2.4 on 2026-06-08 12:53

import uuid

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("conventions", "0105_convention_parents"),
]

operations = [
migrations.CreateModel(
name="AlerteSIAPLog",
fields=[
("id", models.AutoField(primary_key=True, serialize=False)),
("uuid", models.UUIDField(default=uuid.uuid4, editable=False)),
(
"operation",
models.CharField(
choices=[
("CREATION", "Création"),
("SUPPRESSION", "Suppression"),
],
max_length=15,
),
),
(
"statut",
models.CharField(
choices=[("ENVOYEE", "Envoyée"), ("ECHEC", "Échec")],
max_length=10,
),
),
("description", models.CharField(max_length=255)),
("destinataires", models.JSONField(blank=True, default=list)),
("etiquette", models.CharField(blank=True, default="", max_length=255)),
(
"user_login",
models.CharField(blank=True, default="", max_length=255),
),
(
"habilitation_id",
models.CharField(blank=True, default="", max_length=255),
),
("erreur", models.TextField(blank=True, default="")),
("payload", models.JSONField(blank=True, null=True)),
("cree_le", models.DateTimeField(auto_now_add=True)),
(
"convention",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="alerte_siap_logs",
to="conventions.convention",
),
),
],
options={
"verbose_name": "Log alerte SIAP",
"verbose_name_plural": "Logs alertes SIAP",
"ordering": ["-cree_le"],
},
),
]
1 change: 1 addition & 0 deletions conventions/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from conventions.models.alerte_siap_log import *
from conventions.models.avenant_type import *
from conventions.models.choices import *
from conventions.models.convention import *
Expand Down
47 changes: 47 additions & 0 deletions conventions/models/alerte_siap_log.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import uuid

from django.db import models


class AlerteSIAPStatut(models.TextChoices):
ENVOYEE = "ENVOYEE", "Envoyée"
ECHEC = "ECHEC", "Échec"


class AlerteSIAPOperation(models.TextChoices):
CREATION = "CREATION", "Création"
SUPPRESSION = "SUPPRESSION", "Suppression"


class AlerteSIAPLog(models.Model):
id = models.AutoField(primary_key=True)
uuid = models.UUIDField(default=uuid.uuid4, editable=False)
convention = models.ForeignKey(
"Convention",
on_delete=models.CASCADE,
related_name="alerte_siap_logs",
)
operation = models.CharField(
max_length=15,
choices=AlerteSIAPOperation.choices,
)
statut = models.CharField(
max_length=10,
choices=AlerteSIAPStatut.choices,
)
description = models.CharField(max_length=255)
destinataires = models.JSONField(default=list, blank=True)
etiquette = models.CharField(max_length=255, blank=True, default="")
user_login = models.CharField(max_length=255, blank=True, default="")
habilitation_id = models.CharField(max_length=255, blank=True, default="")
erreur = models.TextField(blank=True, default="")
payload = models.JSONField(null=True, blank=True)
cree_le = models.DateTimeField(auto_now_add=True)

class Meta:
ordering = ["-cree_le"]
verbose_name = "Log alerte SIAP"
verbose_name_plural = "Logs alertes SIAP"

def __str__(self):
return f"[{self.statut}] {self.operation} - {self.description} ({self.convention_id})"
Loading
Loading