def test_first_section(self, fetch_toc):
     fetch_toc.return_value = [
         {"section_id": "204-100", "index": ["204", "100"]},
         {"section_id": "204-101", "index": ["204", "101"]},
     ]
     first = utils.first_section("204", "2")
     self.assertEqual(first, "204-100")
Beispiel #2
0
 def get_context_data(self, **kwargs):
     """Get the version for the chrome context"""
     kwargs['version'] = self.request.GET.get('version', '')
     kwargs['skip_count'] = True
     kwargs['label_id'] = utils.first_section(kwargs['label_id'],
                                              kwargs['version'])
     return super(ChromeSearchView, self).get_context_data(**kwargs)
Beispiel #3
0
 def get_context_data(self, **kwargs):
     """Get the version for the chrome context"""
     kwargs['version'] = self.request.GET.get('version', '')
     kwargs['skip_count'] = True
     kwargs['label_id'] = utils.first_section(kwargs['label_id'],
                                              kwargs['version'])
     return super(ChromeSearchView, self).get_context_data(**kwargs)
Beispiel #4
0
def regulation(request, label_id):

    context = {}
    current_version, new_version = get_versions(label_id)
    if new_version:
        context['new_version'] = new_version
    context['current_version'] = current_version

    context['label_id'] = label_id
    context['reg_first_section'] = utils.first_section(
        label_id, current_version['version'])
    context['reg_part'] = label_id.split('-')[0]

    regulation_meta = utils.regulation_meta(
        label_id,
        current_version['version'],
        True)
    context['meta'] = regulation_meta


    c = RequestContext(request, context)

    t = select_template([
        'regulations/landing_%s.html' % label_id,
        'regulations/landing_base.html',
        'regulations/generic_landing.html'])
    return HttpResponse(t.render(c))
def regulation(request, label_id):

    context = {}
    current_version, new_version = get_versions(label_id)
    if new_version:
        context['new_version'] = new_version
    context['current_version'] = current_version

    context['label_id'] = label_id
    context['reg_first_section'] = utils.first_section(
        label_id, current_version['version'])
    context['reg_part'] = label_id.split('-')[0]

    regulation_meta = utils.regulation_meta(
        label_id,
        current_version['version'],
        True)
    context['meta'] = regulation_meta


    c = RequestContext(request, context)

    t = select_template([
        'regulations/landing_%s.html' % label_id,
        'regulations/landing_base.html',
        'regulations/generic_landing.html'])
    return HttpResponse(t.render(c))
 def test_first_section(self, fetch_toc):
     fetch_toc.return_value = [{
         'section_id': '204-100',
         'index': ['204', '100']
     }, {
         'section_id': '204-101',
         'index': ['204', '101']
     }]
     first = utils.first_section('204', '2')
     self.assertEqual(first, '204-100')
Beispiel #7
0
    def fill_kwargs(self, kwargs):
        """Add the version and replace the label_id for the chrome context"""
        reg_part = kwargs['label_id']
        if not regulation_exists(reg_part):
            raise error_handling.MissingContentException()

        current, _ = get_versions(kwargs['label_id'])
        kwargs['version'] = current['version']
        kwargs['label_id'] = utils.first_section(reg_part, current['version'])
        return kwargs
Beispiel #8
0
 def fill_kwargs(self, kwargs):
     """Get the version for the chrome context"""
     kwargs['version'] = self.request.GET.get('version', '')
     kwargs['skip_count'] = True
     if not kwargs['version']:
         current, _ = get_versions(kwargs['label_id'])
         kwargs['version'] = current['version']
     kwargs['label_id'] = utils.first_section(kwargs['label_id'],
                                              kwargs['version'])
     return kwargs
Beispiel #9
0
    def fill_kwargs(self, kwargs):
        """Add the version and replace the label_id for the chrome context"""
        reg_part = kwargs['label_id']
        if not regulation_exists(reg_part):
            raise error_handling.MissingContentException()

        current, _ = get_versions(kwargs['label_id'])
        kwargs['version'] = current['version']
        kwargs['label_id'] = utils.first_section(reg_part, current['version'])
        return kwargs
Beispiel #10
0
 def fill_kwargs(self, kwargs):
     """Get the version for the chrome context"""
     kwargs['version'] = self.request.GET.get('version', '')
     kwargs['skip_count'] = True
     if not kwargs['version']:
         current, _ = get_versions(kwargs['label_id'])
         kwargs['version'] = current['version']
     kwargs['label_id'] = utils.first_section(kwargs['label_id'],
                                              kwargs['version'])
     return kwargs
Beispiel #11
0
    def get_context_data(self, **kwargs):
        """Add the version and replace the label_id for the chrome context"""

        reg_part = kwargs['label_id']
        if not regulation_exists(reg_part):
            raise error_handling.MissingContentException()

        current, _ = get_versions(kwargs['label_id'])
        kwargs['version'] = current['version']
        kwargs['label_id'] = utils.first_section(reg_part, current['version'])
        return super(ChromeLandingView, self).get_context_data(**kwargs)
Beispiel #12
0
    def get_context_data(self, **kwargs):
        """Add the version and replace the label_id for the chrome context"""

        reg_part = kwargs['label_id']
        if not regulation_exists(reg_part):
            raise error_handling.MissingContentException()

        current, _ = get_versions(kwargs['label_id'])
        kwargs['version'] = current['version']
        kwargs['label_id'] = utils.first_section(reg_part, current['version'])
        return super(ChromeLandingView, self).get_context_data(**kwargs)
def get_regulations_list(all_versions):
    """ Given a list of regulation versions, add data about those regulations
    to that list. """

    regs = []
    reg_parts = sorted(all_versions.keys())

    for part in reg_parts:
        version = all_versions.get(part)[0]['version']
        reg_meta = utils.regulation_meta(part, version, True)
        first_section = utils.first_section(part, version)
        amendments = filter_future_amendments(all_versions.get(part, None))

        reg = {'part': part,
               'meta': reg_meta,
               'reg_first_section': first_section,
               'amendments': amendments}

        regs.append(reg)
    return regs
Beispiel #14
0
def regulation(request, label_id):

    context = {}
    current_version, new_version = get_versions(label_id)
    if new_version:
        context["new_version"] = new_version
    context["current_version"] = current_version

    context["label_id"] = label_id
    context["reg_first_section"] = utils.first_section(label_id, current_version["version"])
    context["reg_part"] = label_id.split("-")[0]

    context["meta"] = utils.regulation_meta(label_id, current_version["version"])

    c = RequestContext(request, context)

    t = select_template(
        ["regulations/landing_%s.html" % label_id, "regulations/landing_base.html", "regulations/generic_landing.html"]
    )
    return HttpResponse(t.render(c))
def get_regulations_list(all_versions):
    """ Given a list of regulation versions, add data about those regulations
    to that list. """

    regs = []
    reg_parts = sorted(all_versions.keys(), key=utils.make_sortable)

    for part in reg_parts:
        version = all_versions[part][0]['version']
        reg_meta = utils.regulation_meta(part, version)
        first_section = utils.first_section(part, version)
        amendments = filter_future_amendments(all_versions.get(part, None))

        reg = {'part': part,
               'meta': reg_meta,
               'reg_first_section': first_section,
               'amendments': amendments}

        regs.append(reg)
    return regs
 def test_first_section(self, fetch_toc):
     fetch_toc.return_value = [
         {'section_id': '204-100', 'index': ['204', '100']},
         {'section_id': '204-101', 'index': ['204', '101']}]
     first = utils.first_section('204', '2')
     self.assertEqual(first, '204-100')