From 39079c3c8e2174c266c4f3e69670306ffe67310f Mon Sep 17 00:00:00 2001 From: moanos Date: Tue, 17 Dec 2024 22:55:30 +0100 Subject: [PATCH] feat: Add fallback if first and lastname is not defined --- src/fellchensammlung/models.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/fellchensammlung/models.py b/src/fellchensammlung/models.py index bae298c..9d9d14b 100644 --- a/src/fellchensammlung/models.py +++ b/src/fellchensammlung/models.py @@ -157,6 +157,12 @@ class User(AbstractUser): verbose_name = _('Nutzer*in') verbose_name_plural = _('Nutzer*innen') + def get_full_name(self): + if self.first_name and self.last_name: + return self.first_name + self.last_name + else: + return self.username + def get_absolute_url(self): return reverse("user-detail", args=[str(self.pk)])