1.1 --- a/actions/SectionBreakout.py Sun Feb 20 22:02:35 2011 +0100
1.2 +++ b/actions/SectionBreakout.py Mon Feb 21 01:55:43 2011 +0100
1.3 @@ -36,11 +36,12 @@
1.4 heading_details = getHeadingDetails(body, level, level)
1.5
1.6 d = {
1.7 - "buttons_html" : buttons_html,
1.8 - "heading_level_label" : escape(_("Heading level")),
1.9 - "found_headings_label" : escape(_("Headings found in page")),
1.10 - "preview_label" : escape(_("Preview")),
1.11 - "level" : escattr(level),
1.12 + "buttons_html" : buttons_html,
1.13 + "heading_level_label" : escape(_("Heading level")),
1.14 + "found_headings_label" : escape(_("Headings found in page")),
1.15 + "propagate_categories_label" : escape(_("Propagate categories")),
1.16 + "preview_label" : escape(_("Preview")),
1.17 + "level" : escattr(level),
1.18 }
1.19
1.20 html = u'''
1.21 @@ -60,6 +61,10 @@
1.22 </td>
1.23 </tr>
1.24 <tr>
1.25 + <td class="label">%(propagate_categories_label)s</td>
1.26 + <td class="buttons"><input type="checkbox" name="propagate" value="yes" /></td>
1.27 + </tr>
1.28 + <tr>
1.29 <td></td>
1.30 <td class="buttons"><input type="submit" value="%(preview_label)s" />%(buttons_html)s</td>
1.31 </tr>
1.32 @@ -78,11 +83,12 @@
1.33 # A heading level must be provided.
1.34
1.35 level = form.get("level", [None])[0]
1.36 + propagate = form.get("propagate", [None])[0]
1.37
1.38 if not level:
1.39 return 0, _("No heading level specified.")
1.40
1.41 - return self.break_out_headings(int(level))
1.42 + return self.break_out_headings(int(level), propagate)
1.43
1.44 def render_success(self, msg, msgtype=None):
1.45
1.46 @@ -94,10 +100,11 @@
1.47
1.48 pass
1.49
1.50 - def break_out_headings(self, level):
1.51 + def break_out_headings(self, level, propagate):
1.52
1.53 """
1.54 - Break out headings at the given 'level' from the current page.
1.55 + Break out headings at the given 'level' from the current page. If
1.56 + 'propagate' is a true value, propagate categories to subpages.
1.57 """
1.58
1.59 _ = self._
1.60 @@ -108,7 +115,9 @@
1.61 # Acquire all heading details from the page.
1.62
1.63 page_body = page.get_raw_body()
1.64 - categories = getCategoryMembership(page_body)
1.65 +
1.66 + if propagate:
1.67 + categories = getCategoryMembership(page_body)
1.68
1.69 regions = []
1.70 current_region_start = None
1.71 @@ -164,16 +173,21 @@
1.72
1.73 new_page = PageEditor(request, new_page_name)
1.74 new_page_body = page_body[start:end]
1.75 - new_page_categories = getCategoryMembership(new_page_body)
1.76 +
1.77 + if propagate:
1.78 + new_page_categories = getCategoryMembership(new_page_body)
1.79
1.80 - # Add categories if the parent page has any.
1.81 + # Add categories if the parent page has any.
1.82
1.83 - if new_page_categories != categories:
1.84 - new_page_body += getCategoryDeclaration(categories)
1.85 + if new_page_categories != categories:
1.86 + new_page_body += getCategoryDeclaration(categories)
1.87
1.88 # Save the new page.
1.89
1.90 - new_page.saveText(new_page_body, 0)
1.91 + try:
1.92 + new_page.saveText(new_page_body, 0)
1.93 + except PageEditor.Unchanged:
1.94 + pass
1.95
1.96 # Retain the preceding region for the current page.
1.97
1.98 @@ -196,13 +210,15 @@
1.99
1.100 edited_page = PageEditor(request, page.page_name)
1.101 edited_page_body = "".join(retained_regions)
1.102 - edited_page_categories = getCategoryMembership(edited_page_body)
1.103 +
1.104 + if propagate:
1.105 + edited_page_categories = getCategoryMembership(edited_page_body)
1.106
1.107 - # Add categories if the parent page should have any, but these were
1.108 - # broken out.
1.109 + # Add categories if the parent page should have any, but these were
1.110 + # broken out.
1.111
1.112 - if edited_page_categories != categories:
1.113 - edited_page_body += getCategoryDeclaration(categories)
1.114 + if edited_page_categories != categories:
1.115 + edited_page_body += getCategoryDeclaration(categories)
1.116
1.117 # Save the current page.
1.118