Skip to content

Commit

Permalink
www.stats: Show contextual webinar banners
Browse files Browse the repository at this point in the history
  • Loading branch information
rsebille committed Aug 22, 2024
1 parent 401a80d commit 7a654c7
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 4 deletions.
23 changes: 23 additions & 0 deletions itou/templates/stats/stats.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,29 @@ <h1>{{ page_title }}</h1>
{% endif %}
{% endblock %}

{% block title_messages %}
{{ block.super }}
{% for banner in pilotage_webinar_banners %}
<div class="alert alert-info alert-dismissible fade show" role="status">
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Fermer"></button>
<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>{{ banner.title }}</strong>
</p>
<p class="mb-0">{{ banner.description }}</p>
</div>
<div class="col-12 col-md-auto mt-3 mt-md-0 d-flex align-items-center justify-content-center">
<a class="btn btn-sm btn-primary btn-block btn-ico" href="{{ banner.url }}" target="_blank" rel="noopener"><span>Je m’inscris</span> <i class="ri-external-link-line font-weight-medium" aria-hidden="true"></i></a>
</div>
</div>
</div>
{% endfor %}
{% endblock %}

{% block content %}
<section class="s-section">
<div class="s-section__container container">
Expand Down
62 changes: 58 additions & 4 deletions itou/www/stats/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@
"""

import datetime

from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.core.exceptions import PermissionDenied
from django.http import HttpResponseNotFound, HttpResponseRedirect
from django.shortcuts import render
from django.urls import reverse
from django.utils import timezone
from django.views.decorators.clickjacking import xframe_options_exempt

from itou.analytics.models import StatsDashboardVisit
Expand Down Expand Up @@ -130,6 +133,18 @@ def render_stats(request, context, params=None, template_name="stats/stats.html"

# Key value pairs in context override preexisting pairs in base_context.
base_context.update(context)
if "pilotage_webinar_banners" not in base_context:
base_context["pilotage_webinar_banners"] = [
{
"title": "Des questions sur l’utilisation de vos tableaux de bord ?",
"description": "Nous y répondons lors d’un webinaire questions / réponses animé chaque mois. Inscrivez-vous à la prochaine session prévu jeudi 29 août de 14h à 14h45.", # noqa: E501
"url": "https://app.livestorm.co/itou/le-pilotage-de-linclusion-professionnels-de-liae-questions-reponses-sur-les-tableaux-de-bord-1?s=67c316de-9dc5-4ec7-a469-6698507fa312", # noqa: E501
"is_displayable": lambda: timezone.localdate() <= datetime.date(2024, 8, 29),
}
]
base_context["pilotage_webinar_banners"] = [
banner for banner in base_context["pilotage_webinar_banners"] if banner["is_displayable"]()
]

matomo_custom_url = request.resolver_match.route # e.g. "stats/pe/delay/main"
if suffix := base_context.pop("matomo_custom_url_suffix", None):
Expand Down Expand Up @@ -315,7 +330,7 @@ def stats_siae_hiring_report(request):
return render_stats_siae(request=request, page_title="Déclaration d’embauche")


def render_stats_cd(request, page_title, params=None):
def render_stats_cd(request, page_title, *, params=None, extra_context=None):
"""
CD ("Conseil Départemental") stats shown to relevant members.
They can only view data for their own departement.
Expand All @@ -330,6 +345,8 @@ def render_stats_cd(request, page_title, params=None):
"department": department,
"matomo_custom_url_suffix": format_region_and_department_for_matomo(department),
}
if extra_context:
context.update(extra_context)
return render_stats(request=request, context=context, params=params)


Expand All @@ -342,14 +359,38 @@ def stats_cd_iae(request):
def stats_cd_hiring(request):
if not utils.can_view_stats_cd_whitelist(request):
raise PermissionDenied
return render_stats_cd(request=request, page_title="Facilitation des embauches en IAE")
context = {
"pilotage_webinar_banners": [
{
"title": "Des questions sur la prise en main de ce nouveau tableau de bord ?",
"description": "Nous y répondons en direct lors d’un webinaire de questions / réponses, dédiés aux Conseils départementaux, organisés le mardi 17 septembre à 14h", # noqa: E501
"url": "https://app.livestorm.co/itou/le-pilotage-de-linclusion-webinaire-questions-and-reponses-pour-les-conseils-departementaux?s=f83e62e2-42a3-4cc1-9772-c963d2be2c00", # noqa: E501
"is_displayable": lambda: timezone.localdate() <= datetime.date(2024, 9, 17),
}
]
}
return render_stats_cd(request=request, page_title="Facilitation des embauches en IAE", extra_context=context)


@login_required
def stats_cd_brsa(request):
if not utils.can_view_stats_cd_whitelist(request):
raise PermissionDenied
return render_stats_cd(request=request, page_title="Suivi des prescriptions des accompagnateurs des publics bRSA")
context = {
"pilotage_webinar_banners": [
{
"title": "Des questions sur la prise en main de ce nouveau tableau de bord ?",
"description": "Nous y répondons en direct lors d’un webinaire de questions / réponses, dédiés aux Conseils départementaux, organisés le mardi 17 septembre à 14h", # noqa: E501
"url": "https://app.livestorm.co/itou/le-pilotage-de-linclusion-webinaire-questions-and-reponses-pour-les-conseils-departementaux?s=f83e62e2-42a3-4cc1-9772-c963d2be2c00", # noqa: E501
"is_displayable": lambda: timezone.localdate() <= datetime.date(2024, 9, 17),
}
]
}
return render_stats_cd(
request=request,
page_title="Suivi des prescriptions des accompagnateurs des publics bRSA",
extra_context=context,
)


@login_required
Expand Down Expand Up @@ -484,7 +525,7 @@ def stats_pe_tension(request):
)


def render_stats_ph(request, page_title, extra_params=None):
def render_stats_ph(request, page_title, *, extra_params=None, extra_context=None):
if not utils.can_view_stats_ph(request):
raise PermissionDenied

Expand All @@ -500,17 +541,30 @@ def render_stats_ph(request, page_title, extra_params=None):
"matomo_custom_url_suffix": f"{format_region_and_department_for_matomo(department)}/agence",
"department": department,
}
if extra_context:
context.update(extra_context)
return render_stats(request=request, context=context, params=params)


@login_required
def stats_ph_state_main(request):
context = {}
if request.current_organization.kind in [PrescriberOrganizationKind.ML, PrescriberOrganizationKind.CAP_EMPLOI]:
context["pilotage_webinar_banners"] = [
{
"title": "Besoin d’être accompagné dans la prise en main de ce tableau de bord ?",
"description": "Participez à l’une de nos deux sessions de présentation de vos statistiques dédiées le jeudi 12 septembre ou le mardi 24 septembre.", # noqa: E501
"url": "https://app.livestorm.co/itou/le-pilotage-de-linclusion-missions-locales-et-cap-emploi-decouvrez-votre-nouveau-tableau-de-bord-personnalise-et-faites-le-point-sur-vos-prescriptions-vers-liae?type=detailed", # noqa: E501
"is_displayable": lambda: timezone.localdate() <= datetime.date(2024, 9, 24),
}
]
return render_stats_ph(
request=request,
page_title="Etat des candidatures orientées",
extra_params={
mb.PRESCRIBER_FILTER_KEY: PrescriberOrganizationKind(request.current_organization.kind).label,
},
extra_context=context,
)


Expand Down

0 comments on commit 7a654c7

Please sign in to comment.