def get_context_data(self, **kwargs):
        context = super(ParagraphSXSView, self).get_context_data(**kwargs)

        label_id = context['label_id']
        notice_id = context['notice_id']
        fr_page = context.get('fr_page')

        notice = generator.get_notice(notice_id)
        if not notice:
            raise error_handling.MissingContentException()
        notice = convert_to_python(notice)

        paragraph_sxs = generator.get_sxs(label_id, notice, fr_page)

        if paragraph_sxs is None:
            raise error_handling.MissingContentException()

        notices.add_depths(paragraph_sxs, 3)

        paragraph_sxs['children'] =\
            notices.filter_labeled_children(paragraph_sxs)
        self.footnote_refs(paragraph_sxs)

        context['sxs'] = paragraph_sxs
        # Template assumes a single label
        context['sxs']['label'] = context['label_id']
        context['sxs']['header'] = label_to_text(label_id.split('-'),
                                                 include_marker=True)
        context['sxs']['all_footnotes'] = self.footnotes(notice, paragraph_sxs)
        context['notice'] = notice
        context['further_analyses'] = self.further_analyses(
            label_id, notice_id, paragraph_sxs['page'], context['version'])

        return context
Exemple #2
0
    def get_context_data(self, **kwargs):
        context = super(ParagraphSXSView, self).get_context_data(**kwargs)

        label_id = context['label_id']
        notice_id = context['notice_id']
        fr_page = context.get('fr_page')

        notice = generator.get_notice(notice_id)
        if not notice:
            raise error_handling.MissingContentException()
        notice = convert_to_python(notice)

        paragraph_sxs = generator.get_sxs(label_id, notice, fr_page)

        if paragraph_sxs is None:
            raise error_handling.MissingContentException()

        notices.add_depths(paragraph_sxs, 3)

        paragraph_sxs['children'] =\
            notices.filter_labeled_children(paragraph_sxs)
        self.footnote_refs(paragraph_sxs)

        context['sxs'] = paragraph_sxs
        # Template assumes a single label
        context['sxs']['label'] = context['label_id']
        context['sxs']['header'] = label_to_text(label_id.split('-'),
                                                 include_marker=True)
        context['sxs']['all_footnotes'] = self.footnotes(notice, paragraph_sxs)
        context['notice'] = notice
        context['further_analyses'] = self.further_analyses(
            label_id, notice_id, paragraph_sxs['page'], context['version'])

        return context
 def test_get_notice(self, api_reader):
     notice = {'some': 'notice'}
     api_reader.ApiReader.return_value.notice.return_value = notice
     n = generator.get_notice('204-1234')
     self.assertEqual(notice, n)
     self.assertEqual(('204-1234', ),
                      api_reader.ApiReader.return_value.notice.call_args[0])
    def get_context_data(self, **kwargs):
        context = super(ParagraphSXSView, self).get_context_data(**kwargs)

        label_id = context["label_id"]
        notice_id = context["notice_id"]
        fr_page = context.get("fr_page")

        notice = generator.get_notice(notice_id)
        if not notice:
            raise error_handling.MissingContentException()
        notice = convert_to_python(notice)

        paragraph_sxs = generator.get_sxs(label_id, notice, fr_page)

        if paragraph_sxs is None:
            raise error_handling.MissingContentException()

        notices.add_depths(paragraph_sxs, 3)

        paragraph_sxs["children"] = notices.filter_labeled_children(paragraph_sxs)
        self.footnote_refs(paragraph_sxs)

        context["sxs"] = paragraph_sxs
        # Template assumes a single label
        context["sxs"]["label"] = context["label_id"]
        context["sxs"]["header"] = label_to_text(label_id.split("-"), include_marker=True)
        context["sxs"]["all_footnotes"] = self.footnotes(notice, paragraph_sxs)
        context["notice"] = notice
        context["further_analyses"] = self.further_analyses(
            label_id, notice_id, paragraph_sxs["page"], context["version"]
        )

        return context
 def test_get_notice(self, api_reader):
     notice = {'some': 'notice'}
     api_reader.ApiReader.return_value.notice.return_value = notice
     n = generator.get_notice('204-1234')
     self.assertEqual(notice, n)
     self.assertEqual(
         ('204-1234',),
         api_reader.ApiReader.return_value.notice.call_args[0])