Skip to content

Commit

Permalink
dashboard: conditional admonition
Browse files Browse the repository at this point in the history
  • Loading branch information
xavfernandez committed Jun 13, 2024
1 parent d3bad95 commit 015dbff
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 17 deletions.
30 changes: 16 additions & 14 deletions itou/templates/dashboard/includes/employer_geiq_card.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,25 @@
</a>
</li>
</ul>
<div class="alert alert-info" role="status">
<p class="mb-0"></p>
{% if not last_geiq_execution_assessment.submitted_at %}
<div class="alert alert-info" role="status">
<p class="mb-0"></p>

<div class="row">
<div class="col-auto pe-0">
<i class="ri-information-line ri-xl text-important" aria-hidden="true"></i>
</div>
<div class="col">
<p class="mb-2">
<strong>Validez votre bilan {{ last_geiq_execution_assessment.campaign.year }}</strong>
</p>
<p class="mb-0">
Vous avez jusqu’au {{ last_geiq_execution_assessment.campaign.submission_deadline|date:"d/m/Y" }} pour valider le dossier de votre bilan d’exécution qui sera automatiquement transmis à votre DDETS/DREETS.
</p>
<div class="row">
<div class="col-auto pe-0">
<i class="ri-information-line ri-xl text-important" aria-hidden="true"></i>
</div>
<div class="col">
<p class="mb-2">
<strong>Validez votre bilan {{ last_geiq_execution_assessment.campaign.year }}</strong>
</p>
<p class="mb-0">
Vous avez jusqu’au {{ last_geiq_execution_assessment.campaign.submission_deadline|date:"d/m/Y" }} pour valider le dossier de votre bilan d’exécution qui sera automatiquement transmis à votre DDETS/DREETS.
</p>
</div>
</div>
</div>
</div>
{% endif %}
</div>
</div>
</div>
28 changes: 25 additions & 3 deletions tests/www/dashboard/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
CompanyPendingGracePeriodFactory,
)
from tests.employee_record.factories import EmployeeRecordFactory
from tests.files.factories import FileFactory
from tests.geiq.factories import ImplementationAssessmentCampaignFactory, ImplementationAssessmentFactory
from tests.institutions.factories import InstitutionFactory, InstitutionMembershipFactory, LaborInspectorFactory
from tests.job_applications.factories import JobApplicationFactory, JobApplicationSentByPrescriberFactory
Expand Down Expand Up @@ -91,7 +92,6 @@ class DashboardViewTest(ParametrizedTestCase, TestCase):
HIRE_LINK_LABEL = "Déclarer une embauche"
DORA_LABEL = "DORA"
DORA_CARD_MSG = "Consultez l’offre de service de vos partenaires"
IMPLEMENTATION_ASSESSMENT = "Bilan d’exécution & salariés"

@staticmethod
def apply_start_url(company):
Expand Down Expand Up @@ -789,6 +789,8 @@ def test_institution_with_geiq_assessment_campaign(

@freeze_time("2024-03-10")
def test_geiq_implement_assessment_card(self):
IMPLEMENTATION_ASSESSMENT = "Bilan d’exécution & salariés"
VALIDATE_ADMONITION = "Validez votre bilan"
campaign = ImplementationAssessmentCampaignFactory(
year=2022,
submission_deadline=date(2023, 7, 1),
Expand All @@ -798,20 +800,40 @@ def test_geiq_implement_assessment_card(self):
user = membership.user
self.client.force_login(user)
response = self.client.get(reverse("dashboard:index"))
self.assertNotContains(response, self.IMPLEMENTATION_ASSESSMENT)
self.assertNotContains(response, IMPLEMENTATION_ASSESSMENT)
self.assertNotContains(response, VALIDATE_ADMONITION)
assessment = ImplementationAssessmentFactory(campaign=campaign, company=membership.company)
response = self.client.get(reverse("dashboard:index"))
self.assertContains(response, self.IMPLEMENTATION_ASSESSMENT)
self.assertContains(response, IMPLEMENTATION_ASSESSMENT)
self.assertContains(response, VALIDATE_ADMONITION)
self.assertContains(response, reverse("geiq:assessment_info", kwargs={"assessment_pk": assessment.pk}))
self.assertContains(
response,
reverse(
"geiq:employee_list", kwargs={"assessment_pk": assessment.pk, "info_type": "personal-information"}
),
)
assessment.last_synced_at = timezone.now()
assessment.submitted_at = timezone.now()
assessment.activity_report_file = FileFactory()
assessment.save()
# submitted assessment
response = self.client.get(reverse("dashboard:index"))
self.assertContains(response, IMPLEMENTATION_ASSESSMENT)
self.assertNotContains(response, VALIDATE_ADMONITION)
self.assertContains(response, reverse("geiq:assessment_info", kwargs={"assessment_pk": assessment.pk}))
self.assertContains(
response,
reverse(
"geiq:employee_list", kwargs={"assessment_pk": assessment.pk, "info_type": "personal-information"}
),
)

# With several assessments, the last one is shown
new_assessment = ImplementationAssessmentFactory(campaign__year=2023, company=membership.company)
response = self.client.get(reverse("dashboard:index"))
self.assertContains(response, IMPLEMENTATION_ASSESSMENT)
self.assertContains(response, VALIDATE_ADMONITION)
self.assertContains(response, reverse("geiq:assessment_info", kwargs={"assessment_pk": new_assessment.pk}))
self.assertContains(
response,
Expand Down

0 comments on commit 015dbff

Please sign in to comment.