Permalink
Browse files

Add captcha to article submit form for karma < 1

  • Loading branch information...
1 parent d5aaee4 commit cff76675ab3505569cad5df617d7e16bd1a02ab6 Wesley Moore committed Jan 10, 2011
@@ -514,7 +514,7 @@ def GET_submit(self, url, title, tags):
if redirect_link:
return self.redirect(redirect_link.already_submitted_link)
- captcha = Captcha() if c.user.needs_captcha() else None
+ captcha = Captcha(tabular=False) if c.user.needs_captcha() else None
srs = Subreddit.submit_sr(c.user) if c.default_sr else ()
# Set the default sr to the user's draft when creating a new article
View
@@ -840,10 +840,10 @@ class ResetPassword(Wrapped):
class Captcha(Wrapped):
"""Container for rendering robot detection device."""
- def __init__(self, error=None):
+ def __init__(self, error=None, tabular=True, label=True):
self.error = _('Try entering those letters again') if error else ""
self.iden = get_captcha()
- Wrapped.__init__(self)
+ Wrapped.__init__(self, tabular=tabular, label=label)
class CommentReplyBox(Wrapped):
"""Used on LinkInfoPage to render the comment reply form at the
View
@@ -204,9 +204,7 @@ def make_cookie(self, timestr = None, admin = False):
return id_time + ',' + hashlib.sha1(to_hash).hexdigest()
def needs_captcha(self):
- # TODO: decide on who/what/why needs a captcha
- return False
- # return self.link_karma < 1
+ return self.safe_karma < 1
def modhash(self, rand=None, test=False):
return modhash(self, rand = rand, test = test)
@@ -529,3 +529,10 @@ div.comment div.parent {
color: red
}
+/* Submit form */
+.pretty-form.long-text .cap-reply {
+ display: block;
+}
+.pretty-form.long-text #captcha {
+ width: 250px;
+}
@@ -23,7 +23,7 @@
<%! from r2.lib.template_helpers import static %>
<%namespace file="utils.html" import="error_field"/>
-${captchagen(thing.iden, thing.error)}
+${captchagen(thing.iden, thing.error, tabular=thing.tabular, label=thing.label)}
<%def name="captchagen(iden, error='', tabulate=False, tabular = True, size=60, label=True, show_error = True)">
%if tabulate:
@@ -51,9 +51,6 @@
%else:
<span class="cap-reply">
%endif
- %if label:
- <label for="captcha">${_("Human?")}</label>
- %endif
%if tabular:
</td>
<td>
@@ -64,6 +61,9 @@
<script type="text/javascript">
setMessage($('captcha'), "${_('Type the letters from the image above')}");
</script>
+ %if label:
+ <label for="captcha">${_('Type the letters from the image above.')}</label>
+ %endif
%if tabular:
</td>
<td>
@@ -86,7 +86,11 @@
</tr>
%endif
%if thing.captcha:
- ${thing.captcha.render()}
+ <tr>
+ <td>
+ ${thing.captcha.render()}
+ </td>
+ </tr>
%endif
<tr>
<td>

0 comments on commit cff7667

Please sign in to comment.