-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pilotage : Mise en place d'une route pour accéder aux tableaux de bord par leur nom #4466
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
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.views.decorators.clickjacking import xframe_options_exempt | ||
|
@@ -31,6 +32,7 @@ | |
) | ||
from itou.companies import models as companies_models | ||
from itou.prescribers.enums import PrescriberOrganizationKind | ||
from itou.users.enums import UserKind | ||
from itou.utils import constants as global_constants | ||
from itou.utils.apis import metabase as mb | ||
from itou.utils.perms.company import get_current_company_or_404 | ||
|
@@ -185,6 +187,17 @@ def stats_pilotage(request, dashboard_id): | |
return render_stats(request=request, context=context, template_name="stats/stats_pilotage.html") | ||
|
||
|
||
@login_required | ||
def stats_redirect(request, dashboard_name): | ||
match request.user.kind: | ||
case UserKind.LABOR_INSPECTOR: | ||
normalized_organization_kind = request.current_organization.kind.lower().replace(" ", "_") | ||
case _: | ||
return HttpResponseNotFound() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Je pense au cas d'un membre There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Pas sûr de comprendre 🤔. Et pour le coup j'ai pris le parti de faire la fonction très simple quitte à avoir quelques erreurs au début, plutôt que commencer à mettre des vérifications dans tout les sens. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Je parle de https://github.com/gip-inclusion/les-emplois/blob/master/itou/institutions/enums.py#L7-L10 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, compris ! 😫 🥵 Dans ce cas là il aura pas la 404 mais la 500 [1] car son type d'utilisateur est bon mais la route C'est toujours la même problématique de prendre [1] Je suis parti sur cette idée car une 500 fera une erreur sentry et donc on verra les erreurs réelles plutôt qu'ajouter du code défensif dés le départ sur un truc qui petit et non-critique There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oui pas de super solution à proposer 😬 |
||
|
||
return HttpResponseRedirect(reverse(f"stats:stats_{normalized_organization_kind}_{dashboard_name}")) | ||
|
||
|
||
@login_required | ||
def stats_siae_aci(request): | ||
""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ça donne envie de virer l’espace de la valeur pour
kind
, mais j’ai un peu peur qu’on l’utilise directement.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
J'ai pas regardé si c'était la merde (faut faire des migrations) ou LA MERDE (faut toucher à des requêtes SQL jusque dans le pilotage) mais oui l'espace m'a aussi un peu étonné.