def migrate_category_field_backwards(page_or_revision, data): data = dict(data) # If show_category is true, we need to get the first category from # the page settings categories and assign its name to the categories # field. if data.pop('show_category'): if is_page(page_or_revision): categories = page_or_revision.categories else: revision_content = json.loads(page_or_revision.content_json) categories = revision_content['categories'] try: data['category'] = categories[0]['name'] except IndexError: # If the page or revision doesn't have any categories, we'll get an # IndexError data['category'] = '' else: data['category'] = '' return data
def test_is_page_revision(self): """ Test that a revision is verifiably not a page """ self.assertFalse(is_page(self.revision))
def test_is_page_page(self): """ Test that a page is verifably a page """ self.assertTrue(is_page(self.page))