Attachment 'ApprovePage-191.py'

Download

   1 # -*- coding: iso-8859-1 -*-
   2 """
   3     MoinMoin - ApprovePage action
   4 
   5     This action allows you to approve a page.
   6 
   7     @copyright: 2005 by Robert Penz <robert.penz@outertech.com>
   8     @license: GNU GPL, see COPYING for details.
   9 
  10     Changes by Oliver Siemoneit 4.12.2006:
  11     * made action 1.5 compatible
  12 """
  13 
  14 import os
  15 from datetime import datetime
  16 from MoinMoin import wikiutil
  17 from MoinMoin.PageEditor import PageEditor
  18 from MoinMoin.action import ActionBase
  19 
  20 class ApprovePage(ActionBase):
  21     """ Approve page action
  22 
  23     Note: the action name is the class name
  24     """
  25     def __init__(self, pagename, request):
  26         ActionBase.__init__(self, pagename, request)
  27         self.use_ticket = True
  28         _ = self._
  29         self.form_trigger = 'approve'
  30         self.form_trigger_label = _('Approve')
  31 
  32     def is_allowed(self):
  33         # check user right
  34         may = self.request.user.may
  35         return may.approve(self.pagename)
  36 
  37     def check_condition(self):
  38         _ = self._
  39         if not self.page.exists():
  40             return _('This page is already deleted or was never created! Cannot be approved.')
  41         else:
  42             return None
  43 
  44     def do_action(self):
  45         """ Approve pagename """
  46 
  47         # Create a page editor that does not do editor backups, because
  48         # delete generates a "deleted" version of the page.
  49         #self.page = PageEditor(self.request, self.pagename, do_editor_backup=0)
  50         #success, msgs = self.page.approvePage(comment)
  51         # Approve the page
  52         # in the first colum is the revision and in the second the username
  53         open(os.path.abspath(os.path.join(self.page.getPagePath(), "approved")),"a").write("%08d\t%s\t%s\n" % (self.page.getRevList()[0], self.request.user.name,datetime.utcnow().strftime("%Y-%m-%d %H:%M:S")))
  54 
  55         msgs = 'Page "%s" has been successfully approved!' % self.pagename
  56         return 1, msgs
  57         
  58         # Create a page editor that does not do editor backups, becuase
  59         # approve generate "approved" version, of the page.
  60         #page = PageEditor(request, pagename, do_editor_backup=0)
  61 
  62     def get_form_html(self, buttons_html):
  63         _ = self._
  64 
  65         d = {
  66             'pagename': self.pagename,
  67             'buttons_html': buttons_html,
  68             'querytext': _('Really approve page?'),
  69             }
  70 
  71         return '''
  72 <strong>%(querytext)s</strong>
  73 <table>
  74     <tr>
  75         <td></td>
  76         <td class="buttons">
  77             %(buttons_html)s
  78         </td>
  79     </tr>
  80 </table>
  81 ''' % d
  82 
  83 
  84 
  85 def execute(pagename, request):
  86     """ Glue code for actions """
  87     ApprovePage(pagename, request).render()

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2010-02-05 17:13:18, 2.6 KB) [[attachment:ApprovePage-191.py]]
  • [get | view] (2005-10-18 14:16:34, 2.8 KB) [[attachment:ApprovePage.py]]
  • [get | view] (2005-11-08 14:48:57, 2.9 KB) [[attachment:ApprovePage.py-20050811]]
  • [get | view] (2005-11-08 14:51:44, 2.9 KB) [[attachment:ApprovePage.py-20050811-2]]
  • [get | view] (2010-11-18 09:43:04, 7.1 KB) [[attachment:Page.diff-v193-18112010]]
  • [get | view] (2010-02-05 17:15:25, 78.1 KB) [[attachment:Page.py]]
  • [get | view] (2010-11-18 09:41:22, 79.2 KB) [[attachment:Page.py-v193-18112010]]
  • [get | view] (2010-02-05 17:15:58, 4.3 KB) [[attachment:Page.py.patch]]
  • [get | view] (2008-02-12 01:09:14, 4.3 KB) [[attachment:PageApproval.diff]]
  • [get | view] (2010-02-05 17:25:50, 21.4 KB) [[attachment:approval-history.png]]
  • [get | view] (2010-11-18 10:19:10, 2.4 KB) [[attachment:approvePage.py-v193-18112010]]
  • [get | view] (2006-12-04 21:40:20, 3.0 KB) [[attachment:approvepage2.py]]
  • [get | view] (2005-10-18 14:17:03, 4.5 KB) [[attachment:modern.py]]
  • [get | view] (2010-11-18 09:42:23, 3.8 KB) [[attachment:modern_iso.diff-v193-18112010]]
  • [get | view] (2005-11-08 14:48:07, 4.6 KB) [[attachment:modern_iso.py]]
  • [get | view] (2010-11-18 09:40:06, 6.2 KB) [[attachment:modern_iso.py-v193-18112010]]
  • [get | view] (2006-12-04 21:40:00, 4.9 KB) [[attachment:modern_iso2.py]]
  • [get | view] (2010-11-18 09:40:39, 15.0 KB) [[attachment:modernized_iso.py-v193-18112010]]
  • [get | view] (2006-12-04 21:40:39, 1.5 KB) [[attachment:page.diff]]
  • [get | view] (2010-11-18 10:10:42, 7.2 KB) [[attachment:rightsidebar_iso.py-v193-18112010]]
  • [get | view] (2010-02-05 17:13:56, 29.0 KB) [[attachment:solenoid_iso-191.py]]
  • [get | view] (2010-02-05 17:15:05, 1.4 KB) [[attachment:solenoid_iso-191.py.patch]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.