def test_basic(self):
        register_dynamic_trees(
            (
                compose_dynamic_tree(
                    (
                        tree(
                            "dynamic_main_root",
                            items=(
                                item("dynamic_main_root_1", "dynamic_main_root_1_url", url_as_pattern=False),
                                item("dynamic_main_root_2", "dynamic_main_root_2_url", url_as_pattern=False),
                            ),
                        ),
                    ),
                    target_tree_alias="main",
                ),
                compose_dynamic_tree(
                    (
                        tree(
                            "dynamic_main_sub",
                            items=(
                                item("dynamic_main_sub_1", "dynamic_main_sub_1_url", url_as_pattern=False),
                                item("dynamic_main_sub_2", "dynamic_main_sub_2_url", url_as_pattern=False),
                            ),
                        ),
                    ),
                    target_tree_alias="main",
                    parent_tree_item_alias="for_dynamic",
                ),
                compose_dynamic_tree(
                    (
                        tree(
                            "dynamic",
                            items=(
                                item(
                                    "dynamic_1",
                                    "dynamic_1_url",
                                    children=(item("dynamic_1_sub_1", "dynamic_1_sub_1_url", url_as_pattern=False),),
                                    url_as_pattern=False,
                                ),
                                item("dynamic_2", "dynamic_2_url", url_as_pattern=False),
                            ),
                        ),
                    )
                ),
            )
        )

        self.sitetree._global_context = get_mock_context(path="/the_same_url/")
        tree_alias, sitetree_items = self.sitetree.get_sitetree("main")
        self.assertEqual(len(sitetree_items), 5)
        self.assertEqual(sitetree_items[3].title, "dynamic_main_root_1")
        self.assertEqual(sitetree_items[4].title, "dynamic_main_root_2")
        children = self.sitetree.get_children("main", self.t1_root)
        self.assertEqual(len(children), 2)

        tree_alias, sitetree_items = self.sitetree.get_sitetree("dynamic")
        self.assertEqual(len(sitetree_items), 3)
        children = self.sitetree.get_children("dynamic", sitetree_items[0])
        self.assertEqual(len(children), 1)
Exemple #2
0
    def basic_test(self, new_style=False, reset_cache=False):
        trees = (
            compose_dynamic_tree((tree('dynamic_main_root',
                                       items=(
                                           item('dynamic_main_root_1',
                                                'dynamic_main_root_1_url',
                                                url_as_pattern=False),
                                           item('dynamic_main_root_2',
                                                'dynamic_main_root_2_url',
                                                url_as_pattern=False),
                                       )), ),
                                 target_tree_alias='main'),
            compose_dynamic_tree((tree('dynamic_main_sub',
                                       items=(
                                           item('dynamic_main_sub_1',
                                                'dynamic_main_sub_1_url',
                                                url_as_pattern=False),
                                           item('dynamic_main_sub_2',
                                                'dynamic_main_sub_2_url',
                                                url_as_pattern=False),
                                       )), ),
                                 target_tree_alias='main',
                                 parent_tree_item_alias='for_dynamic'),
            compose_dynamic_tree(
                (tree('dynamic',
                      items=(
                          item('dynamic_1',
                               'dynamic_1_url',
                               children=(item('dynamic_1_sub_1',
                                              'dynamic_1_sub_1_url',
                                              url_as_pattern=False), ),
                               url_as_pattern=False),
                          item('dynamic_2',
                               'dynamic_2_url',
                               url_as_pattern=False),
                      )), )),
        )

        kwargs = {'reset_cache': reset_cache}

        if new_style:
            register_dynamic_trees(*trees, **kwargs)
        else:
            register_dynamic_trees(trees, **kwargs)

        self.sitetree._global_context = get_mock_context(path='/the_same_url/')
        tree_alias, sitetree_items = self.sitetree.get_sitetree('main')

        self.assertEqual(len(sitetree_items), 5)
        self.assertEqual(sitetree_items[3].title, 'dynamic_main_root_1')
        self.assertEqual(sitetree_items[4].title, 'dynamic_main_root_2')
        children = self.sitetree.get_children('main', self.t1_root)
        self.assertEqual(len(children), 2)

        tree_alias, sitetree_items = self.sitetree.get_sitetree('dynamic')
        self.assertEqual(len(sitetree_items), 3)
        children = self.sitetree.get_children('dynamic', sitetree_items[0])
        self.assertEqual(len(children), 1)
