示例#1
0
class MenuFactory(object):
    def __init__(self):
        self.locallink = None
        self.menu = None

    def create_menu_factory(self):
        self.locallink = MenuLocalLink(name='testlink',
                                       local_link='/testing_menu/')
        self.locallink.save()
        locallink_type = ContentType.objects.get(app_label="www",
                                                 model="menulocallink")
        self.menu_navigation_middleware = MenuNavigationMiddleWare()
        self.menu = CMSMenu(menu_name='Testing Menu',
                            display=True,
                            slug='testing_menu',
                            language=Language.objects.get_default(),
                            content_type=locallink_type,
                            object_id=self.locallink.id)
        self.menu.save()
        self.menu2 = CMSMenu(menu_name='Testing Menu2',
                             display=True,
                             parent=self.menu,
                             slug='testing_menu2',
                             language=Language.objects.get_default(),
                             content_type=locallink_type,
                             object_id=self.locallink.id)
        self.menu2.save()
        return self.menu, self.menu2, self.locallink, self.menu_navigation_middleware

    def clean_menu_factory(self):
        self.menu.delete()
        self.menu2.delete()
        self.locallink.delete()
示例#2
0
class MenuFactory(object):
    def __init__(self):
        self.locallink = None
        self.menu = None
        
    def create_menu_factory(self):
        self.locallink = MenuLocalLink(name='testlink', local_link='/testing_menu/')
        self.locallink.save()
        locallink_type = ContentType.objects.get(app_label="www", model="menulocallink")
        self.menu_navigation_middleware = MenuNavigationMiddleWare()
        self.menu = CMSMenu(menu_name='Testing Menu'
                       ,display=True
                       ,slug='testing_menu'
                       ,language=Language.objects.get_default()
                       ,content_type=locallink_type
                       ,object_id=self.locallink.id
                       )
        self.menu.save()
        self.menu2 = CMSMenu(menu_name='Testing Menu2'
                       ,display=True
                       ,parent=self.menu
                       ,slug='testing_menu2'
                       ,language=Language.objects.get_default()
                       ,content_type=locallink_type
                       ,object_id=self.locallink.id
                       )
        self.menu2.save()
        return self.menu, self.menu2, self.locallink, self.menu_navigation_middleware

    def clean_menu_factory(self):
        self.menu.delete()
        self.menu2.delete()
        self.locallink.delete()
示例#3
0
    def save(self, *args, **kwargs):
        if not self.app_slug:
            self.app_slug='www'
        super(BasicPage, self).save()

        from django.contrib.contenttypes.models import ContentType
        this_content_type = ContentType.objects.get_for_model(self.__class__)        
        if not CMSMenu.objects.has_menu_for_page(self):
            menu = CMSMenu(display=False, language=self.language
                           ,slug=self.slug
                           ,content_type=this_content_type, object_id=self.id)
            menu.save()

        super(BasicPage, self).save(*args, **kwargs)