def test_can_create_simple_tag(self): tag = Tag() tag.name = 'shouldBeName' tag.slug = 'shouldBeSlug' tag.save() tag_find = Tag.objects.get(name=tag.name) self.assertEquals(tag_find.name, tag.name) self.assertEquals(tag_find.slug, tag.slug) self.assertEquals(tag_find.id, tag.id) tag.delete()
def delete_orphaned_tags(): ''' Cleans up tags that no longer have any page associations. ''' orphaned_tags = Tag.delete().where( ~Tag.id << (TagAssociation.select(TagAssociation.tag))) orphaned_tags.execute() return orphaned_tags
def delete_orphaned_tags(blog): ''' Cleans up tags that no longer have any page associations. :param blog: A blog object used as the context for this cleanup. ''' orphaned_tags = Tag.delete().where( Tag.blog == blog, ~ Tag.id << (TagAssociation.select(TagAssociation.tag))) orphaned_tags.execute() return orphaned_tags
def delete_orphaned_tags(blog): ''' Cleans up tags that no longer have any page associations. :param blog: A blog object used as the context for this cleanup. ''' orphaned_tags = Tag.delete().where( Tag.blog == blog, ~Tag.id << (TagAssociation.select(TagAssociation.tag))) orphaned_tags.execute() return orphaned_tags