Skip to content

Commit

Permalink
Merge pull request #504 from Krishna-Baldwa/'stable-bans'
Browse files Browse the repository at this point in the history
(bans)Add : Extra field to bans model
  • Loading branch information
VIBR0X authored Oct 24, 2023
2 parents e1f2df6 + 54328bb commit 3ae2894
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion bans/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from collections.abc import Iterable
from django.db import models
from uuid import uuid4
from users.models import UserProfile
from django.db.models.signals import post_save, post_delete, pre_save

# Create your models here.

Expand All @@ -25,7 +28,11 @@ class SSOBan(models.Model):

id = models.UUIDField(primary_key=True, default=uuid4, blank=False)
banned_user = models.ForeignKey(
to="users.UserProfile", related_name="banned_user", on_delete=models.CASCADE
to="users.UserProfile",
related_name="banned_user",
on_delete=models.CASCADE,
null=True,
blank=True,
)
time_of_creation = models.DateTimeField(auto_now_add=True)
reason = models.CharField(max_length=30, choices=BAN_REASON_CHOICHES)
Expand All @@ -38,3 +45,9 @@ class SSOBan(models.Model):
null=True,
blank=True,
)
banned_user_ldapid = models.CharField(max_length=20, blank=True, null=True)

def save(self, *args, **kwargs) -> None:
if self.banned_user_ldapid:
self.banned_user = UserProfile.objects.get(ldap_id=self.banned_user_ldapid)
return super().save(*args, **kwargs)

0 comments on commit 3ae2894

Please sign in to comment.