本文整理汇总了Python中trac.ticket.api.TicketSystem.insert方法的典型用法代码示例。如果您正苦于以下问题:Python TicketSystem.insert方法的具体用法?Python TicketSystem.insert怎么用?Python TicketSystem.insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.ticket.api.TicketSystem
的用法示例。
在下文中一共展示了TicketSystem.insert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _render_admin_panel
# 需要导入模块: from trac.ticket.api import TicketSystem [as 别名]
# 或者: from trac.ticket.api.TicketSystem import insert [as 别名]
def _render_admin_panel(self, req, cat, page, component):
# Detail view?
if component:
comp = model.Component(self.env, component)
if req.method == 'POST':
if req.args.get('save'):
comp.name = name = req.args.get('name')
comp.owner = req.args.get('owner')
comp.description = req.args.get('description')
try:
comp.update()
except self.env.db_exc.IntegrityError:
raise TracError(_('Component "%(name)s" already '
'exists.', name=name))
add_notice(req, _('Your changes have been saved.'))
req.redirect(req.href.admin(cat, page))
elif req.args.get('cancel'):
req.redirect(req.href.admin(cat, page))
Chrome(self.env).add_wiki_toolbars(req)
data = {'view': 'detail', 'component': comp}
else:
default = self.config.get('ticket', 'default_component')
if req.method == 'POST':
# Add Component
if req.args.get('add') and req.args.get('name'):
name = req.args.get('name')
try:
comp = model.Component(self.env, name=name)
except ResourceNotFound:
comp = model.Component(self.env)
comp.name = name
if req.args.get('owner'):
comp.owner = req.args.get('owner')
comp.insert()
add_notice(req, _('The component "%(name)s" has been '
'added.', name=name))
req.redirect(req.href.admin(cat, page))
else:
if comp.name is None:
raise TracError(_("Invalid component name."))
raise TracError(_('Component "%(name)s" already '
'exists.', name=name))
# Remove components
elif req.args.get('remove'):
sel = req.args.get('sel')
if not sel:
raise TracError(_('No component selected'))
if not isinstance(sel, list):
sel = [sel]
with self.env.db_transaction:
for name in sel:
model.Component(self.env, name).delete()
add_notice(req, _("The selected components have been "
"removed."))
req.redirect(req.href.admin(cat, page))
# Set default component
elif req.args.get('apply'):
name = req.args.get('default')
if name and name != default:
self.log.info("Setting default component to %s", name)
self.config.set('ticket', 'default_component', name)
_save_config(self.config, req, self.log)
req.redirect(req.href.admin(cat, page))
data = {'view': 'list',
'components': list(model.Component.select(self.env)),
'default': default}
owners = TicketSystem(self.env).get_allowed_owners()
if owners is not None:
owners.insert(0, '')
data.update({'owners': owners})
return 'admin_components.html', data