コード例 #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
        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
コード例 #2
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
        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
コード例 #3
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
        layers = list(self.determine_layers(reg_part + '-Interp', version))
        builder = CFRHTMLBuilder(layers)
        builder.tree = interp
        builder.generate_html()
        interp = builder.tree
        interp['html_label'] = html_label
        context['tree'] = {'children': [interp]}
        return context
コード例 #4
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
        layers = list(self.determine_layers(reg_part + '-Interp', version))
        builder = CFRHTMLBuilder(layers)
        builder.tree = interp
        builder.generate_html()
        interp = builder.tree
        interp['html_label'] = html_label
        context['tree'] = {'children': [interp]}
        return context
コード例 #5
0
 def check_tree(self, context):
     """Throw an exception if the requested section doesn't exist"""
     label_id, version = context['label_id'], context['version']
     relevant_tree = generator.get_tree_paragraph(label_id, version)
     if relevant_tree is None:
         raise error_handling.MissingSectionException(label_id, version,
                                                      context)
コード例 #6
0
ファイル: chrome.py プロジェクト: annalee/regulations-site
 def check_tree(self, context):
     """Throw an exception if the requested section doesn't exist"""
     label_id, version = context['label_id'], context['version']
     relevant_tree = generator.get_tree_paragraph(label_id, version)
     if relevant_tree is None:
         raise error_handling.MissingSectionException(label_id, version,
                                                      context)
コード例 #7
0
    def check_tree(self, context):
        """We can't defer to Chrome's check because Subterps are constructed
        -site side"""
        version, label_id = context['version'], context['label_id']
        label = label_id.split('-')
        reg_part = label[0]

        interp = generator.get_tree_paragraph(reg_part + '-Interp', version)
        if not interp:
            interp = generator.get_tree_paragraph(label_id, version)
            if not interp:
                raise error_handling.MissingSectionException(
                    label_id, version, context)

        subterp_sects = filter_by_subterp(interp['children'], label, version)
        if not subterp_sects:
            raise error_handling.MissingSectionException(
                label_id, version, context)
コード例 #8
0
    def test_get_tree_paragraph(self, api_reader):
        node = {'some': 'text'}
        api_reader.ApiReader.return_value.regulation.return_value = node

        p = generator.get_tree_paragraph('some-id', 'some-version')
        self.assertEqual(node, p)
        self.assertEqual(
            ('some-id', 'some-version'),
            api_reader.ApiReader.return_value.regulation.call_args[0])
コード例 #9
0
    def test_get_tree_paragraph(self, api_reader):
        node = {'some': 'text'}
        api_reader.ApiReader.return_value.regulation.return_value = node

        p = generator.get_tree_paragraph('some-id', 'some-version')
        self.assertEqual(node, p)
        self.assertEqual(
            ('some-id', 'some-version'),
            api_reader.ApiReader.return_value.regulation.call_args[0])
コード例 #10
0
    def check_tree(self, context):
        """We can't defer to Chrome's check because Subterps are constructed
        -site side"""
        version, label_id = context['version'], context['label_id']
        label = label_id.split('-')
        reg_part = label[0]

        interp = generator.get_tree_paragraph(reg_part + '-Interp', version)
        if not interp:
            interp = generator.get_tree_paragraph(label_id, version)
            if not interp:
                raise error_handling.MissingSectionException(label_id, version,
                                                             context)

        subterp_sects = filter_by_subterp(interp['children'], label, version)
        if not subterp_sects:
            raise error_handling.MissingSectionException(label_id, version,
                                                         context)
コード例 #11
0
    def get_context_data(self, **kwargs):
        context = super(PartialView, self).get_context_data(**kwargs)

        label_id = context["label_id"]
        version = context["version"]

        tree = generator.get_tree_paragraph(label_id, version)
        if tree is None:
            raise Http404

        inline_applier, p_applier, s_applier = self.determine_appliers(label_id, version)

        builder = generate_html(tree, (inline_applier, p_applier, s_applier))
        return self.transform_context(context, builder)
コード例 #12
0
    def get_context_data(self, **kwargs):
        context = super(PartialView, self).get_context_data(**kwargs)

        label_id = context['label_id']
        version = context['version']

        tree = generator.get_tree_paragraph(label_id, version)
        if tree is None:
            raise Http404

        layers = list(self.determine_layers(label_id, version))
        builder = CFRHTMLBuilder(layers)
        builder.tree = tree
        builder.generate_html()
        return self.transform_context(context, builder)
コード例 #13
0
    def get_context_data(self, **kwargs):
        context = super(PartialView, self).get_context_data(**kwargs)

        label_id = context['label_id']
        version = context['version']

        tree = generator.get_tree_paragraph(label_id, version)
        if tree is None:
            raise Http404

        inline_applier, p_applier, s_applier = self.determine_appliers(
            label_id, version)

        builder = generate_html(tree, (inline_applier, p_applier, s_applier))
        return self.transform_context(context, builder)
コード例 #14
0
ファイル: partial.py プロジェクト: eregs/regulations-site
    def get_context_data(self, **kwargs):
        context = super(PartialView, self).get_context_data(**kwargs)

        label_id = context['label_id']
        version = context['version']

        tree = generator.get_tree_paragraph(label_id, version)
        if tree is None:
            raise Http404

        layers = list(self.determine_layers(label_id, version))
        builder = CFRHTMLBuilder(layers)
        builder.tree = tree
        builder.generate_html()
        return self.transform_context(context, builder)