Exemple #3
0
def register_sitetrees():
    sitetreeapp._DYNAMIC_TREES.clear()
    cache.delete('sitetrees')
    register_i18n_trees(['mainmenu', 'competition_admin', 'footermenu'])
    try:
        register_dynamic_trees((
            compose_dynamic_tree(sitetrees_build('lv'), target_tree_alias='mainmenu_lv', parent_tree_item_alias='sacensibas'),
            compose_dynamic_tree(sitetrees_build('en'), target_tree_alias='mainmenu_en', parent_tree_item_alias='sacensibas'),
            compose_dynamic_tree(sitetrees_build('ru'), target_tree_alias='mainmenu_ru', parent_tree_item_alias='sacensibas'),
            compose_dynamic_tree('velo.manager', target_tree_alias='mainmenu_lv', parent_tree_item_alias='manager'),
        ), reset_cache=True)
    except ProgrammingError:
        print('Seems that migrations should be run.')
    def test_basic(self):
        register_dynamic_trees((
            compose_dynamic_tree((tree('dynamic_main_root',
                                       items=(
                                           item('dynamic_main_root_1',
                                                'dynamic_main_root_1_url',
                                                url_as_pattern=False),
                                           item('dynamic_main_root_2',
                                                'dynamic_main_root_2_url',
                                                url_as_pattern=False),
                                       )), ),
                                 target_tree_alias='main'),
            compose_dynamic_tree((tree('dynamic_main_sub',
                                       items=(
                                           item('dynamic_main_sub_1',
                                                'dynamic_main_sub_1_url',
                                                url_as_pattern=False),
                                           item('dynamic_main_sub_2',
                                                'dynamic_main_sub_2_url',
                                                url_as_pattern=False),
                                       )), ),
                                 target_tree_alias='main',
                                 parent_tree_item_alias='for_dynamic'),
            compose_dynamic_tree(
                (tree('dynamic',
                      items=(
                          item('dynamic_1',
                               'dynamic_1_url',
                               children=(item('dynamic_1_sub_1',
                                              'dynamic_1_sub_1_url',
                                              url_as_pattern=False), ),
                               url_as_pattern=False),
                          item('dynamic_2',
                               'dynamic_2_url',
                               url_as_pattern=False),
                      )), )),
        ))

        self.sitetree._global_context = get_mock_context(path='/the_same_url/')
        tree_alias, sitetree_items = self.sitetree.get_sitetree('main')
        self.assertEqual(len(sitetree_items), 5)
        self.assertEqual(sitetree_items[3].title, 'dynamic_main_root_1')
        self.assertEqual(sitetree_items[4].title, 'dynamic_main_root_2')
        children = self.sitetree.get_children('main', self.t1_root)
        self.assertEqual(len(children), 2)

        tree_alias, sitetree_items = self.sitetree.get_sitetree('dynamic')
        self.assertEqual(len(sitetree_items), 3)
        children = self.sitetree.get_children('dynamic', sitetree_items[0])
        self.assertEqual(len(children), 1)
Exemple #5
0
    def build_sitetree(cls, **kwargs):
        """Строит динамическое дерево справочника под именем `references`."""
        root_id = object()

        root_item = get_sitetree_root_item()
        temp_ref_items = {root_id: root_item}

        ref_items = list(cls.model.get_actual().select_related('parent').only(
            'id', 'parent_id', 'parent__title', 'slug',
            'status').order_by('parent_id', 'title', 'id'))

        def get_tree_item(ref_item):
            item_id = getattr(ref_item, 'id', root_id)
            tree_item = temp_ref_items.get(item_id)

            if not tree_item:
                tree_item = item(ref_item.title,
                                 ref_item.get_absolute_url(),
                                 url_as_pattern=False)
                temp_ref_items[item_id] = tree_item

            return tree_item

        for ref_item in ref_items:
            parent = get_tree_item(ref_item.parent)
            child = get_tree_item(ref_item)

            child.parent = parent
            parent.dynamic_children.append(child)

        from sitetree.sitetreeapp import register_dynamic_trees, compose_dynamic_tree
        register_dynamic_trees(compose_dynamic_tree(
            [tree('references', items=[root_item])]),
                               reset_cache=True)
