Add report record admin and template search

When creating a ban, you can type in to do a search, this is useful for
quickly banning users.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2022-06-23 18:16:00 -07:00
parent 789bd0efe9
commit b64559aba9
4 changed files with 88 additions and 15 deletions

View File

@@ -311,11 +311,21 @@ class Ban(BanCommon):
class BanTemplate(models.Model):
# The name of this template
name = models.CharField(max_length=100)
# The reason for this ban
ban_reason = models.TextField(blank=False)
# The duration of the ban
duration = models.DurationField()
# The duration of the ban, in days
duration = models.IntegerField(blank=True, null=True)
# The board that this template is for, or none.
board = models.ForeignKey("Board", on_delete=models.CASCADE, null=True, blank=True)
def create_ban(self, ip: str) -> Ban:
expires = timezone.now() + self.duration
return Ban.objects.create(ip=ip, ban_reason=self.ban_reason, expires=expires)
def __str__(self) -> str:
if self.board:
return f"/{self.board.url}/ - {self.name}"
else:
return self.name