From 03fccb24f99a9d145a0a3aaec3dea66aeb49c765 Mon Sep 17 00:00:00 2001 From: Ema Ciupe Date: Mon, 6 Jun 2022 16:24:53 +0300 Subject: [PATCH] [ch29134] Admin header: add href to current user --- src/etools/applications/users/models.py | 5 +++++ src/etools/templates/admin/base_site.html | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/etools/applications/users/models.py b/src/etools/applications/users/models.py index 3ad2123af..fbe3d6f9b 100644 --- a/src/etools/applications/users/models.py +++ b/src/etools/applications/users/models.py @@ -9,6 +9,7 @@ from django.core.validators import MaxValueValidator, MinValueValidator from django.db import connection, models from django.db.models.signals import post_save +from django.urls import reverse from django.utils.functional import cached_property from django.utils.translation import gettext_lazy as _ @@ -99,6 +100,10 @@ def get_staff_member_country(self): return country return None + def get_admin_url(self): + info = (self._meta.app_label, self._meta.model_name) + return reverse('admin:%s_%s_change' % info, args=(self.pk,)) + def save(self, *args, **kwargs): if self.email != self.email.lower(): raise ValidationError("Email must be lowercase.") diff --git a/src/etools/templates/admin/base_site.html b/src/etools/templates/admin/base_site.html index 9a26b5c38..c97f0cc8d 100644 --- a/src/etools/templates/admin/base_site.html +++ b/src/etools/templates/admin/base_site.html @@ -150,7 +150,10 @@
{% block welcome-msg %} {% trans 'Welcome,' %} + {% firstof user.get_short_name user.get_username %}. + + {% endblock %} {% block userlinks %} {% trans 'Log out' %}