Exemple #6
0
def build_sitetree():
    """Строит древо сайта, исходя из достпных областей сайта.

    :return:
    """
    from sitetree.sitetreeapp import register_dynamic_trees, compose_dynamic_tree  # Потакаем поведению Django 1.7 при загрузке приложений.
    register_dynamic_trees(
        compose_dynamic_tree((
            tree('main', 'Основное дерево', (
                item('PYTHONZ', '/', alias='topmenu', url_as_pattern=False, children=(realm.get_sitetree_items() for realm in get_realms())),
                item('Вход', 'login', access_guest=True, in_menu=False, in_breadcrumbs=False),
                item('Личное меню', '#', alias='personal', url_as_pattern=False, access_loggedin=True, in_menu=False, in_sitetree=False, children=(
                    item('Профиль', 'users:details request.user.id', access_loggedin=True, in_breadcrumbs=False, in_sitetree=False),
                    item('Настройки', 'users:edit request.user.id', access_loggedin=True, in_breadcrumbs=False, in_sitetree=False),
                    item('Выход', 'logout', access_loggedin=True, in_breadcrumbs=False, in_sitetree=False),
                )),

            )),
            tree('about', 'О проекте', (
                item('Что такое Python', '/promo/', url_as_pattern=False),
                item('О проекте', '/about/', url_as_pattern=False),
                item('Карта сайта', '/sitemap/', url_as_pattern=False),
                item('Поиск по сайту', '/search/', url_as_pattern=False),
            ))
        )),
        reset_cache=True
    )
Exemple #7
0
    def build_sitetree(cls, **kwargs):
        """Строит динамическое дерево справочника под именем `references`."""
        root_id = object()

        root_item = get_sitetree_root_item()
        temp_ref_items = {root_id: root_item}

        ref_items = list(cls.model.get_actual().select_related('parent').only(
            'id', 'parent_id', 'parent__title', 'slug', 'status'
        ).order_by('parent_id', 'title', 'id'))

        def get_tree_item(ref_item):
            item_id = getattr(ref_item, 'id', root_id)
            tree_item = temp_ref_items.get(item_id)

            if not tree_item:
                tree_item = item(ref_item.title, ref_item.get_absolute_url(), url_as_pattern=False)
                temp_ref_items[item_id] = tree_item

            return tree_item

        for ref_item in ref_items:
            parent = get_tree_item(ref_item.parent)
            child = get_tree_item(ref_item)

            child.parent = parent
            parent.dynamic_children.append(child)

        from sitetree.sitetreeapp import register_dynamic_trees, compose_dynamic_tree
        register_dynamic_trees(compose_dynamic_tree([tree('references', items=[root_item])]), reset_cache=True)
Exemple #8
0
    def basic_test(self, new_style=False, reset_cache=False):
        trees = (
            compose_dynamic_tree((
                tree('dynamic_main_root', items=(
                    item('dynamic_main_root_1', 'dynamic_main_root_1_url', url_as_pattern=False),
                    item('dynamic_main_root_2', 'dynamic_main_root_2_url', url_as_pattern=False),
                )),
            ), target_tree_alias='main'),
            compose_dynamic_tree((
                tree('dynamic_main_sub', items=(
                    item('dynamic_main_sub_1', 'dynamic_main_sub_1_url', url_as_pattern=False),
                    item('dynamic_main_sub_2', 'dynamic_main_sub_2_url', url_as_pattern=False),
                )),
            ), target_tree_alias='main', parent_tree_item_alias='for_dynamic'),
            compose_dynamic_tree((
                tree('dynamic', items=(
                    item('dynamic_1', 'dynamic_1_url', children=(
                        item('dynamic_1_sub_1', 'dynamic_1_sub_1_url', url_as_pattern=False),
                    ), url_as_pattern=False),
                    item('dynamic_2', 'dynamic_2_url', url_as_pattern=False),
                )),
            )),
        )

        kwargs = {
            'reset_cache': reset_cache
        }

        if new_style:
            register_dynamic_trees(*trees, **kwargs)
        else:
            register_dynamic_trees(trees, **kwargs)

        self.sitetree._global_context = get_mock_context(path='/the_same_url/')
        tree_alias, sitetree_items = self.sitetree.get_sitetree('main')

        self.assertEqual(len(sitetree_items), 5)
        self.assertEqual(sitetree_items[3].title, 'dynamic_main_root_1')
        self.assertEqual(sitetree_items[4].title, 'dynamic_main_root_2')
        children = self.sitetree.get_children('main', self.t1_root)
        self.assertEqual(len(children), 2)


        tree_alias, sitetree_items = self.sitetree.get_sitetree('dynamic')
        self.assertEqual(len(sitetree_items), 3)
        children = self.sitetree.get_children('dynamic', sitetree_items[0])
        self.assertEqual(len(children), 1)
