Пример #1
0
    def get_context_data(self, **kwargs):
        context = super(ChromeView, self).get_context_data(**kwargs)

        label_id = context['label_id']
        version = context['version']
        label_id_list = label_id.split('-')
        reg_part = label_id_list[0]
        context['q'] = self.request.GET.get('q', '')
        context['formatted_id'] = label_to_text(label_id_list, True, True)
        context['node_type'] = type_from_label(label_id_list)

        error_handling.check_regulation(reg_part)

        try:
            self.set_chrome_context(context, reg_part, version)
            self.check_tree(context)
            self.add_main_content(context)
        except (IndexError, TypeError):
            raise Http404

        if self.has_sidebar:
            sidebar_view = SideBarView.as_view()
            response = sidebar_view(self.request, label_id=label_id,
                                    version=version)
            self._assert_good(response)
            response.render()
            context['sidebar_content'] = response.content

        return context
Пример #2
0
    def get_context_data(self, **kwargs):
        context = super(ChromeView, self).get_context_data(**kwargs)

        label_id = context['label_id']
        version = context['version']
        label_id_list = label_id.split('-')
        reg_part = label_id_list[0]
        context['q'] = self.request.GET.get('q', '')
        context['formatted_id'] = label_to_text(label_id_list, True, True)
        context['node_type'] = type_from_label(label_id_list)

        error_handling.check_regulation(reg_part)

        try:
            self.set_chrome_context(context, reg_part, version)
            self.check_tree(context)
            self.add_main_content(context)
        except (IndexError, TypeError):
            raise Http404

        if self.has_sidebar:
            sidebar_view = SideBarView.as_view()
            response = sidebar_view(self.request, label_id=label_id,
                                    version=version)
            self._assert_good(response)
            response.render()
            context['sidebar_content'] = response.content

        return context
Пример #3
0
 def sidebar(self, label_id, version):
     """Generate the sidebar content for this label_id+version. This
     involves passing through to the SideBarView"""
     sidebar_view = SideBarView.as_view(components=self.sidebar_components)
     response = sidebar_view(self.request, label_id=label_id,
                             version=version)
     self._assert_good(response)
     response.render()
     return response.content
Пример #4
0
 def sidebar(self, label_id, version):
     """Generate the sidebar content for this label_id+version. This
     involves passing through to the SideBarView"""
     sidebar_view = SideBarView.as_view(components=self.sidebar_components)
     response = sidebar_view(self.request, label_id=label_id,
                             version=version)
     self._assert_good(response)
     response.render()
     return response.content
def add_to_chrome(body, context, request):
    chrome_template = loader.get_template('regulations/chrome.html')

    context['main_content'] = body
    sidebar_view = SideBarView.as_view(components=[HelpSidebar])
    sidebar_response = sidebar_view(request, label_id=context['label_id'],
                                    version=context['version'])
    context['sidebar_content'] = sidebar_response.render().content
    chrome_body = chrome_template.render(context, request)

    return http.HttpResponseNotFound(chrome_body, content_type='text/html')
Пример #6
0
def add_to_chrome(body, context, request):
    chrome_template = loader.get_template('regulations/chrome.html')

    context['main_content'] = body
    sidebar_view = SideBarView.as_view(components=[HelpSidebar])
    sidebar_response = sidebar_view(request, label_id=context['label_id'],
                                    version=context['version'])
    context['sidebar_content'] = sidebar_response.render().content
    chrome_body = chrome_template.render(RequestContext(
        request, context))

    return http.HttpResponseNotFound(chrome_body, content_type='text/html')
