Skip to content

Commit 5bd25bb

Browse files
authored
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).
1 parent 22867d7 commit 5bd25bb

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pydis_site/apps/api/models/bot/user.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ class User(ModelReprMixin, models.Model):
7676

7777
def __str__(self):
7878
"""Returns the name and discriminator for the current user, for display purposes."""
79-
return f"{self.name}#{self.discriminator:04d}"
79+
if self.discriminator:
80+
return f"{self.name}#{self.discriminator:04d}"
81+
return self.name
8082

8183
@property
8284
def top_role(self) -> Role:

pydis_site/apps/api/tests/test_models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,9 @@ def test_nomination_str_representation(self):
187187
"Nomination of Hemlock's Cat#7777 (active)",
188188
str(self.nomination)
189189
)
190+
191+
192+
class UserTests(SimpleTestCase):
193+
def test_str_without_discriminator(self) -> None:
194+
user = User(name="lemonfannumber1")
195+
self.assertEqual(str(user), "lemonfannumber1")

0 commit comments

Comments
 (0)