Exemple #9
0
    def test_basic(self):
        register_dynamic_trees((
            compose_dynamic_tree((
                tree('dynamic_main_root', items=(
                    item('dynamic_main_root_1', 'dynamic_main_root_1_url', url_as_pattern=False),
                    item('dynamic_main_root_2', 'dynamic_main_root_2_url', url_as_pattern=False),
                )),
            ), target_tree_alias='main'),
            compose_dynamic_tree((
                tree('dynamic_main_sub', items=(
                    item('dynamic_main_sub_1', 'dynamic_main_sub_1_url', url_as_pattern=False),
                    item('dynamic_main_sub_2', 'dynamic_main_sub_2_url', url_as_pattern=False),
                )),
            ), target_tree_alias='main', parent_tree_item_alias='for_dynamic'),
            compose_dynamic_tree((
                tree('dynamic', items=(
                    item('dynamic_1', 'dynamic_1_url', children=(
                        item('dynamic_1_sub_1', 'dynamic_1_sub_1_url', url_as_pattern=False),
                    ), url_as_pattern=False),
                    item('dynamic_2', 'dynamic_2_url', url_as_pattern=False),
                )),
            )),
        ))

        self.sitetree._global_context = get_mock_context(path='/the_same_url/')
        tree_alias, sitetree_items = self.sitetree.get_sitetree('main')
        self.assertEqual(len(sitetree_items), 5)
        self.assertEqual(sitetree_items[3].title, 'dynamic_main_root_1')
        self.assertEqual(sitetree_items[4].title, 'dynamic_main_root_2')
        children = self.sitetree.get_children('main', self.t1_root)
        self.assertEqual(len(children), 2)


        tree_alias, sitetree_items = self.sitetree.get_sitetree('dynamic')
        self.assertEqual(len(sitetree_items), 3)
        children = self.sitetree.get_children('dynamic', sitetree_items[0])
        self.assertEqual(len(children), 1)
Exemple #10
0
def build_sitetree():
    """Строит древо сайта, исходя из доступных областей сайта.

    :return:
    """
    # Потакаем поведению Django 1.7 при загрузке приложений.
    from sitetree.sitetreeapp import register_dynamic_trees, compose_dynamic_tree
    register_dynamic_trees(
        compose_dynamic_tree((
            tree('main', 'Основное дерево', (
                get_sitetree_root_item((realm.get_sitetree_items() for realm in get_realms().values())),
                item('Вход', 'login', access_guest=True, in_menu=False, in_breadcrumbs=False),
                item('', '/', alias='personal', url_as_pattern=False, access_loggedin=True, in_menu=False,
                     in_sitetree=False, children=(
                        item('Профиль', 'users:details request.user.id', access_loggedin=True, in_breadcrumbs=True,
                             in_sitetree=False),
                        item('Настройки', 'users:edit request.user.id', access_loggedin=True, in_breadcrumbs=True,
                             in_sitetree=False),
                        item('Выход', 'logout', access_loggedin=True, in_breadcrumbs=False, in_sitetree=False),
                )),

            )),
            tree('about', 'О проекте', (
                item('Что такое Python', '/promo/',
                     description='Краткие сведения о возможностях и областях применения языка программирования Python.',
                     url_as_pattern=False),
                item('О проекте', '/about/',
                     description='Информация о проекте. О том, как, кем и для чего разрабатывается данный сайт.',
                     url_as_pattern=False),
                item('Карта сайта', '/sitemap/', description='Список разделов на сайте оформленный в виде карты сайта.',
                     url_as_pattern=False),
                item('Поиск по сайту', '/search/site/',
                     description='Глобальный поиск по материалам, расположенным на сайте.',
                     url_as_pattern=False),
                item('Результаты поиска «{{ search_term }}»', '/search/', url_as_pattern=False, in_menu=False,
                     in_sitetree=False),
            ))
        )),
        reset_cache=True
    )

    ReferenceRealm.build_sitetree()
