Skip to content

Commit

Permalink
Merge pull request #1157 from betagouv/objection-pdf
Browse files Browse the repository at this point in the history
Génère le certificat d'objection.
  • Loading branch information
pletelli authored Oct 22, 2024
2 parents 04bdbd6 + cecf808 commit 202739c
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 23 deletions.
10 changes: 1 addition & 9 deletions api/serializers/declaration.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
Plant,
PlantPart,
Population,
Snapshot,
Substance,
SubstanceUnit,
)
Expand Down Expand Up @@ -322,7 +321,7 @@ class DeclarationSerializer(serializers.ModelSerializer):
computed_substances = DeclaredListSerializer(child=ComputedSubstanceSerializer(), required=False)
attachments = DeclaredListSerializer(child=AttachmentSerializer(), required=False)
name = serializers.CharField(allow_blank=False, required=True)
blocking_reasons = serializers.SerializerMethodField(read_only=True)
blocking_reasons = serializers.ListField(read_only=True)

class Meta:
model = Declaration
Expand Down Expand Up @@ -469,13 +468,6 @@ def to_representation(self, obj):
ret.pop("private_notes")
return ret

def get_blocking_reasons(self, obj):
try:
latest_snapshot = obj.snapshots.filter(blocking_reasons__isnull=False).latest("creation_date")
return latest_snapshot.blocking_reasons
except Snapshot.DoesNotExist:
return None


class DeclarationShortSerializer(serializers.ModelSerializer):
author = SimpleUserSerializer(read_only=True)
Expand Down
10 changes: 10 additions & 0 deletions data/models/declaration.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,16 @@ def create_snapshot(
blocking_reasons=blocking_reasons,
)

@property
def blocking_reasons(self):
from data.models import Snapshot

try:
latest_snapshot = self.snapshots.filter(blocking_reasons__isnull=False).latest("creation_date")
return latest_snapshot.blocking_reasons
except Snapshot.DoesNotExist:
return None

