2021-09-17 18:57:28 +00:00
|
|
|
""" Lets try NOT to sell viagra """
|
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
from .user import User
|
|
|
|
|
|
|
|
|
|
|
|
class EmailBlocklist(models.Model):
|
|
|
|
"""blocked email addresses"""
|
|
|
|
|
|
|
|
created_date = models.DateTimeField(auto_now_add=True)
|
|
|
|
domain = models.CharField(max_length=255, unique=True)
|
|
|
|
is_active = models.BooleanField(default=True)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
"""default sorting"""
|
|
|
|
|
|
|
|
ordering = ("-created_date",)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def users(self):
|
|
|
|
"""find the users associated with this address"""
|
|
|
|
return User.objects.filter(email__endswith=f"@{self.domain}")
|
|
|
|
|
|
|
|
|
|
|
|
class IPBlocklist(models.Model):
|
|
|
|
"""blocked ip addresses"""
|
|
|
|
|
|
|
|
created_date = models.DateTimeField(auto_now_add=True)
|
|
|
|
address = models.CharField(max_length=255, unique=True)
|
|
|
|
is_active = models.BooleanField(default=True)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
"""default sorting"""
|
|
|
|
|
|
|
|
ordering = ("-created_date",)
|
2022-02-18 05:01:34 +00:00
|
|
|
|
|
|
|
|
2022-02-24 19:18:43 +00:00
|
|
|
class AutoMod(models.Model):
|
2022-02-18 05:01:34 +00:00
|
|
|
"""rules to automatically flag suspicious activity"""
|
2022-02-24 19:18:43 +00:00
|
|
|
string_match = models.CharField(max_length=200, unique=True)
|
|
|
|
flag_users = models.BooleanField(default=True)
|
|
|
|
flag_statuses = models.BooleanField(default=True)
|
2022-02-18 05:01:34 +00:00
|
|
|
created_by = models.ForeignKey("User", on_delete=models.PROTECT)
|