Just been playing around with adding captchas to for guests posting 
comments on the blog. I don't want logged in users having a captcha 
obviously.

I see the comment form type is hard wired in comment_tags.py and 
generic.views.py.

What do people think about making the comment form type a SETTING that 
defaults to 'mezzanine.generic.forms.ThreadedCommentForm'?

This way users can create customised comment forms. For my case I could add 
a very simple form that adds a captcha for guest users only:-

from mezzanine.generic.forms import ThreadedCommentForm
from captcha.fields import CaptchaField
class GuestCaptchaThreadedCommentForm(ThreadedCommentForm):
    def __init__(self, request, *args, **kwargs):
        super(GuestCaptchaThreadedCommentForm, self).__init__(request, 
*args, **kwargs)
        if not request.user.is_authenticated():
            self.fields['captcha'] = CaptchaField()


Then set the new 'COMMENT_FORM_CLASS' (name TBD) setting to 
'GuestCaptchaThreadedCommentForm' to use it.

Is this a good way to do it or is there a better way? I know of 
EXTRA_FORM_FIELDS but that won't make a difference to the comment form.

I would like to do a similar thing for the sign up form too. The captcha 
would always be present for that form obviously.

If Steve thinks this is okay I can submit the change, it's very simple; add 
the new SETTING and update mezzanine/generic/templatetags/comment_tags.py 
and generic/views.py to use the class specified by the setting.

Paullo

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to