Add user tripcodes
Users can separate their name and a password with ## to create the illusion of consistent posting. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -8,9 +8,11 @@ from django.forms.models import fields_for_model
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import gettext as _
|
||||
from guardian.shortcuts import get_objects_for_user
|
||||
from board.models import Ban, Post, Report, ReportReason, ReportRecord
|
||||
from hcaptcha.fields import hCaptchaField
|
||||
|
||||
from board.models import Ban, Post, Report, ReportReason, ReportRecord
|
||||
from board.utils import generate_tripcode
|
||||
|
||||
|
||||
class PostForm(ModelForm):
|
||||
"""
|
||||
@@ -42,6 +44,13 @@ class PostForm(ModelForm):
|
||||
if not self.user or not self.user.has_perm("board.use_capcode", capcode):
|
||||
raise ValidationError(_("Could not create post"))
|
||||
|
||||
def clean_name(self):
|
||||
name = self.cleaned_data["name"]
|
||||
if "##" in name:
|
||||
name, password = [v.strip() for v in name.split("##", 1)]
|
||||
self.instance.tripcode = generate_tripcode(password)
|
||||
return name
|
||||
|
||||
|
||||
class ReplyForm(PostForm):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user