aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/staff
diff options
context:
space:
mode:
authorGravatar Gareth Coles <[email protected]>2019-10-11 22:32:08 +0100
committerGravatar Gareth Coles <[email protected]>2019-10-11 22:32:08 +0100
commit953195e93c667d39bf213b8c94082bc8f826344d (patch)
tree61bc4a0dca20bf2705e8ba028501662c5c54dc15 /pydis_site/apps/staff
parentSignals: Fix test for `deletion=True` change (diff)
Signals: Handle (and test) mapping updates/deletions
This also enforces unique values for both attributes on the RoleMapping model. Supporting configurations where this isn't the case would introduce quite a lot of added complexity.
Diffstat (limited to 'pydis_site/apps/staff')
-rw-r--r--pydis_site/apps/staff/models/role_mapping.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/pydis_site/apps/staff/models/role_mapping.py b/pydis_site/apps/staff/models/role_mapping.py
index 5c728283..10c09cf1 100644
--- a/pydis_site/apps/staff/models/role_mapping.py
+++ b/pydis_site/apps/staff/models/role_mapping.py
@@ -10,13 +10,15 @@ class RoleMapping(models.Model):
role = models.OneToOneField(
Role,
on_delete=models.CASCADE,
- help_text="The Discord role to use for this mapping."
+ help_text="The Discord role to use for this mapping.",
+ unique=True, # Unique in order to simplify group assignment logic
)
group = models.OneToOneField(
Group,
on_delete=models.CASCADE,
- help_text="The Django permissions group to use for this mapping."
+ help_text="The Django permissions group to use for this mapping.",
+ unique=True, # Unique in order to simplify group assignment logic
)
def __str__(self):