Ejemplo n.º 1
0
    def testNavigationOrderMoveOverExisting(self):
        NavigationOrder(route='a', order=0).save()
        n = NavigationOrder(route='b', order=1)
        n.save()
        n.move(0)

        eq_(NavigationOrder.objects(order=0).first().route, 'b')
        eq_(NavigationOrder.objects(order=1).first().route, 'a')
Ejemplo n.º 2
0
    def testNavigationOrderPopulate(self):
        Content(route='athing', show_in_navigation=True).save()
        Content(route='bthing', show_in_navigation=True).save()
        Content(route='notathing').save()
        ContentNavigationOrder.populate_from_content()

        eq_(NavigationOrder.objects(order=0).first().route, 'athing')
        eq_(NavigationOrder.objects(order=1).first().route, 'bthing')
        eq_(NavigationOrder.objects(order=2).first(), None)
Ejemplo n.º 3
0
def navigation_move(route, order, **kwargs):
    if Content.objects(route=route).first() is None:
        raise InvalidCommand("route '{0}' does not exist in content collection".format(route))
    if Content.objects(route=route, show_in_navigation=True).first() is None:
        raise InvalidCommand("route '{0}' is not visible in navigation".format(route))
    nav_order = NavigationOrder.objects(route=route).first()
    if nav_order is None:  # This probably shouldn't happen.
        nav_order = NavigationOrder.add(route=route)
    nav_order.move(order)
Ejemplo n.º 4
0
def load_from_file(route, title, short_description, content_filename, show_in_navigation, **kwargs):
    content = Content()
    content.route = route
    content.title = title
    content.short_description = short_description
    content.show_in_navigation = show_in_navigation
    if show_in_navigation and (NavigationOrder.objects(route=route).first() is None):
        NavigationOrder.add(route=route)

    with open(content_filename) as content_file:
        content.content = '\n'.join(content_file.readlines())

    content.save()
    def test_no_nav_order(self):
        Content(route='a', show_in_navigation=True).save()
        navigation_move('a', 1)

        eq_(NavigationOrder.objects(route='a').first().order, 1)
Ejemplo n.º 6
0
 def testAddToEmpty(self):
     NavigationOrder.add('a')
     eq_(NavigationOrder.objects(route='a').first().order, 0)
Ejemplo n.º 7
0
 def testAdd(self):
     NavigationOrder(route='a', order=10).save()
     NavigationOrder.add('b')
     eq_(NavigationOrder.objects(route='b').first().order, 11)
Ejemplo n.º 8
0
    def testMoveOverSelf(self):
        n = NavigationOrder(route='a', order=0)
        n.save()
        n.move(0)

        eq_(NavigationOrder.objects(order=0).first().route, 'a')