Add posting cooldown
If a user tries to post more than once in a certain amount of time, they will be blocked from doing so until their cooldown is over. This required a little bit of hacking to get the board and IP address set *before* the validation checks were made, but it all appears to work. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
37
board/forms.py
Normal file
37
board/forms.py
Normal file
@@ -0,0 +1,37 @@
|
||||
from django.forms import ModelForm
|
||||
from board.models import Post
|
||||
|
||||
|
||||
class PostForm(ModelForm):
|
||||
"""
|
||||
A form used for new threads for posts.
|
||||
|
||||
This requires the board and the IP address to be specified.
|
||||
"""
|
||||
|
||||
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.
|
||||
"""
|
||||
|
||||
class Meta:
|
||||
model = Post
|
||||
fields = ["name", "text", "image"]
|
||||
|
||||
def __init__(self, *args, op, reply, **kwargs):
|
||||
super(ReplyForm, self).__init__(*args, **kwargs)
|
||||
self.instance.op = op
|
||||
self.instance.reply = reply
|
||||
Reference in New Issue
Block a user