コード例 #15
0
    def get_context_data(self, **kwargs):
        # We don't want to run the content data of PartialView -- it assumes
        # we will be applying layers
        context = super(PartialView, self).get_context_data(**kwargs)

        label_id = context['label_id']
        older = context['version']
        newer = context['newer_version']

        tree = generator.get_tree_paragraph(label_id, older)

        if tree is None:
            #TODO We need a more complicated check here to see if the diffs
            #add the requested section. If not -> 404
            tree = {}

        appliers = get_appliers(label_id, older, newer)

        builder = HTMLBuilder(*appliers)
        builder.tree = tree

        if not builder.tree:
            return error_handling.handle_generic_404(self.request)

        builder.generate_html()

        child_of_root = builder.tree
        if builder.tree['node_type'] == REGTEXT:
            child_of_root = {
                'node_type': EMPTYPART,
                'children': [builder.tree]
            }
        context['tree'] = {'children': [child_of_root]}
        context['markup_page_type'] = 'diff'

        regpart = label_id.split('-')[0]
        old_toc = fetch_toc(regpart, older)
        diff = generator.get_diff_json(regpart, older, newer)
        from_version = self.request.GET.get('from_version', older)
        context['TOC'] = diff_toc(older, newer, old_toc, diff, from_version)
        context['navigation'] = self.footer_nav(label_id, context['TOC'],
                                                older, newer, from_version)
        return context
コード例 #16
0
    def get_context_data(self, **kwargs):
        # We don't want to run the content data of PartialView -- it assumes
        # we will be applying layers
        context = super(PartialView, self).get_context_data(**kwargs)

        label_id = context['label_id']
        older = context['version']
        newer = context['newer_version']

        tree = generator.get_tree_paragraph(label_id, older)

        if tree is None:
            #TODO We need a more complicated check here to see if the diffs
            #add the requested section. If not -> 404
            tree = {}

        appliers = get_appliers(label_id, older, newer)

        builder = HTMLBuilder(*appliers)
        builder.tree = tree

        if not builder.tree:
            return error_handling.handle_generic_404(self.request)

        builder.generate_html()

        child_of_root = builder.tree
        if builder.tree['node_type'] == REGTEXT:
            child_of_root = {
                'node_type': EMPTYPART,
                'children': [builder.tree]}
        context['tree'] = {'children': [child_of_root]}
        context['markup_page_type'] = 'diff'

        regpart = label_id.split('-')[0]
        old_toc = fetch_toc(regpart, older)
        diff = generator.get_diff_json(regpart, older, newer)
        from_version = self.request.GET.get('from_version', older)
        context['TOC'] = diff_toc(older, newer, old_toc, diff, from_version)
        context['navigation'] = self.footer_nav(label_id, context['TOC'],
                                                older, newer, from_version)
        return context
コード例 #17
0
    def get_context_data(self, **kwargs):
        # We don't want to run the content data of PartialView -- it assumes
        # we will be applying layers
        context = super(PartialView, self).get_context_data(**kwargs)

        label_id = context['label_id']
        versions = Versions(context['version'], context['newer_version'],
                            self.request.GET.get('from_version'))

        tree = generator.get_tree_paragraph(label_id, versions.older)

        if tree is None:
            # TODO We need a more complicated check here to see if the diffs
            # add the requested section. If not -> 404
            tree = {}

        diff_applier = generator.get_diff_applier(label_id, versions.older,
                                                  versions.newer)
        if diff_applier is None:
            raise error_handling.MissingContentException()
        layers = list(generator.diff_layers(versions, label_id))

        builder = CFRHTMLBuilder(layers, diff_applier)
        builder.tree = tree
        builder.generate_html()

        child_of_root = builder.tree
        if builder.tree['node_type'] == REGTEXT:
            child_of_root = {
                'node_type': EMPTYPART,
                'children': [builder.tree]
            }
        context['tree'] = {'children': [child_of_root]}
        context['markup_page_type'] = 'diff'

        regpart = label_id.split('-')[0]
        old_toc = fetch_toc(regpart, versions.older)
        diff = generator.get_diff_json(regpart, versions.older, versions.newer)
        context['TOC'] = diff_toc(versions, old_toc, diff)
        context['navigation'] = self.footer_nav(label_id, context['TOC'],
                                                versions)
        return context
コード例 #18
0
ファイル: diff.py プロジェクト: eregs/regulations-site
    def get_context_data(self, **kwargs):
        # We don't want to run the content data of PartialView -- it assumes
        # we will be applying layers
        context = super(PartialView, self).get_context_data(**kwargs)

        label_id = context['label_id']
        versions = Versions(context['version'], context['newer_version'],
                            self.request.GET.get('from_version'))

        tree = generator.get_tree_paragraph(label_id, versions.older)

        if tree is None:
            # TODO We need a more complicated check here to see if the diffs
            # add the requested section. If not -> 404
            tree = {}

        diff_applier = generator.get_diff_applier(
            label_id, versions.older, versions.newer)
        if diff_applier is None:
            raise error_handling.MissingContentException()
        layers = list(generator.diff_layers(versions, label_id))

        builder = CFRHTMLBuilder(layers, diff_applier)
        builder.tree = tree
        builder.generate_html()

        child_of_root = builder.tree
        if builder.tree['node_type'] == REGTEXT:
            child_of_root = {
                'node_type': EMPTYPART,
                'children': [builder.tree]}
        context['tree'] = {'children': [child_of_root]}
        context['markup_page_type'] = 'diff'

        regpart = label_id.split('-')[0]
        old_toc = fetch_toc(regpart, versions.older)
        diff = generator.get_diff_json(regpart, versions.older, versions.newer)
        context['TOC'] = diff_toc(versions, old_toc, diff)
        context['navigation'] = self.footer_nav(
            label_id, context['TOC'], versions)
        return context