本文整理汇总了Python中bkr.server.model.Distro.by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Distro.by_id方法的具体用法?Python Distro.by_id怎么用?Python Distro.by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bkr.server.model.Distro
的用法示例。
在下文中一共展示了Distro.by_id方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_tag
# 需要导入模块: from bkr.server.model import Distro [as 别名]
# 或者: from bkr.server.model.Distro import by_id [as 别名]
def save_tag(self, id=None, tag=None, *args, **kw):
try:
distro = Distro.by_id(id)
except InvalidRequestError:
flash(_(u"Invalid distro id %s" % id))
redirect(".")
if tag['text']:
distro.tags.append(tag['text'])
distro.activity.append(DistroActivity(
user=identity.current.user, service=u'WEBUI',
action=u'Added', field_name=u'Tag',
old_value=None, new_value=tag['text']))
flash(_(u"Added Tag %s" % tag['text']))
redirect("./view?id=%s" % id)
示例2: tag_remove
# 需要导入模块: from bkr.server.model import Distro [as 别名]
# 或者: from bkr.server.model.Distro import by_id [as 别名]
def tag_remove(self, id=None, tag=None, *args, **kw):
try:
distro = Distro.by_id(id)
except InvalidRequestError:
flash(_(u"Invalid distro id %s" % id))
redirect(".")
if tag:
for dtag in distro.tags:
if dtag == tag:
distro.tags.remove(dtag)
distro.activity.append(DistroActivity(
user=identity.current.user, service=u'WEBUI',
action=u'Removed', field_name=u'Tag',
old_value=tag, new_value=None))
flash(_(u"Removed Tag %s" % tag))
redirect("./view?id=%s" % id)
示例3: view
# 需要导入模块: from bkr.server.model import Distro [as 别名]
# 或者: from bkr.server.model.Distro import by_id [as 别名]
def view(self, id=None, *args, **kw):
try:
distro = Distro.by_id(id)
except InvalidRequestError:
flash(_(u"Invalid distro id %s" % id))
redirect(".")
is_admin = identity.current.user and identity.current.user.is_admin() or False
task_form = TaskSearchForm(hidden=dict(distro=True, osmajor_id=True))
return dict(title = 'Distro',
value = distro,
value_task = dict(distro_id = distro.id),
form = self.tag_form,
form_task = task_form,
action = './save_tag',
action_task = '/tasks/do_search',
options = dict(tags = distro.tags,
readonly = not is_admin))