diff --git a/lemarche/stats/models.py b/lemarche/stats/models.py index 48c54e5cb..07972b12c 100644 --- a/lemarche/stats/models.py +++ b/lemarche/stats/models.py @@ -11,8 +11,8 @@ class TrackerQuerySet(models.QuerySet): def env_prod(self): return self.filter(env="prod", isadmin=False) - def by_user_type(self, user_type): - return self.filter(data__meta__user_type=user_type) + def by_user_kind(self, user_kind): + return self.filter(user_kind=user_kind) def siae_views_last_3_months(self, siae_slug): return self.env_prod().filter( @@ -22,10 +22,10 @@ def siae_views_last_3_months(self, siae_slug): ) def siae_buyer_views_last_3_months(self, siae_slug): - return self.env_prod().siae_views_last_3_months(siae_slug).by_user_type(constants.USER_KIND_BUYER) + return self.env_prod().siae_views_last_3_months(siae_slug).by_user_kind(constants.USER_KIND_BUYER) def siae_partner_views_last_3_months(self, siae_slug): - return self.env_prod().siae_views_last_3_months(siae_slug).by_user_type(constants.USER_KIND_PARTNER) + return self.env_prod().siae_views_last_3_months(siae_slug).by_user_kind(constants.USER_KIND_PARTNER) class Tracker(models.Model): diff --git a/lemarche/templates/includes/_tracker_itou.html b/lemarche/templates/includes/_tracker_itou.html index 7484e7cd5..ac7b5fd6d 100644 --- a/lemarche/templates/includes/_tracker_itou.html +++ b/lemarche/templates/includes/_tracker_itou.html @@ -20,7 +20,7 @@ const meta = Object.assign(metaIn, getUrlMeta()); // user info meta['is_admin'] = {% if user.is_authenticated %}{% if user.kind == 'ADMIN' %}true{% else %}false{% endif %}{% else %}false{% endif %}; - meta['user_type'] = {% if user.is_authenticated %}'{{ user.kind }}'{% else %}null{% endif %}; + meta['user_kind'] = {% if user.is_authenticated %}'{{ user.kind }}'{% else %}null{% endif %}; meta['user_id'] = {% if user.is_authenticated %}{{ user.id }}{% else %}null{% endif %}; meta['siae_id'] = {% if siae %}{{ siae.id }}{% else %}null{% endif %}; // default data diff --git a/lemarche/utils/tracker.py b/lemarche/utils/tracker.py index 3d334cec6..d29883c1b 100644 --- a/lemarche/utils/tracker.py +++ b/lemarche/utils/tracker.py @@ -53,10 +53,10 @@ # @task() def track(page: str = "", action: str = "load", meta: dict = {}): # noqa B006 # Don't log in dev - if settings.BITOUBI_ENV not in ("dev", "test"): + if settings.BITOUBI_ENV not in ("test"): date_created = timezone.now() user_id = int(meta.get("user_id")) if meta.get("user_id", None) else None - user_kind = meta.get("user_type") if meta.get("user_type", "") else "" + user_kind = meta.get("user_kind") if meta.get("user_kind", "") else "" siae_id = meta.get("siae_id", None) if siae_id: siae_id = int(siae_id[0]) if (type(siae_id) is list) else int(siae_id) @@ -154,7 +154,7 @@ def extract_user_info(self, request: HttpRequest, context_data: dict): siae = context_data.get("siae") return { "user_id": user.id if user.is_authenticated else None, - "user_type": user.kind if user.is_authenticated else "", + "user_kind": user.kind if user.is_authenticated else "", "is_admin": user.is_authenticated and user.kind == User.KIND_ADMIN, "siae_id": siae.id if siae else None, "siae_kind": siae.kind if siae else "",