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 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_add_depths(self): sxs = {"label": "204-2", "children": [{"label": "204-2-a", "children": [], "paragraphs": ["abc"]}]} notices.add_depths(sxs, 3) depth_sxs = { "label": "204-2", "depth": 3, "children": [{"depth": 4, "label": "204-2-a", "children": [], "paragraphs": ["abc"]}], } self.assertEqual(depth_sxs, sxs)
def test_add_depths(self): sxs = { 'label': '204-2', 'children': [{ 'label': '204-2-a', 'children': [], 'paragraphs': ['abc']}]} notices.add_depths(sxs, 3) depth_sxs = { 'label': '204-2', 'depth': 3, 'children': [{ 'depth': 4, 'label': '204-2-a', 'children': [], 'paragraphs': ['abc']}]} self.assertEqual(depth_sxs, sxs)
def get_context_data(self, **kwargs): context = super(ParagraphSXSView, self).get_context_data(**kwargs) label_id = context['label_id'] part = label_id.split('-')[0] notice_id = context['notice_id'] fr_page = context.get('fr_page') version = context.get('version', notice_id) # Try first to get the notice and SxS with the version. try: notice, paragraph_sxs = generator.get_notice_and_sxs( part, version, label_id, fr_page) except TypeError: raise Http404 if notice is None or paragraph_sxs is None: # If that didn't work, try again with the notice_id notice, paragraph_sxs = generator.get_notice_and_sxs( part, notice_id, label_id, fr_page) if notice is None or 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, context['version'], paragraph_sxs.get('page')) return context
def get_context_data(self, **kwargs): context = super(ParagraphSXSView, self).get_context_data(**kwargs) label_id = context['label_id'] part = label_id.split('-')[0] notice_id = context['notice_id'] fr_page = context.get('fr_page') version = context.get('version', notice_id) # Try first to get the notice and SxS with the version. notice, paragraph_sxs = generator.get_notice_and_sxs(part, version, label_id, fr_page) if notice is None or paragraph_sxs is None: # If that didn't work, try again with the notice_id notice, paragraph_sxs = generator.get_notice_and_sxs(part, notice_id, label_id, fr_page) if notice is None or 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, context['version'], paragraph_sxs.get('page')) return context