changeset 4732:e9a2cbcf5479

action.CopyPage: added textcha feature
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Thu, 21 May 2009 16:38:16 +0200
parents 512aeb66b980
children 742ace271d41 47c0ada5c1a2
files MoinMoin/action/CopyPage.py
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/CopyPage.py	Mon May 11 23:10:55 2009 +0200
+++ b/MoinMoin/action/CopyPage.py	Thu May 21 16:38:16 2009 +0200
@@ -13,6 +13,7 @@
 from MoinMoin.Page import Page
 from MoinMoin.PageEditor import PageEditor
 from MoinMoin.action import ActionBase
+from MoinMoin.security.textcha import TextCha
 
 class CopyPage(ActionBase):
     """ Copy page action
@@ -45,6 +46,11 @@
     def do_action(self):
         """ copy this page to "pagename" """
         _ = self._
+        # Currently we only check TextCha for upload (this is what spammers ususally do),
+        # but it could be extended to more/all attachment write access
+        if not TextCha(self.request).check_answer_from_form():
+            return status, _('TextCha: Wrong answer! Go back and try again...')
+
         form = self.form
         newpagename = form.get('newpagename', [u''])[0]
         newpagename = self.request.normalizePagename(newpagename)
@@ -84,6 +90,7 @@
             subpages = ' '.join(self.users_subpages)
 
             d = {
+                'textcha': TextCha(self.request).render(),
                 'subpage': subpages,
                 'subpages_checked': ('', 'checked')[self.request.form.get('subpages_checked', ['0'])[0] == '1'],
                 'subpage_label': _('Copy all /subpages too?'),
@@ -98,6 +105,7 @@
 <strong>%(querytext)s</strong>
 <br>
 <br>
+%(textcha)s
 <table>
     <tr>
     <dd>
@@ -132,12 +140,14 @@
 
         else:
             d = {
+                'textcha': TextCha(self.request).render(),
                 'pagename': wikiutil.escape(self.pagename, True),
                 'newname_label': _("New name"),
                 'comment_label': _("Optional reason for the copying"),
                 'buttons_html': buttons_html,
                 }
             return '''
+%(textcha)s
 <table>
     <tr>
         <td class="label"><label>%(newname_label)s</label></td>