diff options
author | 2021-06-18 22:16:53 +0100 | |
---|---|---|
committer | 2021-06-18 22:16:53 +0100 | |
commit | c40ed8c159f5101d1bc677a66406cef7c99843aa (patch) | |
tree | ea42f2161b96d4e5b59e9406973831dc247cd285 | |
parent | Add cache purge step to CI deploy stage (#533) (diff) |
Use BigInt for permissions field and remove max value validator
BigInt is needed as Discord's permissions number now exceeds that which can be stored
in a normal int. I have removed the max value validator, as this just adds
maintanence burden for us each time Discord adds new permissions.
-rw-r--r-- | pydis_site/apps/api/migrations/0070_auto_20210618_2114.py | 19 | ||||
-rw-r--r-- | pydis_site/apps/api/models/bot/role.py | 8 |
2 files changed, 21 insertions, 6 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/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." ) |