Exemple #11
0
def build_sitetree():
    """Строит древо сайта, исходя из доступных областей сайта.

    :return:
    """
    # Потакаем поведению Django 1.7 при загрузке приложений.
    from sitetree.sitetreeapp import register_dynamic_trees, compose_dynamic_tree
    register_dynamic_trees(
        compose_dynamic_tree((
            tree('main', 'Основное дерево', (
                get_sitetree_root_item((realm.get_sitetree_items() for realm in get_realms().values())),
                item('Вход', 'login', access_guest=True, in_menu=False, in_breadcrumbs=False),
                item('Личное меню', '#', alias='personal', url_as_pattern=False, access_loggedin=True, in_menu=False,
                     in_sitetree=False, children=(
                        item('Профиль', 'users:details request.user.id', access_loggedin=True, in_breadcrumbs=False,
                             in_sitetree=False),
                        item('Настройки', 'users:edit request.user.id', access_loggedin=True, in_breadcrumbs=False,
                             in_sitetree=False),
                        item('Выход', 'logout', access_loggedin=True, in_breadcrumbs=False, in_sitetree=False),
                )),

            )),
            tree('about', 'О проекте', (
                item('Что такое Python', '/promo/',
                     description='Краткие сведения о возможностях и областях применения языка программирования Python.',
                     url_as_pattern=False),
                item('О проекте', '/about/',
                     description='Информация о проекте. О том, как, кем и для чего разрабатывается данный сайт.',
                     url_as_pattern=False),
                item('Карта сайта', '/sitemap/', description='Список разделов на сайте оформленный в виде карты сайта.',
                     url_as_pattern=False),
                item('Поиск по сайту', '/search/site/',
                     description='Глобальный поиск по материалам, расположенным на сайте.',
                     url_as_pattern=False),
                item('Результаты поиска «{{ search_term }}»', '/search/', url_as_pattern=False, in_menu=False,
                     in_sitetree=False),
            ))
        )),
        reset_cache=True
    )

    ReferenceRealm.build_sitetree()
Exemple #12
0
def build_sitetree():
    """Строит древо сайта, исходя из доступных областей сайта.

    :return:
    """
    # Потакаем поведению Django 1.7 при загрузке приложений.
    from sitetree.sitetreeapp import register_dynamic_trees, compose_dynamic_tree
    register_dynamic_trees(
        compose_dynamic_tree((
            tree('main', 'Основное дерево', (
                item('Про Python', '/', alias='topmenu', url_as_pattern=False,
                     description='Материалы по языку программирования Python. Книги, видео, сообщества '
                                 'и многое другое.',
                     children=(realm.get_sitetree_items() for realm in get_realms().values())),
                item('Вход', 'login', access_guest=True, in_menu=False, in_breadcrumbs=False),
                item('Личное меню', '#', alias='personal', url_as_pattern=False, access_loggedin=True, in_menu=False,
                     in_sitetree=False, children=(
                        item('Профиль', 'users:details request.user.id', access_loggedin=True, in_breadcrumbs=False,
                             in_sitetree=False),
                        item('Настройки', 'users:edit request.user.id', access_loggedin=True, in_breadcrumbs=False,
                             in_sitetree=False),
                        item('Выход', 'logout', access_loggedin=True, in_breadcrumbs=False, in_sitetree=False),
                )),

            )),
            tree('about', 'О проекте', (
                item('Что такое Python', '/promo/', description='Краткие сведения о языке программирования Python.',
                     url_as_pattern=False),
                item('О проекте', '/about/', description='Информация о проекте pythonz.net.', url_as_pattern=False),
                item('Карта сайта', '/sitemap/', description='Список разделов проекта pythonz.net.',
                     url_as_pattern=False),
                item('Поиск по сайту', '/search/site/', url_as_pattern=False),
                item('Результаты поиска «{{ search_term }}»', '/search/', url_as_pattern=False, in_menu=False,
                     in_sitetree=False),
            ))
        )),
        reset_cache=True
    )
