Fix report form to use appropriate templates
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
from django.conf import settings
|
||||
from django.db import transaction
|
||||
from django.forms import ModelForm
|
||||
from board.models import Post, Report, ReportRecord
|
||||
from django.db.models import Q
|
||||
from django.forms import ModelForm, ModelChoiceField
|
||||
from board.models import Post, Report, ReportReason, ReportRecord
|
||||
from hcaptcha.fields import hCaptchaField
|
||||
|
||||
|
||||
@@ -61,6 +62,8 @@ class ReportForm(ModelForm):
|
||||
super(ReportForm, self).__init__(*args, **kwargs)
|
||||
self.instance.ip = ip
|
||||
self.op = op
|
||||
queryset = ReportReason.objects.filter(Q(board=None) | Q(board=board))
|
||||
self.fields["reason"] = ModelChoiceField(queryset=queryset)
|
||||
|
||||
def clean(self):
|
||||
# Get or create the record before creating the model
|
||||
|
||||
@@ -226,9 +226,6 @@ class ReportRecord(models.Model):
|
||||
# If this report is urgent or not
|
||||
urgent = models.BooleanField(default=False)
|
||||
|
||||
# def urgent(self) -> bool:
|
||||
# return self.report_set().aggregate(
|
||||
|
||||
|
||||
class Report(models.Model):
|
||||
"""
|
||||
@@ -263,8 +260,25 @@ def report_created(sender, instance, created, **kwargs):
|
||||
instance.record.save()
|
||||
|
||||
|
||||
# class BanTemplate(models.Model):
|
||||
# board =
|
||||
|
||||
|
||||
class RangeBan(models.Model):
|
||||
# Starting IP address of the ban
|
||||
start = models.GenericIPAddressField()
|
||||
# Ending IP address of the ban
|
||||
end = models.GenericIPAddressField()
|
||||
# The reason for this ban
|
||||
ban_reason = models.TextField(blank=False)
|
||||
# The time that this ban was created.
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
# Expiration date of this ban. If it is null, it is permanent.
|
||||
expires = models.DateTimeField(null=True)
|
||||
|
||||
|
||||
class Ban(models.Model):
|
||||
# IP address of the reporter
|
||||
# IP address of the ban
|
||||
ip = models.GenericIPAddressField()
|
||||
# The reason for this ban
|
||||
ban_reason = models.TextField(blank=False)
|
||||
@@ -274,8 +288,8 @@ class Ban(models.Model):
|
||||
board = models.ForeignKey("Board", on_delete=models.CASCADE, null=True)
|
||||
# The time that this ban was created.
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
# Expiration date of this ban.
|
||||
expires = models.DateTimeField()
|
||||
# Expiration date of this ban. If it is null, it is permanent.
|
||||
expires = models.DateTimeField(null=True)
|
||||
|
||||
|
||||
class BanTemplate(models.Model):
|
||||
|
||||
Reference in New Issue
Block a user