From c40ed8c159f5101d1bc677a66406cef7c99843aa Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 18 Jun 2021 22:16:53 +0100 Subject: [PATCH] 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. --- .../api/migrations/0070_auto_20210618_2114.py | 19 +++++++++++++++++++ pydis_site/apps/api/models/bot/role.py | 8 ++------ 2 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 pydis_site/apps/api/migrations/0070_auto_20210618_2114.py 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 000000000..1d25e421d --- /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 cfadfec45..733a8e08a 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." )