The report system is pretty low-tech. However the scaffolding is there for a lot of new stuff. What we currently have: * Users can create reports * Staff can view reports * Admins can create report templates There's a post drop-down menu available on all posts now, too. This is where "report post" menu item lives and other things like that can be added too. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
61 lines
1.5 KiB
Python
61 lines
1.5 KiB
Python
from django.conf import settings
|
|
from django.forms import ModelForm
|
|
from board.models import Post, Report
|
|
from hcaptcha.fields import hCaptchaField
|
|
|
|
|
|
class PostForm(ModelForm):
|
|
"""
|
|
A form used for new threads for posts.
|
|
|
|
This requires the board and the IP address to be specified.
|
|
"""
|
|
|
|
hcaptcha = hCaptchaField() if settings.USE_HCAPTCHA else None
|
|
|
|
class Meta:
|
|
model = Post
|
|
fields = ["subject", "name", "text", "image"]
|
|
|
|
def __init__(self, *args, board, ip, **kwargs):
|
|
super(PostForm, self).__init__(*args, **kwargs)
|
|
self.instance.board = board
|
|
self.instance.ip = ip
|
|
|
|
|
|
class ReplyForm(PostForm):
|
|
"""
|
|
A form used for replies to posts.
|
|
|
|
This requires the OP post, the reply post, the board, and the IP address be
|
|
specified.
|
|
"""
|
|
|
|
hcaptcha = hCaptchaField() if settings.USE_HCAPTCHA else None
|
|
|
|
class Meta:
|
|
model = Post
|
|
fields = ["name", "text", "bump", "image"]
|
|
|
|
def __init__(self, *args, op, reply, **kwargs):
|
|
super(ReplyForm, self).__init__(*args, **kwargs)
|
|
self.instance.op = op
|
|
self.instance.reply = reply
|
|
|
|
|
|
class ReportForm(ModelForm):
|
|
"""
|
|
A form used to create reports on posts.
|
|
|
|
This requires the board and the IP address to be specified.
|
|
"""
|
|
|
|
class Meta:
|
|
model = Report
|
|
fields = ["reason"]
|
|
|
|
def __init__(self, *args, op, board, ip, **kwargs):
|
|
super(ReportForm, self).__init__(*args, **kwargs)
|
|
self.instance.ip = ip
|
|
self.instance.post = op
|