Exemple #13
0
WIKI_SLUG = r"(([\w-]{2,})(/[\w-]{2,})*)"

urlpatterns = i18n_patterns(
    path("", TemplateView.as_view(template_name="homepage.html"), name="home"),
    path("speakers/", include("ilpycon.symposion.speakers.urls")),
    path("dashboard/", dashboard, name="dashboard"),
)

urlpatterns += [
    path("admin/", admin.site.urls),
    path("i18n/", include('ilpycon.i18n')),
    path("account/", include("account.urls")),

    path("proposals/", include("ilpycon.symposion.proposals.urls")),
    path("sponsors/", include("ilpycon.symposion.sponsorship.urls")),
    path("boxes/", include("pinax.boxes.urls")),
    path("teams/", include("ilpycon.symposion.teams.urls")),
    path("reviews/", include("ilpycon.symposion.reviews.urls")),
    path("schedule/", include("ilpycon.symposion.schedule.urls")),
    path(r"blog/", include("pinax.blog.urls", namespace="pinax_blog")),
    path(r"ajax/images/", include("pinax.images.urls",
                                   namespace="pinax_images")),
    path("", include("pinax.pages.urls", namespace="pinax_pages"))
]

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

register_dynamic_trees(compose_dynamic_tree('ilpycon'), reset_cache=True)
register_i18n_trees(['main'])
Exemple #14
0
from registration.views import ApplicationUpdate, ApplicationCreate, CompanyApplicationCreate, CompanyApplicationDetail, \
    CompanyApplicationParticipantAdd, MyCompanyApplicationList, CompanyApplicationParticipantAddOK, \
    CompanyApplicationUpdate, ParticipantPDF
from results.views import ResultAllView
from supporter.views import AgencySupporters
from velo.views import CustomAutoResponseView


admin.autodiscover()


register_i18n_trees(['mainmenu', 'competition_admin'])

try:
    register_dynamic_trees((
        compose_dynamic_tree('core', target_tree_alias='mainmenu_lv', parent_tree_item_alias='sacensibas'),
    ))
    register_dynamic_trees((
        compose_dynamic_tree('manager', target_tree_alias='mainmenu_lv', parent_tree_item_alias='manager'),
    ))
except ProgrammingError:
    print 'Seems that migrations should be run.'



js_info_dict = {
    # Not yet used
}

urlpatterns = i18n_patterns('',
    #url(r'^$', RedirectView.as_view(url='/lv/sacensibas/42/rezultati/'), name='index'),
Exemple #15
0
    # Filter by user/group urls
    url(
        r'^(?P<group_slug>[-_\w\d]+)/(?P<project_type>[-_\w\d]+)/(?P<project_slug>[-_\w\d]+)/(?P<layer_id>[0-9]+)/'
        r'filterbyuser/$',
        login_required(FilterByUserLayerView.as_view()),
        name='fitler-by-user-layer'),
]

try:
    # encaspulate in a try except procedure for migration
    from sitetree.sitetreeapp import register_dynamic_trees, compose_dynamic_tree

    #get qdjango sitetree and add items to core sitetree:

    register_dynamic_trees(compose_dynamic_tree(
        'qdjango',
        target_tree_alias='core',
        parent_tree_item_alias='project-list',
        include_trees=('qdjango', )),
                           reset_cache=True)
    register_dynamic_trees(compose_dynamic_tree(
        'qdjango',
        target_tree_alias='core_en',
        parent_tree_item_alias='project-list',
        include_trees=('qdjango_en', )),
                           reset_cache=True)

except:
    pass
