Big upheaval of how the reports system works
* There are now Reports and ReportRecords. * Reports coordinate to what moderators see, and ReportRecords coordinate with the reports that are created by individual users. * Reports keep track of the report reason and the creating user. * ReportRecords keep track of the total weight and whether this report requires urgent attention or not. * ReportRecord keeps track of its own weight and urgency because then we can sort by weight and urgency in the admin view. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from django.conf import settings
|
||||
from django.db import transaction
|
||||
from django.forms import ModelForm
|
||||
from board.models import Post, Report
|
||||
from board.models import Post, Report, ReportRecord
|
||||
from hcaptcha.fields import hCaptchaField
|
||||
|
||||
|
||||
@@ -50,6 +51,8 @@ class ReportForm(ModelForm):
|
||||
This requires the board and the IP address to be specified.
|
||||
"""
|
||||
|
||||
# uses report_form.html
|
||||
|
||||
class Meta:
|
||||
model = Report
|
||||
fields = ["reason"]
|
||||
@@ -57,4 +60,14 @@ class ReportForm(ModelForm):
|
||||
def __init__(self, *args, op, board, ip, **kwargs):
|
||||
super(ReportForm, self).__init__(*args, **kwargs)
|
||||
self.instance.ip = ip
|
||||
self.instance.post = op
|
||||
self.op = op
|
||||
|
||||
def clean(self):
|
||||
# Get or create the record before creating the model
|
||||
with transaction.atomic():
|
||||
try:
|
||||
record = ReportRecord.objects.get(post=self.op)
|
||||
except ReportRecord.DoesNotExist:
|
||||
record = ReportRecord.objects.create(post=self.op)
|
||||
self.instance.record = record
|
||||
return super(ReportForm, self).clean()
|
||||
|
||||
Reference in New Issue
Block a user