本文整理汇总了Python中indico.modules.categories.Category.get_root方法的典型用法代码示例。如果您正苦于以下问题:Python Category.get_root方法的具体用法?Python Category.get_root怎么用?Python Category.get_root使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类indico.modules.categories.Category
的用法示例。
在下文中一共展示了Category.get_root方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_event_own_visibility_horizon
# 需要导入模块: from indico.modules.categories import Category [as 别名]
# 或者: from indico.modules.categories.Category import get_root [as 别名]
def _get_event_own_visibility_horizon(self, event):
if self.visibility.data is None: # unlimited
return Category.get_root()
elif self.visibility.data == 0: # invisible
return None
else:
return event.category.nth_parent(self.visibility.data - 1)
示例2: _process_args
# 需要导入模块: from indico.modules.categories import Category [as 别名]
# 或者: from indico.modules.categories.Category import get_root [as 别名]
def _process_args(self):
if 'confId' in request.view_args:
self.obj = Event.get_one(request.view_args['confId'], is_deleted=False)
self.obj_type = 'event'
elif 'category_id' in request.view_args:
self.obj = Category.get_one(request.view_args['category_id'], is_deleted=False)
self.obj_type = 'category' if not self.obj.is_root else None
else:
self.obj = Category.get_root()
self.obj_type = None
示例3: category_family
# 需要导入模块: from indico.modules.categories import Category [as 别名]
# 或者: from indico.modules.categories.Category import get_root [as 别名]
def category_family(create_category, db):
grandpa = Category.get_root()
dad = create_category(1, title='Dad', parent=grandpa)
son = create_category(2, title='Son', parent=dad)
sibling = create_category(3, title='Sibling', parent=dad)
db.session.add(son)
db.session.flush()
return grandpa, dad, son, sibling
示例4: _process
# 需要导入模块: from indico.modules.categories import Category [as 别名]
# 或者: from indico.modules.categories.Category import get_root [as 别名]
def _process(self):
db.session.delete(self.template)
root = Category.get_root()
if not root.default_ticket_template:
# if we deleted the root category's default template, pick
# a system template as the new default (this always exists)
system_template = DesignerTemplate.find_first(DesignerTemplate.is_system_template,
DesignerTemplate.type == TemplateType.badge)
root.default_ticket_template = system_template
db.session.flush()
flash(_('The template has been deleted'), 'success')
return jsonify_data(html=_render_template_list(self.target, event=self.event_or_none))
示例5: test_excluded_categories
# 需要导入模块: from indico.modules.categories import Category [as 别名]
# 或者: from indico.modules.categories.Category import get_root [as 别名]
def test_excluded_categories(mocker, monkeypatch, db, create_category):
"""Test if category exclusions work."""
plugin = mocker.patch('indico_livesync.plugin.LiveSyncPlugin')
plugin.settings.get.return_value = [{'id': 2}, {'id': 3}]
categories = {}
with db.session.no_autoflush:
for cat_id in xrange(6):
category = (create_category(cat_id, title=str(cat_id), protection_mode=0,
parent=categories[CATEGORY_PARENTS[cat_id]])
if cat_id else Category.get_root())
categories[cat_id] = category
db.session.add(category)
db.session.flush()
db.session.flush()
for cat in categories.viewvalues():
db = mocker.patch('indico_livesync.models.queue.db')
LiveSyncQueueEntry.create({ChangeType.created}, obj_ref(cat), excluded_categories=get_excluded_categories())
assert db.session.add.called == (cat.id not in {2, 3, 4, 5})
示例6: test_effective_protection_mode
# 需要导入模块: from indico.modules.categories import Category [as 别名]
# 或者: from indico.modules.categories.Category import get_root [as 别名]
def test_effective_protection_mode(db):
def _cat(id_, protection_mode=ProtectionMode.inheriting, children=None):
return Category(id=id_, title='cat-{}'.format(id_), protection_mode=protection_mode, children=children or [])
root = Category.get_root()
root.protection_mode = ProtectionMode.protected
root.children = [
_cat(1),
_cat(2, ProtectionMode.public, children=[
_cat(3, children=[
_cat(4, ProtectionMode.inheriting),
_cat(5, ProtectionMode.public),
_cat(6, ProtectionMode.protected),
]),
_cat(7, ProtectionMode.protected, children=[
_cat(8, ProtectionMode.inheriting),
_cat(9, ProtectionMode.public),
_cat(10, ProtectionMode.protected),
]),
_cat(11)
])
]
db.session.add(root)
db.session.flush()
data = {c.id: c.effective_protection_mode for c in Category.query.options(undefer('effective_protection_mode'))}
assert data == {
0: ProtectionMode.protected,
1: ProtectionMode.protected,
2: ProtectionMode.public,
3: ProtectionMode.public,
4: ProtectionMode.public,
5: ProtectionMode.public,
6: ProtectionMode.protected,
7: ProtectionMode.protected,
8: ProtectionMode.protected,
9: ProtectionMode.public,
10: ProtectionMode.protected,
11: ProtectionMode.public
}
示例7: _process_args
# 需要导入模块: from indico.modules.categories import Category [as 别名]
# 或者: from indico.modules.categories.Category import get_root [as 别名]
def _process_args(self):
self.event_type = EventType[request.view_args['event_type']]
self.root_category = Category.get_root()
self.single_category = not self.root_category.children
示例8: _create_category
# 需要导入模块: from indico.modules.categories import Category [as 别名]
# 或者: from indico.modules.categories.Category import get_root [as 别名]
def _create_category(id_=None, **kwargs):
kwargs.setdefault('title', u'cat#{}'.format(id_) if id_ is not None else u'dummy')
kwargs.setdefault('timezone', 'UTC')
if 'parent' not in kwargs:
kwargs['parent'] = Category.get_root()
return Category(id=id_, acl_entries=set(), **kwargs)