Exemple #16
0
def build_sitetree():
    """Строит древо сайта, исходя из доступных областей сайта.

    :return:
    """
    # Потакаем поведению Django 1.7 при загрузке приложений.
    from sitetree.sitetreeapp import register_dynamic_trees, compose_dynamic_tree
    register_dynamic_trees(compose_dynamic_tree(
        (tree('main', 'Основное дерево', (
            item(
                'Про Python',
                '/',
                alias='topmenu',
                url_as_pattern=False,
                description=
                'Материалы по языку программирования Python. Книги, видео, сообщества '
                'и многое другое.',
                children=(realm.get_sitetree_items()
                          for realm in get_realms().values())),
            item('Вход',
                 'login',
                 access_guest=True,
                 in_menu=False,
                 in_breadcrumbs=False),
            item('Личное меню',
                 '#',
                 alias='personal',
                 url_as_pattern=False,
                 access_loggedin=True,
                 in_menu=False,
                 in_sitetree=False,
                 children=(
                     item('Профиль',
                          'users:details request.user.id',
                          access_loggedin=True,
                          in_breadcrumbs=False,
                          in_sitetree=False),
                     item('Настройки',
                          'users:edit request.user.id',
                          access_loggedin=True,
                          in_breadcrumbs=False,
                          in_sitetree=False),
                     item('Выход',
                          'logout',
                          access_loggedin=True,
                          in_breadcrumbs=False,
                          in_sitetree=False),
                 )),
        )),
         tree('about', 'О проекте', (
             item('Что такое Python',
                  '/promo/',
                  description=
                  'Краткие сведения о языке программирования Python.',
                  url_as_pattern=False),
             item('О проекте',
                  '/about/',
                  description='Информация о проекте pythonz.net.',
                  url_as_pattern=False),
             item('Карта сайта',
                  '/sitemap/',
                  description='Список разделов проекта pythonz.net.',
                  url_as_pattern=False),
             item('Поиск по сайту', '/search/site/', url_as_pattern=False),
             item('Результаты поиска «{{ search_term }}»',
                  '/search/',
                  url_as_pattern=False,
                  in_menu=False,
                  in_sitetree=False),
         )))),
                           reset_cache=True)
Exemple #17
0
from django.conf.urls import url, include, patterns
from sitetree.sitetreeapp import register_dynamic_trees, compose_dynamic_tree
from sitetrees import dynamic_sitetrees
from .views import imovel, quadra, lado, bairro, logradouro, municipio, uf

urlpatterns = patterns(
    '',
    url(r'^imovel/', include(imovel.urls, 'imovel')),
    url(r'^quadra/', include(quadra.urls, 'quadra')),
    url(r'^quadra/lado/', include(lado.urls, 'ladoquadra')),
    url(r'^bairro/', include(bairro.urls, 'bairro')),
    url(r'^logradouro/', include(logradouro.urls, 'logradouro')),
    url(r'^municipio/', include(municipio.urls, 'municipio')),
    url(r'^uf/', include(uf.urls, 'uf'))

)

register_dynamic_trees(
    compose_dynamic_tree(dynamic_sitetrees, target_tree_alias='main',
                         parent_tree_item_alias='home'),
    reset_cache=True
)
Exemple #18
0
# -*- coding: utf-8 -*-

from .models import *
from sitetree.sitetreeapp import register_dynamic_trees, compose_dynamic_tree
from sitetree.utils import tree, item

