Fix report form to use appropriate templates

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2022-06-19 22:41:02 -07:00
parent daeb7849e8
commit b4df8b9756
2 changed files with 25 additions and 8 deletions

View File

@@ -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