Skip to content

Commit

Permalink
blocking reason is a declaration property + wording
Browse files Browse the repository at this point in the history
  • Loading branch information
Perrine Letellier committed Oct 21, 2024
1 parent ea38179 commit cecf808
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 24 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
16 changes: 8 additions & 8 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: 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
14 changes: 9 additions & 5 deletions web/templates/certificates/certificate-objected.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,13 +10,17 @@ <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>
L’examen de cette déclaration soulève les objections suivantes, qui la rendent irrecevable:
<span style="font-family: 'Marianne-Bold'; font-weight: bold;"></span>
{{ declaration.objection }}
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.
Expand Down
4 changes: 2 additions & 2 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,7 +10,7 @@ <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. Toutefois, les éléments apportés
Expand Down

0 comments on commit cecf808

Please sign in to comment.