コード例 #1
0
ファイル: diff.py プロジェクト: Scotchester/regulations-site
    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 test_choose_previous_section(self):
     l = [1,  2, 3]
     self.assertEquals(1, navigation.choose_previous_section(1, l))
     self.assertEquals(2, navigation.choose_previous_section(2, l))
     self.assertEquals(None, navigation.choose_previous_section(0, l))