diff options
author | 2024-11-23 20:36:18 +0100 | |
---|---|---|
committer | 2024-11-23 19:36:18 +0000 | |
commit | 5bd25bb107f969663793401f6aa3259fc46125d9 (patch) | |
tree | b85070b56d54b555cd31b36e5e8a5cb56d07010c /pydis_site/apps | |
parent | Fix typo in `git remote add` in the guide (#1437) (diff) |
Remove discriminator from bot logs view (#1424)
When a user does not have a discriminator, do not display it anymore.
Behaviour for users with discriminators (for historic infractions is
unchanged).
Diffstat (limited to 'pydis_site/apps')
-rw-r--r-- | pydis_site/apps/api/models/bot/user.py | 4 | ||||
-rw-r--r-- | pydis_site/apps/api/tests/test_models.py | 6 |
2 files changed, 9 insertions, 1 deletions
diff --git a/pydis_site/apps/api/models/bot/user.py b/pydis_site/apps/api/models/bot/user.py index df5459a5..7f49fa86 100644 --- a/pydis_site/apps/api/models/bot/user.py +++ b/pydis_site/apps/api/models/bot/user.py @@ -76,7 +76,9 @@ class User(ModelReprMixin, models.Model): def __str__(self): """Returns the name and discriminator for the current user, for display purposes.""" - return f"{self.name}#{self.discriminator:04d}" + if self.discriminator: + return f"{self.name}#{self.discriminator:04d}" + return self.name @property def top_role(self) -> Role: diff --git a/pydis_site/apps/api/tests/test_models.py b/pydis_site/apps/api/tests/test_models.py index 456ac408..0804384c 100644 --- a/pydis_site/apps/api/tests/test_models.py +++ b/pydis_site/apps/api/tests/test_models.py @@ -187,3 +187,9 @@ class StringDunderMethodTests(SimpleTestCase): "Nomination of Hemlock's Cat#7777 (active)", str(self.nomination) ) + + +class UserTests(SimpleTestCase): + def test_str_without_discriminator(self) -> None: + user = User(name="lemonfannumber1") + self.assertEqual(str(user), "lemonfannumber1") |