Users may only report a post once per IP address.
If a user *really* doesn't like a post, they may try to report it multiple times. Users may now only report a single post once per IP address. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -101,6 +101,8 @@ class ReportForm(ModelForm):
|
||||
record = ReportRecord.objects.get(post=self.op)
|
||||
except ReportRecord.DoesNotExist:
|
||||
record = ReportRecord.objects.create(post=self.op)
|
||||
if record.report_set.filter(ip=self.instance.ip):
|
||||
raise ValidationError(_("You have already reported this post."))
|
||||
self.instance.record = record
|
||||
return super(ReportForm, self).clean()
|
||||
|
||||
|
||||
@@ -281,6 +281,11 @@ class Report(models.Model):
|
||||
they are abusing the system.
|
||||
"""
|
||||
|
||||
class Meta:
|
||||
unique_together = [
|
||||
["record", "ip"],
|
||||
]
|
||||
|
||||
# The report that was made by this user
|
||||
record = models.ForeignKey("ReportRecord", on_delete=models.CASCADE)
|
||||
# Reason for this report
|
||||
|
||||
@@ -200,7 +200,6 @@ function openReportWindow(reportUrl) {
|
||||
});
|
||||
$(reportWindow.iframe, "iframe").on("load", () => {
|
||||
fitWindowToContent(reportWindow);
|
||||
reportWindow.setResizable(false);
|
||||
});
|
||||
reportWindow.show();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user