本文整理匯總了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