changeset 1819:4cf97d47a314

merged main
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 25 Feb 2007 17:18:49 +0100
parents df984fe11783 (current diff) fd22bf359a65 (diff)
children 9595d9d5e5ae
files
diffstat 1 files changed, 72 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/DeletePage.py	Sun Feb 25 17:17:53 2007 +0100
+++ b/MoinMoin/action/DeletePage.py	Sun Feb 25 17:18:49 2007 +0100
@@ -23,6 +23,13 @@
         _ = self._
         self.form_trigger = 'delete'
         self.form_trigger_label = _('Delete')
+        pages = request.rootpage.getPageList(user='', exists='')
+        self.subpages = []
+        subpage = pagename + '/'
+        for name in pages:
+            if name.startswith(subpage) and self.request.user.may.delete(name):
+                self.subpages.append(name)
+                
 
     def is_allowed(self):
         # this is not strictly necessary because the underlying storage code checks
@@ -47,17 +54,73 @@
         # delete generates a "deleted" version of the page.
         self.page = PageEditor(self.request, self.pagename, do_editor_backup=0)
         success, msg = self.page.deletePage(comment)
-        return success, msg
+        msgs = msg
+        delete_subpages = 0
+        if form.has_key('delete_subpages'):
+            try:
+                delete_subpages = int(form['delete_subpages'][0])
+            except:
+                pass
+
+        if delete_subpages and self.subpages:
+            for name in self.subpages:
+                self.page = PageEditor(self.request, name, do_editor_backup=0)
+                success_i, msg = self.page.deletePage(comment)
+                msgs += "%s " %msg
+
+        return success, msgs
 
     def get_form_html(self, buttons_html):
         _ = self._
-        d = {
-            'pagename': self.pagename,
-            'comment_label': _("Optional reason for the deletion"),
-            'buttons_html': buttons_html,
-            'querytext': _('Really delete this page?'),
-        }
-        return '''
+
+        if self.subpages:
+            subpages = ' '.join(self.subpages)
+
+            d = {
+                'subpage': subpages,
+                'subpages_checked':('', 'checked')[self.request.form.get('subpages_checked', ['0'])[0] == '1'],
+                'subpage_label': _('Delete all /subpages too?'),
+                'comment_label': _("Optional reason for the deletion"),
+                'buttons_html': buttons_html,
+                'querytext': _('Really delete this page?'),
+                }
+
+            return '''
+<strong>%(querytext)s</strong>
+<br>
+<br>
+<table>
+<tr>
+<dd>
+%(subpage_label)s<input type="checkbox" name="delete_subpages" value="1" %(subpages_checked)s> </dd>
+<dd><class="label"><subpage> %(subpage)s</subpage></dd>   
+</tr>
+</table>
+<table>
+    <tr>
+        <td class="label"><label>%(comment_label)s</label></td>
+        <td class="content">
+            <input type="text" name="comment" maxlength="200">
+        </td>
+    </tr>
+    <tr>
+        <td></td>
+        <td class="buttons">
+            %(buttons_html)s
+        </td>
+    </tr>
+</table>
+''' % d
+
+        else:
+            d = {
+                'pagename': self.pagename,
+                'comment_label': _("Optional reason for the deletion"),
+                'buttons_html': buttons_html,
+                'querytext': _('Really delete this page?'),
+                }
+
+            return '''
 <strong>%(querytext)s</strong>
 <table>
     <tr>
@@ -76,6 +139,7 @@
 ''' % d
 
 
+
 def execute(pagename, request):
     """ Glue code for actions """
     DeletePage(pagename, request).render()