Пример #7
0
    # A regulation paragraph with chrome
    # Example: http://.../201-2-g/2013-10704
    url(r'^%s/%s$' % (paragraph_pattern, version_pattern),
        lt_cache(ChromeView.as_view(
            partial_class=PartialParagraphView,
            version_switch_view='chrome_paragraph_view')),
        name='chrome_paragraph_view'),
    # A regulation landing page
    # Example: http://.../201
    url(r'^%s$' % reg_pattern, ChromeLandingView.as_view(),
        name='regulation_landing_view'),

    # Load just the sidebar
    # Example: http://.../partial/sidebar/201-2/2013-10704
    url(r'^partial/sidebar/%s/%s$' % (paragraph_pattern, version_pattern),
        SideBarView.as_view(),
        name='sidebar'),

    # Load just search results
    url(r'^partial/search(?:/cfr)?/%s$' % reg_pattern,
        PartialSearch.as_view(), name='partial_search',
        kwargs={'doc_type': 'cfr'}),
    url(r'^partial/search/preamble/%s$' % preamble_pattern,
        PartialSearch.as_view(), name='partial_search',
        kwargs={'doc_type': 'preamble'}),

    # A diff view of a section (without chrome)
    url(r'^partial/diff/%s/%s/%s$' % (
        section_pattern, version_pattern, newer_version_pattern),
        lt_cache(PartialSectionDiffView.as_view()),
        name='partial_section_diff_view'),
Пример #8
0
        lt_cache(ChromeRegulationView.as_view()),
        name='chrome_regulation_view'),
    #A regulation paragraph with chrome
    #Example: http://.../201-2-g/2013-10704
    url(r'^%s/%s$' % (paragraph_pattern, version_pattern),
        lt_cache(ChromeParagraphView.as_view()),
        name='chrome_paragraph_view'),
    #A regulation landing page
    #Example: http://.../201
    url(r'^%s$' % reg_pattern, ChromeLandingView.as_view(),
        name='regulation_landing_view'),

    # Load just the sidebar
    # Example: http://.../partial/sidebar/201-2/2013-10704
    url(r'^partial/sidebar/%s/%s$' % (paragraph_pattern, version_pattern),
        SideBarView.as_view(),
        name='sidebar'),

    # Load just search results
    url(r'^partial/search/%s$' % reg_pattern,
        PartialSearch.as_view(),
        name='partial_search'),

    #A diff view of a section (without chrome)
    url(r'^partial/diff/%s/%s/%s$' % (
        section_pattern, version_pattern, newer_version_pattern),
        lt_cache(PartialSectionDiffView.as_view()),
        name='partial_section_diff_view'),
    #A section by section paragraph (without chrome)
    #Example: http://.../partial/sxs/201-2-g/2011-1738
    url(r'^partial/sxs/%s/%s$' % (paragraph_pattern, notice_pattern),
Пример #9
0
 ),
 # Interpretation of a section/paragraph or appendix
 # Example: http://.../regulation/201-4-Interp/2013-10704
 url(r"^%s/%s$" % (interp_pattern, version_pattern), ChromeInterpView.as_view(), name="chrome_interp_view"),
 # The whole regulation with chrome
 # Example: http://.../regulation/201/2013-10704
 url(r"^%s/%s$" % (reg_pattern, version_pattern), ChromeRegulationView.as_view(), name="chrome_regulation_view"),
 # A regulation paragraph with chrome
 # Example: http://.../regulation/201-2-g/2013-10704
 url(r"^%s/%s$" % (paragraph_pattern, version_pattern), ChromeParagraphView.as_view(), name="chrome_paragraph_view"),
 # A regulation landing page
 # Example: http://.../regulation/201
 url(r"^%s$" % reg_pattern, ChromeLandingView.as_view(), name="regulation_landing_view"),
 # Load just the sidebar
 # Example: http://.../partial/sidebar/201-2/2013-10704
 url(r"^partial/sidebar/%s/%s$" % (paragraph_pattern, version_pattern), SideBarView.as_view(), name="sidebar"),
 # Load just search results
 url(r"^partial/search/%s$" % reg_pattern, PartialSearch.as_view(), name="partial_search"),
 # A diff view of a section (without chrome)
 url(
     r"^partial/diff/%s/%s/%s$" % (section_pattern, version_pattern, newer_version_pattern),
     PartialSectionDiffView.as_view(),
     name="partial_section_diff_view",
 ),
 # A section by section paragraph (without chrome)
 # Example: http://.../partial/sxs/201-2-g/2011-1738
 url(
     r"^partial/sxs/%s/%s$" % (paragraph_pattern, notice_pattern),
     ParagraphSXSView.as_view(),
     name="paragraph_sxs_view",
 ),