aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps
diff options
context:
space:
mode:
authorGravatar Johannes Christ <[email protected]>2021-07-08 21:12:21 +0200
committerGravatar Johannes Christ <[email protected]>2021-07-08 21:12:21 +0200
commitfa4a8dd77b8792c5f859dd5ccd1c1e70441d0b94 (patch)
tree3624cd418bd3801b199bb933db38429823c590c0 /pydis_site/apps
parentMove subdomains to query paths. (diff)
parentMerge pull request #547 from Numerlor/docker-override (diff)
Merge branch 'master' into subdomains-to-query-paths
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/content/resources/guides/pydis-guides/contributing/site.md39
-rw-r--r--pydis_site/apps/resources/resources/communities/rlbot.yaml13
7 files changed, 116 insertions, 23 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/content/resources/guides/pydis-guides/contributing/site.md b/pydis_site/apps/content/resources/guides/pydis-guides/contributing/site.md
index c4f29887..df75e81a 100644
--- a/pydis_site/apps/content/resources/guides/pydis-guides/contributing/site.md
+++ b/pydis_site/apps/content/resources/guides/pydis-guides/contributing/site.md
@@ -78,10 +78,12 @@ SECRET_KEY=suitable-for-development-only
STATIC_ROOT=staticfiles
```
+The [Configuration in Detail](#configuration-in-detail) section contains
+detailed information about these settings.
+
#### Notes regarding `DATABASE_URL`
-- If the database is hosted locally i.e. on the same machine as the webserver, then use `localhost` for the host. Windows and macOS users may
- need to use the [Docker host IP](https://stackoverflow.com/questions/22944631/how-to-get-the-ip-address-of-the-docker-host-from-inside-a-docker-container) instead.
+- If the database is hosted locally i.e. on the same machine as the webserver, then use `localhost` for the host. Windows and macOS users may need to use the [Docker host IP](https://stackoverflow.com/questions/22944631/how-to-get-the-ip-address-of-the-docker-host-from-inside-a-docker-container) instead.
- If the database is running in Docker, use port `7777`. Otherwise, use `5432` as that is the default port used by PostegreSQL.
- If you configured PostgreSQL in a different manner or you are not hosting it locally, then you will need to determine the correct host and port yourself.
The user, password, and database name should all still be `pysite` unless you deviated from the setup instructions in the previous section.
@@ -143,3 +145,36 @@ Unless you are editing the Dockerfile or docker-compose.yml, you shouldn't need
Django provides an interface for administration with which you can view and edit the models among other things.
It can be found at [http://127.0.0.1:8000/admin/](http://127.0.0.1:8000/admin/). The default credentials are `admin` for the username and `admin` for the password.
+
+---
+
+# Configuration in detail
+
+The website is configured through the following environment variables:
+
+## Essential
+- **`DATABASE_URL`**: A string specifying the PostgreSQL database to connect to,
+ in the form `postgresql://user:password@host/database`, such as
+ `postgresql://joethedestroyer:ihavemnesia33@localhost/pysite_dev`
+
+- **`METRICITY_DB_URL`**: A string specifying the PostgreSQL metric database to
+ connect to, in the same form as `$DATABASE_URL`.
+
+- **`DEBUG`**: Controls Django's internal debugging setup. Enable this when
+ you're developing locally. Optional, defaults to `False`.
+
+- **`LOG_LEVEL`**: Any valid Python `logging` module log level - one of `DEBUG`,
+ `INFO`, `WARN`, `ERROR` or `CRITICAL`. When using debug mode, this defaults to
+ `INFO`. When testing, defaults to `ERROR`. Otherwise, defaults to `WARN`.
+
+## Deployment
+- **`ALLOWED_HOSTS`**: A comma-separated lists of alternative hosts to allow to
+ host the website on, when `DEBUG` is not set. Optional, defaults to the
+ `pythondiscord.com` family of domains.
+
+- **`SECRET_KEY`**: The secret key used in various parts of Django. Keep this
+ secret as the name suggests! This is managed for you in debug setups.
+
+- **`STATIC_ROOT`**: The root in which `python manage.py collectstatic`
+ collects static files. Optional, defaults to `/app/staticfiles` for the
+ standard Docker deployment.
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