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 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_filter_children(self): sxs = { 'children': [{ 'label': '204-a', 'paragraphs': ['me'] }, { 'paragraphs': ['abcd'] }] } filtered = notices.filter_labeled_children(sxs) self.assertEqual(filtered, [{'paragraphs': ['abcd']}])
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
def test_filter_children_no_candidates(self): sxs = {"children": [{"label": "204-a", "paragraphs": ["me"]}, {"label": "204-b", "paragraphs": ["abcd"]}]} filtered = notices.filter_labeled_children(sxs) self.assertEqual(filtered, [])
def test_filter_children_no_candidates(self): sxs = {'children': [ {'label': '204-a', 'paragraphs': ['me']}, {'label': '204-b', 'paragraphs': ['abcd']}]} filtered = notices.filter_labeled_children(sxs) self.assertEqual(filtered, [])