added captcha to message composition

This commit is contained in:
Christopher Slowe
2008-08-16 21:36:56 -07:00
parent 2ffb666e87
commit 35181f164f
5 changed files with 27 additions and 11 deletions

View File

@@ -137,7 +137,8 @@ class ApiController(RedditController):
POST_ad_inq = POST_feedback
@Json
@validate(VUser(),
@validate(VCaptcha(),
VUser(),
VModhash(),
ip = ValidIP(),
to = VExistingUname('to'),
@@ -153,6 +154,9 @@ class ApiController(RedditController):
elif (res._chk_error(errors.NO_MSG_BODY) or
res._chk_error(errors.COMMENT_TOO_LONG)):
res._focus('message')
elif res._chk_captcha(errors.BAD_CAPTCHA):
pass
if not res.error:
spam = (c.user._spam or
errors.BANNED_IP in c.errors or

View File

@@ -425,12 +425,17 @@ class MessageController(ListingController):
c.msg_location = where
return ListingController.GET_listing(self, **env)
def GET_compose(self):
i = request.get
if not c.user_is_loggedin: return self.abort404()
content = MessageCompose(to = i.get('to'), subject = i.get('subject'),
message = i.get('message'),
success = i.get('success'))
@validate(VUser(),
to = nop('to'),
subject = nop('subject'),
message = nop('message'),
success = nop('success'))
def GET_compose(self, to, subject, message, success):
captcha = Captcha() if c.user.needs_captcha() else None
content = MessageCompose(to = to, subject = subject,
captcha = captcha,
message = message,
success = success)
return MessagePage(content = content).render()

View File

@@ -95,7 +95,7 @@ class Reddit(Wrapped):
self.subreddit_sidebox = True
self.subreddit_checkboxes = c.site == Default
if c.user_is_loggedin:
if c.user_is_loggedin and self.show_sidebar:
self._content = PaneStack([ShareLink(), content])
else:
self._content = content
@@ -300,6 +300,8 @@ class PrefDelete(Wrapped):
class MessagePage(Reddit):
"""Defines the content for /message/*"""
def __init__(self, *a, **kw):
if not kw.has_key('show_sidebar'):
kw['show_sidebar'] = False
Reddit.__init__(self, *a, **kw)
self.replybox = CommentReplyBox()
@@ -316,9 +318,11 @@ class MessagePage(Reddit):
class MessageCompose(Wrapped):
"""Compose message form."""
def __init__(self,to='', subject='', message='', success=''):
def __init__(self,to='', subject='', message='', success='',
captcha = None):
Wrapped.__init__(self, to = to, subject = subject,
message = message, success = success)
message = message, success = success,
captcha = captcha)
class BoringPage(Reddit):

View File

@@ -60,6 +60,9 @@ ${success_field(_("your message has been delivered"),
<td>${error_field("NO_MSG_BODY", "span")}
${error_field("COMMENT_TOO_LONG", "span")}</td>
</tr>
%if thing.captcha:
${thing.captcha.render()}
%endif
<tr>
<th>
<label for="send"></label>

View File

@@ -1,4 +1,4 @@
## "The contents of this file are subject to the Common Public Attribution
## The contents of this file are subject to the Common Public Attribution
## License Version 1.0. (the "License"); you may not use this file except in
## compliance with the License. You may obtain a copy of the License at
## http://code.reddit.com/LICENSE. The License is based on the Mozilla Public