print '----------------------------------'
register_dynamic_trees((

    # Gather all the trees from `catalog`,
    #compose_dynamic_tree('catalog'),

    # or gather all the trees from `catalog` and attach them to `main` tree root,
    compose_dynamic_tree('catalog', target_tree_alias='TopMenu'),

    # or gather all the trees from `catalog` and attach them to `for_catalog` aliased item in `main` tree,
    #compose_dynamic_tree('catalog', target_tree_alias='main', parent_tree_item_alias='for_catalog'),

    # or even define a tree right at the process of registration.
    #compose_dynamic_tree((
    #    tree('dynamic', items=(
    #        item('dynamic_1', 'dynamic_1_url', children=(
    #            item('dynamic_1_sub_1', 'dynamic_1_sub_1_url'),
    #        )),
    #        item('dynamic_2', 'dynamic_2_url'),
    #    )),
    #)),
))
Exemple #19
0
    def basic_test(self, new_style=False, reset_cache=False):
        trees = (
            compose_dynamic_tree((
                tree('dynamic_main_root', items=(
                    item('dynamic_main_root_1', 'dynamic_main_root_1_url', url_as_pattern=False, sort_order=2),
                    item('dynamic_main_root_2', 'dynamic_main_root_2_url', url_as_pattern=False, sort_order=1),
                )),
            ), target_tree_alias='main'),
            compose_dynamic_tree((
                tree('dynamic_main_sub', items=(
                    item('dynamic_main_sub_1', 'dynamic_main_sub_1_url',
                         url_as_pattern=False, access_by_perms=['auth.add_group', 'auth.change_group']),
                    item('dynamic_main_sub_2', 'dynamic_main_sub_2_url',
                         url_as_pattern=False, access_by_perms=['auth.add_group'], perms_mode_all=False),
                )),
            ), target_tree_alias='main', parent_tree_item_alias='for_dynamic'),
            compose_dynamic_tree((
                tree('dynamic', items=(
                    item('dynamic_1', 'dynamic_1_url', children=(
                        item('dynamic_1_sub_1', 'dynamic_1_sub_1_url', url_as_pattern=False),
                    ), url_as_pattern=False),
                    item('dynamic_2', 'dynamic_2_url', url_as_pattern=False),
                )),
            )),
        )

        kwargs = {
            'reset_cache': reset_cache
        }

        if new_style:
            register_dynamic_trees(*trees, **kwargs)
        else:
            register_dynamic_trees(trees, **kwargs)

        mock_context = get_mock_context(path='/the_same_url/')
        self.sitetree._global_context = mock_context
        tree_alias, sitetree_items = self.sitetree.get_sitetree('main')

        if reset_cache:
            self.assertEqual(len(sitetree_items), 13)
            children = self.sitetree.get_children('main', self.tree_main_root)
            self.assertEqual(len(children), 6)
            tree_alias, sitetree_items = self.sitetree.get_sitetree('dynamic')
            self.assertEqual(len(sitetree_items), 9)
            children = self.sitetree.get_children('dynamic', sitetree_items[0])
            self.assertEqual(len(children), 1)

        else:

            mock_user = MockUser(True)
            self.assertFalse(self.sitetree.check_access(sitetree_items[1], {'user': mock_user}))
            self.assertTrue(self.sitetree.check_access(sitetree_items[2], {'user': mock_user}))
            self.assertFalse(self.sitetree.check_access(sitetree_items[2], {
                'user': MockUser(True, permissions=['dummy.dummy'])}))

            self.assertEqual(len(sitetree_items), 5)
            self.assertEqual(sitetree_items[1].perms, set(['auth.add_group', 'auth.change_group']))
            self.assertEqual(sitetree_items[3].title, 'dynamic_main_root_1')
            self.assertEqual(sitetree_items[4].title, 'dynamic_main_root_2')
            self.assertEqual(sitetree_items[3].sort_order, 2)
            self.assertEqual(sitetree_items[4].sort_order, 1)
            self.assertIsNone(getattr(sitetree_items[3], 'perms', None))
            children = self.sitetree.get_children('main', self.tree_main_root)
            self.assertEqual(len(children), 2)

            tree_alias, sitetree_items = self.sitetree.get_sitetree('dynamic')
            self.assertEqual(len(sitetree_items), 3)
            children = self.sitetree.get_children('dynamic', sitetree_items[0])
            self.assertEqual(len(children), 1)
Exemple #20
0
                        'placeholder': placeholder})
        return context

plugin_pool.register_plugin(CMSCategoryEntriesPlugin)

from sitetree.sitetreeapp import register_dynamic_trees, compose_dynamic_tree
from sitetree.utils import tree, item

 
items_cat = {}
entries = Entry.published.all() #@UndefinedVariable
for entry in entries:
    node = item(entry.title, entry.get_absolute_url(), url_as_pattern=False)
    node.title_ru = entry.title_ru
    cats = entry.categories.all()[:1]
    if not cats:
        continue      
    cat = entry.categories.all()[:1][0].slug
    if not cat in items_cat:
        items_cat[cat] = []
    items_cat[cat].append(node)  

for key, value in items_cat.iteritems():    
    register_dynamic_trees((   
        compose_dynamic_tree((
            tree('dynamic', title='dynamic', items=value),
        ), target_tree_alias='mainmenu',  parent_tree_item_alias=key),
    ))