aboutsummaryrefslogtreecommitdiffstats
path: root/api/models.py
diff options
context:
space:
mode:
authorGravatar Johannes Christ <[email protected]>2018-09-01 21:54:11 +0200
committerGravatar Johannes Christ <[email protected]>2018-09-01 21:54:11 +0200
commit2b43df6140f250b481d06e08c4f843b29f743b69 (patch)
tree92b3ace1131f77aafed674ad2e6da1cae935e775 /api/models.py
parentIgnore irrelevant files in coverage report. (diff)
Add the `Role` model.
Diffstat (limited to 'api/models.py')
-rw-r--r--api/models.py43
1 files changed, 42 insertions, 1 deletions
diff --git a/api/models.py b/api/models.py
index 7f4175af..6d7af764 100644
--- a/api/models.py
+++ b/api/models.py
@@ -1,4 +1,4 @@
-from django.core.validators import RegexValidator
+from django.core.validators import MaxValueValidator, MinValueValidator, RegexValidator
from django.db import models
@@ -23,3 +23,44 @@ class SnakeName(models.Model):
name = models.CharField(primary_key=True, max_length=100)
scientific = models.CharField(max_length=150)
+
+
+class Role(models.Model):
+ """A role on our Discord server."""
+
+ id = models.BigIntegerField(
+ primary_key=True,
+ validators=(
+ MinValueValidator(
+ limit_value=0,
+ message="Role IDs cannot be negative."
+ ),
+ ),
+ help_text="The role's ID, taken from Discord."
+ )
+ name = models.CharField(
+ max_length=100,
+ help_text="The role's name, taken from Discord."
+ )
+ colour = models.IntegerField(
+ validators=(
+ MinValueValidator(
+ limit_value=0,
+ message="Colour hex cannot be negative."
+ ),
+ ),
+ help_text="The integer value of the colour of this role from Discord."
+ )
+ permissions = models.IntegerField(
+ 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."
+ )