本文整理汇总了Python中sitetree.utils.item函数的典型用法代码示例。如果您正苦于以下问题:Python item函数的具体用法?Python item怎么用?Python item使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了item函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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,
)
示例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
)
示例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
示例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)
示例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)
示例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)
示例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,
)