本文整理汇总了Python中sitetree.utils.item函数的典型用法代码示例。如果您正苦于以下问题:Python item函数的具体用法?Python item怎么用?Python item使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了item函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: build_sitetree
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
)
开发者ID:cesaiskra,项目名称:pythonz,代码行数:27,代码来源:realms.py
示例2: test_access_restricted
def test_access_restricted(self):
# Test that default is False
i0 = item('root', 'url', access_by_perms=1)
self.assertEqual(i0.access_restricted, True)
# True is respected
i1 = item('root', 'url')
self.assertEqual(i1.access_restricted, False)
开发者ID:elpaquete,项目名称:django-sitetree,代码行数:8,代码来源:tests.py
示例3: test_permission_any
def test_permission_any(self):
i1 = item('root', 'url')
self.assertEqual(i1.access_perm_type, i1.PERM_TYPE_ANY)
i2 = item('root', 'url', perm_any=True)
self.assertEqual(i2.access_perm_type, i1.PERM_TYPE_ANY)
i3 = item('root', 'url', perm_any=False)
self.assertEqual(i3.access_perm_type, i1.PERM_TYPE_ALL)
开发者ID:Guest007,项目名称:django-sitetree,代码行数:9,代码来源:tests.py
示例4: build_menu
def build_menu(self, lang):
current_date = datetime.date.today()
child_items = [
item('Atbalstītāji', 'competition:supporters %i' % self.competition.id),
item('Starta saraksts', 'competition:participant_list %i' % self.competition.id),
]
self.build_flat_pages(self.competition, child_items, lang)
if self.competition.map_set.count():
child_items.append(item('Kartes', 'competition:maps %i' % self.competition.id))
if self.competition.competition_date <= current_date:
child_items.append(item('Rezultāti', '/media/results/2015_RM_bernu_rezultati.pdf', url_as_pattern=False))
return item(str(self.competition), 'competition:competition %i' % self.competition.id, url_as_pattern=True, children=child_items, in_menu=self.competition.is_in_menu)
开发者ID:Ameriks,项目名称:velo.lv,代码行数:13,代码来源:brm2015.py
示例5: build_menu
def build_menu(self, lang):
activate(lang)
current_date = datetime.date.today()
child_items = [
item(_('Start List'), 'competition:participant_list %i' % self.competition.id),
item(_("Maps"), 'competition:maps %i' % self.competition.id),
]
self.build_flat_pages(self.competition, child_items, lang)
if self.competition.competition_date <= current_date + datetime.timedelta(days=1):
child_items.append(item(_("Results"), 'competition:result_distance_list %i' % self.competition.id))
return item(str(self.competition), 'competition:competition %i' % self.competition.id, url_as_pattern=True, children=child_items, in_menu=self.competition.is_in_menu)
开发者ID:Ameriks,项目名称:velo.lv,代码行数:13,代码来源:ec2016.py
示例6: get_sitetree_add_item
def get_sitetree_add_item(cls):
"""Возвращает элемент древа сайта, указывающий на страницу добавления объекта.
:return:
"""
realm_name, realm_name_plural = cls.get_names()
return item(cls.txt_form_add, '%s:add' % realm_name_plural, access_loggedin=True)
开发者ID:cesaiskra,项目名称:pythonz,代码行数:7,代码来源:realms.py
示例7: get_sitetree_edit_item
def get_sitetree_edit_item(cls):
"""Возвращает элемент древа сайта, указывающий на страницу редактирования объекта.
:return:
"""
realm_name, _tmp = cls.get_names()
return item(cls.txt_form_edit, '%s %s.id' % (cls.get_edit_urlname(), realm_name), in_menu=False, in_sitetree=False, access_loggedin=True)
开发者ID:cesaiskra,项目名称:pythonz,代码行数:7,代码来源:realms.py
示例8: get_sitetree_tags_item
def get_sitetree_tags_item(cls):
"""Возвращает элемент древа сайта, указывающий на страницу разбивки объектов по метке (категории).
:return:
"""
return item('Категория «{{ category.title }}»', '%s category.id' % cls.get_tags_urlname(),
in_menu=False, in_sitetree=False)
开发者ID:gitter-badger,项目名称:pythonz,代码行数:7,代码来源:realms.py
示例9: build_manager_menu
def build_manager_menu(self):
return item(
unicode(self.competition),
"#",
url_as_pattern=False,
in_menu=self.competition.is_in_menu,
access_loggedin=True,
)
开发者ID:adamslapins,项目名称:velo.lv,代码行数:8,代码来源:brm2015.py
示例10: get_item
def get_item(urlname, id_attr='id'):
return item(
'{{ %s.title }}' % realm_name,
'%s %s.%s' % (urlname, realm_name, id_attr), # Например books:details book.id
children=children,
in_menu=False,
in_sitetree=False
)
开发者ID:gitter-badger,项目名称:pythonz,代码行数:8,代码来源:realms.py
示例11: get_tree_item
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
开发者ID:bergsoftplus,项目名称:pythonz,代码行数:9,代码来源:realms.py
示例12: test_basic
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)
开发者ID:robcharlwood,项目名称:django-sitetree,代码行数:59,代码来源:tests.py
示例13: build_manager_menu
def build_manager_menu(self):
child_items = []
# for child in self.competition.get_children():
# children = []
# children.append(item('Dalībnieki', '#', url_as_pattern=False, access_loggedin=True, children=[
# item('Pieteikt dalībnieku', 'manager:participant_create %i' % child.id, access_loggedin=True),
# item('Dalībnieku saraksts', 'manager:participant_list %i' % child.id, access_loggedin=True),
# item('{{ object }}', 'manager:participant %i object.id' % child.id, in_menu=False, access_loggedin=True),
# ]))
return item(unicode(self.competition), 'manager:competition %i' % self.competition.id, children=child_items, in_menu=self.competition.is_in_menu, access_loggedin=True)
开发者ID:martinsv,项目名称:velo.lv,代码行数:10,代码来源:vb2014.py
示例14: get_sitetree_details_item
def get_sitetree_details_item(cls):
"""Возвращает элемент древа сайта, указывающий на страницу с детальной информацией об объекте.
:return:
"""
realm_name, realm_name_plural = cls.get_names()
children = []
if 'edit' in cls.allowed_views:
children.append(cls.get_sitetree_edit_item())
return item('{{ %s.title }}' % realm_name, '%s %s.id' % (cls.get_details_urlname(), realm_name), children=children, in_menu=False, in_sitetree=False)
开发者ID:cesaiskra,项目名称:pythonz,代码行数:10,代码来源:realms.py
示例15: build_menu
def build_menu(self):
current_date = datetime.date.today()
child_items = [
item("Atbalstītāji", "competition:supporters %i" % self.competition.id),
item("Starta saraksts", "competition:participant_list %i" % self.competition.id),
]
self.build_flat_pages(self.competition, child_items)
if self.competition.map_set.count():
child_items.append(item("Kartes", "competition:maps %i" % self.competition.id))
if self.competition.competition_date <= current_date:
child_items.append(item("Rezultāti", "/media/results/2015_RM_bernu_rezultati.pdf", url_as_pattern=False))
return item(
unicode(self.competition),
"competition:competition %i" % self.competition.id,
url_as_pattern=True,
children=child_items,
in_menu=self.competition.is_in_menu,
)
开发者ID:adamslapins,项目名称:velo.lv,代码行数:19,代码来源:brm2015.py
示例16: get_sitetree_add_item
def get_sitetree_add_item(cls):
"""Возвращает элемент древа сайта, указывающий на страницу добавления объекта.
:return:
"""
tree_item = item(cls.txt_form_add, cls.get_add_urlname(), access_loggedin=True)
tree_item.show_on_top = True
return tree_item
开发者ID:idlesign,项目名称:pythonz,代码行数:10,代码来源:realms.py
示例17: build_sitetree
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()
开发者ID:bergsoftplus,项目名称:pythonz,代码行数:42,代码来源:realms.py
示例18: get_sitetree_root_item
def get_sitetree_root_item(children=None):
"""Возвращает корневой элемент динамического древа сайта.
:param tuple|generator children: Дочерние динамические элементы.
"""
return item(
'Про Python', '/', alias='topmenu', url_as_pattern=False,
description='Сайт про Питон. Различные материалы по языку программирования Python: '
'книги, видео, справочник, сообщества, события, обсуждения и многое другое.',
children=children)
开发者ID:bergsoftplus,项目名称:pythonz,代码行数:11,代码来源:realms.py
示例19: sitetrees_build
def sitetrees_build():
items = []
for competition in Competition.objects.filter(is_in_menu=True):
children = []
if competition.processing_class:
_class = load_class(competition.processing_class)
processing = _class(competition=competition)
items.append(processing.build_menu())
else:
items.append(item(unicode(competition), '#', url_as_pattern=False, children=children))
return (tree('dynamic_competition', items=items),)
开发者ID:adamslapins,项目名称:velo.lv,代码行数:11,代码来源:sitetrees.py
示例20: get_sitetree_items
def get_sitetree_items(cls):
"""Возвращает элементы древа сайта.
:return:
"""
if cls.sitetree_items is None:
cls.sitetree_items = item(
str(cls.model._meta.verbose_name_plural), cls.get_listing_urlname(),
children=[getattr(cls, 'get_sitetree_%s_item' % view_name)() for view_name in cls.allowed_views if view_name != 'edit']
)
return cls.sitetree_items
开发者ID:cesaiskra,项目名称:pythonz,代码行数:11,代码来源:realms.py
注:本文中的sitetree.utils.item函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论