aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps
diff options
context:
space:
mode:
authorGravatar Kieran Siek <[email protected]>2021-06-27 16:12:07 +0800
committerGravatar GitHub <[email protected]>2021-06-27 16:12:07 +0800
commitcc59fc79b6e4fe23b5630577e492a1fb0ef08852 (patch)
treedd1d389ba271371d6a3143dc80426b5f680407e5 /pydis_site/apps
parentAddress review comments. (diff)
parentMerge pull request #536 from bast0006/fix-nitro-message (diff)
Merge branch 'main' into move-config-docs-to-contributing-guide
Diffstat (limited to 'pydis_site/apps')
-rw-r--r--pydis_site/apps/api/migrations/0070_auto_20210618_2114.py19
-rw-r--r--pydis_site/apps/api/migrations/0071_increase_message_content_4000.py18
-rw-r--r--pydis_site/apps/api/models/bot/message.py2
-rw-r--r--pydis_site/apps/api/models/bot/role.py8
-rw-r--r--pydis_site/apps/api/tests/test_models.py40
-rw-r--r--pydis_site/apps/resources/resources/communities/rlbot.yaml13
6 files changed, 79 insertions, 21 deletions
diff --git a/pydis_site/apps/api/migrations/0070_auto_20210618_2114.py b/pydis_site/apps/api/migrations/0070_auto_20210618_2114.py
new file mode 100644
index 00000000..1d25e421
--- /dev/null
+++ b/pydis_site/apps/api/migrations/0070_auto_20210618_2114.py
@@ -0,0 +1,19 @@
+# Generated by Django 3.0.14 on 2021-06-18 21:14
+
+import django.core.validators
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('api', '0069_documentationlink_validators'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='role',
+ name='permissions',
+ field=models.BigIntegerField(help_text='The integer value of the permission bitset of this role from Discord.', validators=[django.core.validators.MinValueValidator(limit_value=0, message='Role permissions cannot be negative.')]),
+ ),
+ ]
diff --git a/pydis_site/apps/api/migrations/0071_increase_message_content_4000.py b/pydis_site/apps/api/migrations/0071_increase_message_content_4000.py
new file mode 100644
index 00000000..6ca5d21a
--- /dev/null
+++ b/pydis_site/apps/api/migrations/0071_increase_message_content_4000.py
@@ -0,0 +1,18 @@
+# Generated by Django 3.0.14 on 2021-06-24 14:45
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('api', '0070_auto_20210618_2114'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='deletedmessage',
+ name='content',
+ field=models.CharField(blank=True, help_text='The content of this message, taken from Discord.', max_length=4000),
+ ),
+ ]
diff --git a/pydis_site/apps/api/models/bot/message.py b/pydis_site/apps/api/models/bot/message.py
index ff06de21..60e2a553 100644
--- a/pydis_site/apps/api/models/bot/message.py
+++ b/pydis_site/apps/api/models/bot/message.py
@@ -43,7 +43,7 @@ class Message(ModelReprMixin, models.Model):
verbose_name="Channel ID"
)
content = models.CharField(
- max_length=2_000,
+ max_length=4_000,
help_text="The content of this message, taken from Discord.",
blank=True
)
diff --git a/pydis_site/apps/api/models/bot/role.py b/pydis_site/apps/api/models/bot/role.py
index cfadfec4..733a8e08 100644
--- a/pydis_site/apps/api/models/bot/role.py
+++ b/pydis_site/apps/api/models/bot/role.py
@@ -1,6 +1,6 @@
from __future__ import annotations
-from django.core.validators import MaxValueValidator, MinValueValidator
+from django.core.validators import MinValueValidator
from django.db import models
from pydis_site.apps.api.models.mixins import ModelReprMixin
@@ -38,16 +38,12 @@ class Role(ModelReprMixin, models.Model):
),
help_text="The integer value of the colour of this role from Discord."
)
- permissions = models.IntegerField(
+ permissions = models.BigIntegerField(
validators=(
MinValueValidator(
limit_value=0,
message="Role permissions cannot be negative."
),
- MaxValueValidator(
- limit_value=2 << 32,
- message="Role permission bitset exceeds value of having all permissions"
- )
),
help_text="The integer value of the permission bitset of this role from Discord."
)
diff --git a/pydis_site/apps/api/tests/test_models.py b/pydis_site/apps/api/tests/test_models.py
index 66052e01..5c9ddea4 100644
--- a/pydis_site/apps/api/tests/test_models.py
+++ b/pydis_site/apps/api/tests/test_models.py
@@ -1,6 +1,7 @@
from datetime import datetime as dt
-from django.test import SimpleTestCase
+from django.core.exceptions import ValidationError
+from django.test import SimpleTestCase, TestCase
from django.utils import timezone
from pydis_site.apps.api.models import (
@@ -34,6 +35,43 @@ class ReprMixinTests(SimpleTestCase):
self.assertEqual(repr(self.klass), expected)
+class NitroMessageLengthTest(TestCase):
+ def setUp(self):
+ self.user = User.objects.create(id=50, name='bill', discriminator=5)
+ self.context = MessageDeletionContext.objects.create(
+ id=50,
+ actor=self.user,
+ creation=dt.utcnow()
+ )
+
+ def test_create(self):
+ message = DeletedMessage(
+ id=46,
+ author=self.user,
+ channel_id=666,
+ content="w"*4000,
+ deletion_context=self.context,
+ embeds=[]
+ )
+
+ try:
+ message.clean_fields()
+ except Exception as e: # pragma: no cover
+ self.fail(f"Creation of message of length 3950 failed with: {e}")
+
+ def test_create_failure(self):
+ message = DeletedMessage(
+ id=47,
+ author=self.user,
+ channel_id=666,
+ content="w"*4001,
+ deletion_context=self.context,
+ embeds=[]
+ )
+
+ self.assertRaisesRegex(ValidationError, "content':", message.clean_fields)
+
+
class StringDunderMethodTests(SimpleTestCase):
def setUp(self):
self.nomination = Nomination(
diff --git a/pydis_site/apps/resources/resources/communities/rlbot.yaml b/pydis_site/apps/resources/resources/communities/rlbot.yaml
deleted file mode 100644
index d12c1dec..00000000
--- a/pydis_site/apps/resources/resources/communities/rlbot.yaml
+++ /dev/null
@@ -1,13 +0,0 @@
-description: RLBot is a community of programmers making awesome Rocket League bots.
- They've created a framework that you can use to write bots in a number of languages (including Python),
- and they host regular tournaments where botmakers can pit their creations against each other.
-title_image: https://i.imgur.com/S8L1muZ.png
-title_url: https://discord.gg/4JJdJKb
-position: 7
-urls:
- - icon: branding/discord
- url: https://discord.gg/4JJdJKb
- color: blurple
- - icon: regular/link
- url: https://www.rlbot.org/
- color: teal