예제 #1
0
    def footer_nav(self, label, toc, old_version, new_version, from_version):
        nav = {}
        for idx, toc_entry in enumerate(toc):
            if toc_entry['section_id'] != label:
                continue

            p_sect = choose_previous_section(idx, toc)
            n_sect = choose_next_section(idx, toc)

            if p_sect:
                nav['previous'] = p_sect
                nav['previous']['url'] = reverse_chrome_diff_view(
                    p_sect['section_id'], old_version,
                    new_version, from_version)

            if n_sect:
                nav['next'] = n_sect
                nav['next']['url'] = reverse_chrome_diff_view(
                    n_sect['section_id'], old_version,
                    new_version, from_version)
        return nav
예제 #2
0
    def footer_nav(self, label, toc, old_version, new_version, from_version):
        nav = {}
        for idx, toc_entry in enumerate(toc):
            if toc_entry['section_id'] != label:
                continue

            p_sect = choose_previous_section(idx, toc)
            n_sect = choose_next_section(idx, toc)

            if p_sect:
                nav['previous'] = p_sect
                nav['previous']['url'] = reverse_chrome_diff_view(
                    p_sect['section_id'], old_version, new_version,
                    from_version)

            if n_sect:
                nav['next'] = n_sect
                nav['next']['url'] = reverse_chrome_diff_view(
                    n_sect['section_id'], old_version, new_version,
                    from_version)
        return nav
 def test_choose_next_section(self):
     l = [1, 2, 3]
     self.assertEquals(3, navigation.choose_next_section(1, l))
     self.assertEquals(None, navigation.choose_next_section(2, l))
 def test_choose_next_section(self):
     l = [1, 2, 3]
     self.assertEquals(3, navigation.choose_next_section(1, l))
     self.assertEquals(None, navigation.choose_next_section(2, l))