Exemplo n.º 1
0
 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()
Exemplo n.º 2
0
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
Exemplo n.º 3
0
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
Exemplo n.º 4
0
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