示例#1
0
    def get_context_data(self, **kwargs):
        #   skip our parent
        context = super(PartialView, self).get_context_data(**kwargs)

        label_id = context['label_id']
        label = label_id.split('-')
        reg_part = label[0]
        version = context['version']

        context['navigation'] = self.section_navigation(label_id, version)

        interp = generator.get_tree_paragraph(reg_part + '-Interp', version)
        if not interp:
            raise Http404

        subterp_sects = filter_by_subterp(interp['children'], label, version)
        if not subterp_sects:
            raise Http404

        context['markup_page_type'] = 'reg-section'
        html_label = node_types.to_markup_id(label_id.split('-'))
        interp['children'] = subterp_sects

        # interp['label] is defined so that the template receives the
        # appropriate markup ID, matching the rendered subterp and not
        # the parent node in the tree
        interp['label'] = label
        inline_applier, p_applier, s_applier = self.determine_appliers(
            reg_part + '-Interp', version)
        builder = generate_html(interp, (inline_applier, p_applier, s_applier))
        interp = builder.tree
        interp['html_label'] = html_label
        context['tree'] = {'children': [interp]}
        return context
    def get_context_data(self, **kwargs):
        #   skip our parent
        context = super(PartialView, self).get_context_data(**kwargs)

        label_id = context['label_id']
        label = label_id.split('-')
        reg_part = label[0]
        version = context['version']

        context['navigation'] = self.section_navigation(label_id, version)

        interp = generator.get_tree_paragraph(reg_part + '-Interp', version)
        if not interp:
            raise Http404

        subterp_sects = filter_by_subterp(interp['children'], label, version)
        if not subterp_sects:
            raise Http404

        context['markup_page_type'] = 'reg-section'
        html_label = node_types.to_markup_id(label_id.split('-'))
        interp['children'] = subterp_sects
        inline_applier, p_applier, s_applier = self.determine_appliers(
            reg_part + '-Interp', version)
        builder = generate_html(interp, (inline_applier, p_applier, s_applier))
        interp = builder.tree
        interp['html_label'] = html_label
        context['tree'] = {'children': [interp]}
        return context
 def test_generate_html(self):
     regulation_tree = {'text': '', 'children': [], 'label': ['8675'],
                        'title': 'Regulation R', 'node_type': REGTEXT}
     i_applier = InlineLayersApplier()
     p_applier = ParagraphLayersApplier()
     sr_applier = SearchReplaceLayersApplier()
     appliers = (i_applier, p_applier, sr_applier)
     builder = partial.generate_html(regulation_tree, appliers)
     self.assertEquals(builder.tree, regulation_tree)
     self.assertEquals(builder.inline_applier, i_applier)
     self.assertEquals(builder.p_applier, p_applier)
     self.assertEquals(builder.search_applier, sr_applier)
示例#4
0
 def test_generate_html(self):
     regulation_tree = {
         'text': '',
         'children': [],
         'label': ['8675'],
         'title': 'Regulation R',
         'node_type': REGTEXT
     }
     i_applier = InlineLayersApplier()
     p_applier = ParagraphLayersApplier()
     sr_applier = SearchReplaceLayersApplier()
     appliers = (i_applier, p_applier, sr_applier)
     builder = partial.generate_html(regulation_tree, appliers)
     self.assertEquals(builder.tree, regulation_tree)
     self.assertEquals(builder.inline_applier, i_applier)
     self.assertEquals(builder.p_applier, p_applier)
     self.assertEquals(builder.search_applier, sr_applier)