@property
def json_representation(self):
from api.serializers import DeclarationSerializer
Expand Down
18 changes: 9 additions & 9 deletions frontend/src/components/DeclarationAlert.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ const declarantDisplayData = computed(() => {
case "OBJECTION":
return {
type: "warning",
title: "Une objection a été emise sur cette déclaration",
title: "Une objection a été émise sur cette déclaration",
expirationDate: props.declaration?.expirationDate,
body: blockingReasons.value,
canDownloadCertificate: false,
canDownloadCertificate: true,
}
case "OBSERVATION":
return {
type: "warning",
title: "Une observation a été emise sur cette déclaration",
title: "Une observation a été émise sur cette déclaration",
expirationDate: props.declaration?.expirationDate,
body: blockingReasons.value,
canDownloadCertificate: false,
Expand Down Expand Up @@ -125,14 +125,14 @@ const instructorDisplayData = computed(() => {
case "OBJECTION":
return {
type: "info",
title: "Une objection a été emise sur cette déclaration",
title: "Une objection a été émise sur cette déclaration",
body: blockingReasons.value,
canDownloadCertificate: false,
canDownloadCertificate: true,
}
case "OBSERVATION":
return {
type: "warning",
title: "Une observation a été emise sur cette déclaration",
title: "Une observation a été émise sur cette déclaration",
body: blockingReasons.value,
canDownloadCertificate: false,
}
Expand Down Expand Up @@ -181,14 +181,14 @@ const visorDisplayData = computed(() => {
case "OBJECTION":
return {
type: "info",
title: "Une objection a été emise sur cette déclaration",
title: "Une objection a été émise sur cette déclaration",
body: blockingReasons.value,
canDownloadCertificate: false,
canDownloadCertificate: true,
}
case "OBSERVATION":
return {
type: "warning",
title: "Une observation a été emise sur cette déclaration",
title: "Une observation a été émise sur cette déclaration",
body: blockingReasons.value,
canDownloadCertificate: false,
}
Expand Down
47 changes: 47 additions & 0 deletions web/templates/certificates/certificate-objected.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{% extends 'certificates/certificate-base-template.html' %}
{% block 'body' %}
<h1 style="font-family: 'Marianne-Bold'; font-weight: bold;">
Réf. : Dossier n° {{declaration.id}}
</h1>
<div style="font-size: 1.2em;">
<p>
Madame, Monsieur,
</p>
<p>
Le {{ last_submission_date|date:"l j F Y" }}, vous avez déclaré la mise sur le marché du produit :
<span style="font-family: 'Marianne-Bold'; font-weight: bold;">
{{ declaration.name }} / {{ declaration.galenic_formulation }}
</span>
<p>
L’examen de cette déclaration soulève les objections suivantes, qui la rendent irrecevable :
<span style="font-family: 'Marianne-Bold'; font-weight: bold;">
<br>
{% for reason in declaration.blocking_reasons %}
- {{ reason }}<br>
{% endfor %}
</span>

</p>
<p>
Vous disposez d’un délai de 30 jours francs, à compter de la date de réception de la présente lettre, pour régulariser votre déclaration ou me faire part de vos observations.
Vous pouvez vous faire assister ou représenter par le conseil de votre choix.
</p>
<p>
En l’absence de réponse de votre part dans ce délai, le dossier sera clos et la déclaration sera réputée rejetée.
</p>
<p>
Je vous rappelle, à toutes fins utiles, que l’article 20 du décret du décret du 20 mars 2006 précité vous interdit d’importer pour la mise en libre pratique,
de détenir en vue de la vente ou de la distribution à titre gratuit, de mettre en vente, de vendre ou de distribuer à titre gratuit un complément alimentaire qui n’a pas été dûment déclaré.
</p>
<p>
Je vous prie d’agréer, Madame, Monsieur, l’expression de ma considération distinguée.
</p>
<p style="padding-left: 10cm;">
La Sous-Directrice de la sécurité sanitaire<br />
des aliments
</p>
<p style="padding-left: 10cm;">
Vanessa HUMMEL-FOURRAT
</p>
</div>
{% endblock %}
10 changes: 5 additions & 5 deletions web/templates/certificates/certificate-rejected.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends 'certificates/certificate-base-template.html' %}
{% block 'body' %}
<h1 style="font-family: 'Marianne-Bold'; font-weight: bold;">
Réf. : n° {{declaration.id}}
Réf. : Dossier n° {{declaration.id}}
</h1>
<div style="font-size: 1.2em;">
<p>
Expand All @@ -10,14 +10,14 @@ <h1 style="font-family: 'Marianne-Bold'; font-weight: bold;">
<p>
Le {{ last_submission_date|date:"l j F Y" }}, vous avez déclaré la mise sur le marché du produit :
<span style="font-family: 'Marianne-Bold'; font-weight: bold;">
{{ declaration.name }}
{{ declaration.name }} / {{ declaration.galenic_formulation }}
</span>
<p>
Des objections ont été émises à l’égard de cette déclaration. Aucune observation apportée n'a
été de nature à remettre en cause les objections opposées à la déclaration
Des objections ont été émises à l’égard de cette déclaration. Toutefois, les éléments apportés
à cette occasion ne sont pas de nature à remettre en cause les objections opposées à la déclaration.
</p>
<p>
Votre déclaration est donc refusée. En application de l’article 20 du décret n°2006-352 du décret du 20 mars 2006,
Votre déclaration est donc refusée. En application de l’article 20 du décret n°2006-352 du 20 mars 2006,
il vous est interdit d’importer pour la mise en libre pratique, de détenir en vue de la vente ou de la distribution à
titre gratuit, de mettre en vente, de vendre ou de distribuer à titre gratuit le complément alimentaire cité ci-dessus.
</p>
Expand Down
2 changes: 2 additions & 0 deletions web/views/certificate.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def get_template_path(self, declaration):
return f"certificates/certificate-submitted-art-{article}.html"
if declaration.status in [status.AUTHORIZED, status.WITHDRAWN]:
return f"certificates/certificate-art-{article}.html"
if declaration.status == status.OBJECTION:
return "certificates/certificate-objected.html"
if declaration.status == status.REJECTED:
return "certificates/certificate-rejected.html"

Expand Down

0 comments on commit 202739c

Please sign in to comment.