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:
2022-07-13 12:35:57 -07:00
parent f131c58d1b
commit f04604ce69
3 changed files with 7 additions and 1 deletions

View File

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