Create new email domain block entries

This commit is contained in:
Mouse Reeve
2021-09-08 15:30:18 -07:00
parent c705178c3b
commit 8717d8a675
5 changed files with 59 additions and 24 deletions

View File

@ -127,12 +127,17 @@ class EmailBlocklist(models.Model):
"""blocked email addresses"""
created_date = models.DateTimeField(auto_now_add=True)
domain = models.CharField(max_length=255)
domain = models.CharField(max_length=255, unique=True)
class Meta:
"""default sorting"""
ordering = ("-created_date",)
@property
def users(self):
"""find the users associated with this address"""
User.objects.filter(email__endswith=f"@{self.domain}")
return User.objects.filter(email__endswith=f"@{self.domain}")
# pylint: disable=unused-argument