Skip to content

Commit

Permalink
Remove discriminator from bot logs view
Browse files Browse the repository at this point in the history
When a user does not have a discriminator, do not display it anymore.
Behaviour for users with discriminators (for historic infractions is
unchanged).
  • Loading branch information
jchristgit committed Aug 30, 2024
1 parent be1648d commit 24a7854
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pydis_site/apps/api/models/bot/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions pydis_site/apps/api/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,9 @@ def test_nomination_str_representation(self):
"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")

0 comments on commit 24a7854

Please sign in to comment.