aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/api
diff options
context:
space:
mode:
Diffstat (limited to 'pydis_site/apps/api')
-rw-r--r--pydis_site/apps/api/migrations/0093_user_alts.py2
-rw-r--r--pydis_site/apps/api/models/bot/user.py6
-rw-r--r--pydis_site/apps/api/tests/test_models.py6
-rw-r--r--pydis_site/apps/api/views.py2
4 files changed, 12 insertions, 4 deletions
diff --git a/pydis_site/apps/api/migrations/0093_user_alts.py b/pydis_site/apps/api/migrations/0093_user_alts.py
index fa5f2102..db6807b4 100644
--- a/pydis_site/apps/api/migrations/0093_user_alts.py
+++ b/pydis_site/apps/api/migrations/0093_user_alts.py
@@ -36,6 +36,6 @@ class Migration(migrations.Migration):
),
migrations.AddConstraint(
model_name='useraltrelationship',
- constraint=models.CheckConstraint(check=models.Q(('source', models.F('target')), _negated=True), name='api_useraltrelationship_prevent_alt_to_self'),
+ constraint=models.CheckConstraint(condition=models.Q(('source', models.F('target')), _negated=True), name='api_useraltrelationship_prevent_alt_to_self'),
),
]
diff --git a/pydis_site/apps/api/models/bot/user.py b/pydis_site/apps/api/models/bot/user.py
index 4d317b8e..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:
@@ -137,6 +139,6 @@ class UserAltRelationship(ModelReprMixin, ModelTimestampMixin, models.Model):
),
models.CheckConstraint(
name="%(app_label)s_%(class)s_prevent_alt_to_self",
- check=~models.Q(source=models.F("target")),
+ condition=~models.Q(source=models.F("target")),
),
]
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")
diff --git a/pydis_site/apps/api/views.py b/pydis_site/apps/api/views.py
index 05a2bb02..da0bfe49 100644
--- a/pydis_site/apps/api/views.py
+++ b/pydis_site/apps/api/views.py
@@ -348,7 +348,7 @@ class GitHubWebhookFilterView(APIView):
headers.pop('Content-Length', None)
headers.pop('Content-Type', None)
headers.pop('Host', None)
- request = urllib.request.Request( # noqa: S310
+ request = urllib.request.Request(
f'https://discord.com/api/webhooks/{webhook_id}/{webhook_token}/github?wait=1',
data=payload,
headers={'Content-Type': 'application/json', **headers},