本文整理汇总了Python中trac.ticket.model.Priority类的典型用法代码示例。如果您正苦于以下问题:Python Priority类的具体用法?Python Priority怎么用?Python Priority使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Priority类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_priority_delete
def test_priority_delete(self):
prio = Priority(self.env, 'major')
self.assertEqual('3', prio.value)
prio.delete()
self.assertEqual(False, prio.exists)
self.assertRaises(TracError, Priority, self.env, 'major')
prio = Priority(self.env, 'minor')
self.assertEqual('3', prio.value)
开发者ID:zjj,项目名称:trac_hack,代码行数:8,代码来源:model.py
示例2: main
def main():
if len(sys.argv) < 2:
print("usage: %s /path/to/projenv" % os.path.basename(sys.argv[0]),
file=sys.stderr)
sys.exit(2)
env = open_environment(sys.argv[1])
with env.db_transaction:
for oldprio, newprio in priority_mapping.items():
priority = Priority(env, oldprio)
priority.name = newprio
priority.update()
for severity in list(Severity.select(env)):
severity.delete()
开发者ID:pkdevbox,项目名称:trac,代码行数:15,代码来源:migrateticketmodel.py
示例3: main
def main():
if len(sys.argv) < 2:
print >> sys.stderr, 'usage: %s /path/to/projenv' \
% os.path.basename(sys.argv[0])
sys.exit(2)
env = open_environment(sys.argv[1])
db = env.get_db_cnx()
for oldprio, newprio in priority_mapping.items():
priority = Priority(env, oldprio, db)
priority.name = newprio
priority.update(db)
for severity in list(Severity.select(env, db)):
severity.delete(db)
db.commit()
开发者ID:wiraqutra,项目名称:photrackjp,代码行数:18,代码来源:migrateticketmodel.py
示例4: get_ticket_changes
def get_ticket_changes(self, req, ticket, action):
id = "vote_%s_result" % (action,)
selected = req.args.get(id, "for")
priorities = list(Priority.select(self.env))
orig_ticket = Ticket(self.env, ticket.id)
current_priority = int(Priority(self.env, name=orig_ticket["priority"]).value)
if selected == "for":
# priorities are 1-based, not 0-based
new_value = max(1, current_priority - 1)
else:
maxval = max([int(p.value) for p in priorities])
new_value = min(maxval, current_priority + 1)
return {"priority": [p.name for p in priorities if int(p.value) == new_value][0]}
开发者ID:moreati,项目名称:trac-gitsvn,代码行数:13,代码来源:VoteOperation.py
示例5: _do_enter_sticket
def _do_enter_sticket(self, sticket):
ticket = Ticket(self.env)
ticket.values['status'] = 'new'
ticket.values['reporter'] = 'scheduled'
ticket.values['summary'] = sticket['summary']
ticket.values['description'] = sticket['description']
priorities = Priority.select(self.env)
for priority in priorities:
if int(priority.value) == sticket['priority']:
ticket.values['priority'] = priority.name
for manipulator in self.ticket_manipulators:
manipulator.validate_ticket([], ticket)
# This was largely copied from trac.ticket.web_ui
ticket.insert()
try:
tn = TicketNotifyEmail(self.env)
tn.notify(ticket, newticket=True)
except Exception, e:
error = "Failure sending notification on creation of ticket #%s: %s" % (ticket.id, exception_to_unicode(e))
self.log.error(error)
print error
开发者ID:sgielen,项目名称:trac-plugin-scheduled,代码行数:24,代码来源:scheduled.py
示例6: test_priority_update
def test_priority_update(self):
prio = Priority(self.env, 'major')
prio.name = 'foo'
prio.update()
Priority(self.env, 'foo')
self.assertRaises(TracError, Priority, self.env, 'major')
开发者ID:zjj,项目名称:trac_hack,代码行数:6,代码来源:model.py
示例7: test_priority_insert_with_value
def test_priority_insert_with_value(self):
prio = Priority(self.env)
prio.name = 'bar'
prio.value = 100
prio.insert()
self.assertEqual(True, prio.exists)
开发者ID:zjj,项目名称:trac_hack,代码行数:6,代码来源:model.py
示例8: test_priority_insert
def test_priority_insert(self):
prio = Priority(self.env)
prio.name = 'foo'
prio.insert()
self.assertEqual(True, prio.exists)
开发者ID:zjj,项目名称:trac_hack,代码行数:5,代码来源:model.py
示例9: process_request
def process_request(self, req):
add_stylesheet(req, 'scheduled/css/scheduled.css')
m = re.match(r'/scheduled(?:/delete/(\d+))?/?$', req.path_info)
if m:
tid = m.group(1)
deleted_message = None
if tid is not None:
deleted = False
for row in self.env.db_query("SELECT summary FROM scheduled WHERE id=%s", str(tid)):
deleted = True
with self.env.db_transaction as db:
cursor = db.cursor()
cursor.execute("DELETE FROM scheduled WHERE id=%s",
str(tid))
deleted_message = "Scheduled ticket succesfully deleted: " + row[0]
if not deleted:
deleted_message = "No ticket found with that ID, none deleted"
tickets = []
index = 0
for row in self.env.db_query("SELECT id, summary, description, priority, recurring_days, scheduled_start, enabled FROM scheduled ORDER BY enabled DESC, scheduled_start ASC"):
ticket = self.row_to_dict(row)
ticket['__idx__'] = index
tickets.append(ticket)
index += 1
return 'scheduled.html', \
{'scheduled_tickets': tickets, \
'deleted_message': deleted_message}, None
m = re.match(r'/scheduled/(?:create/?|alter/(\d+)/?)$', req.path_info)
if m:
message = None
ticket = None
tid = m.group(1)
priorities = Priority.select(self.env)
if tid is None:
ticket = {}
else:
for row in self.env.db_query("SELECT id, summary, description, priority, recurring_days, scheduled_start, enabled FROM scheduled WHERE id=%s", str(tid)):
ticket = self.row_to_dict(row)
# microsecond UNIX timestamp to number of days from now
ticket['scheduled_start'] = ((ticket['scheduled_start'] / 1000000) - time.time()) / (24*3600)
if ticket is None:
raise TracError("The given ticket ID was not found.")
assert ticket is not None, "ticket should be initialised by now"
if req.method == 'POST':
try:
# Save new fields into ticket here, so an exception will not cause
# the fields to blank
if 'ticket_id' in req.args:
ticket['id'] = req.args['ticket_id']
ticket['summary'] = req.args['field_summary']
ticket['description'] = req.args['field_description']
ticket['recurring_days'] = req.args['field_repeatdays']
ticket['scheduled_start'] = req.args['field_nextdue']
ticket['enabled'] = req.args['field_enabled'];
ticket['priority'] = req.args['field_priority'];
if ticket['enabled'] == "1":
ticket['enabled'] = 1
else:
ticket['enabled'] = 0
recurring = int(ticket['recurring_days'])
if recurring < 0:
raise Exception('Recurring days must not be negative')
nextdue = float(ticket['scheduled_start'])
if nextdue <= 0:
raise Exception('Next due days must be > 0')
ticket['recurring_days'] = recurring
ticket['scheduled_start'] = (time.time() + nextdue * 3600 * 24) * 1000000
with self.env.db_transaction as db:
cursor = db.cursor()
if 'id' in ticket:
cursor.execute("""
UPDATE scheduled SET summary=%s, description=%s, recurring_days=%s,
scheduled_start=%s, enabled=%s, priority=%s WHERE id=%s""",
(ticket['summary'], ticket['description'],
ticket['recurring_days'], ticket['scheduled_start'], ticket['enabled'],
ticket['priority'], ticket['id']))
else:
cursor.execute("""
INSERT INTO scheduled (summary, description, recurring_days,
scheduled_start, enabled, priority) VALUES (%s, %s, %s, %s, %s, %s)""",
(ticket['summary'], ticket['description'],
ticket['recurring_days'], ticket['scheduled_start'],
ticket['enabled'], ticket['priority']))
ticket['id'] = db.get_last_id(cursor, 'scheduled')
self.log.warning("Saved into schedule, id=%s", str(ticket['id']))
req.redirect(req.href('/scheduled'))
except RequestDone, e:
raise
except Exception, e:
message = str(e)
开发者ID:sgielen,项目名称:trac-plugin-scheduled,代码行数:99,代码来源:scheduled.py
示例10: filter_stream
def filter_stream(self, req, method, filename, stream, data):
# this is shamelessly stollen from MasterTickets
if data and filename in ["report_view.html", "query_results.html", "ticket.html", "query.html"]:
self._link_parent(req, filename, data)
# Tickets will be modified to show the child tickets as a list under the 'Description' section.
if filename == 'ticket.html':
# Add our own styles for the ticket lists.
add_stylesheet(req, 'ct/css/childtickets.css')
add_stylesheet(req, 'common/css/report.css')
add_stylesheet(req, 'common/css/roadmap.css')
add_script(req, 'ct/js/childtickets.js')
# Get the ticket info.
ticket = data.get('ticket')
# Modify ticket.html with sub-ticket table, create button, etc...
# As follows:
# - If ticket has no child tickets and child tickets are NOT allowed then skip.
# - If ticket has child tickets and child tickets are NOT allowed (ie. rules changed or ticket type changed after children were assigned),
# print list of tickets but do not allow any tickets to be created.
# - If child tickets are allowed then print list of child tickets or 'No Child Tickets' if non are currently assigned.
#
if ticket and ticket.exists:
# The additional section on the ticket is built up of (potentially) three parts: header, ticket table, buttons. These
# are all 'wrapped up' in a 'div' with the 'attachments' id (we'll just pinch this to make look and feel consistent with any
# future changes!)
filter = Transformer('//div[@id="ticket"]')
snippet = tag.div()
priorities = dict([(p.name, int(p.value)) for p in Priority.select(self.env)])
# Are there any child tickets to display?
childtickets = self._get_childtickets(ticket, priorities)
# Are child tickets allowed?
childtickets_allowed = self.config.getbool('childtickets', 'parent.%s.allow_child_tickets' % ticket['type'])
# If there are no childtickets and the ticket should not have any child tickets, we can simply drop out here.
if not childtickets_allowed and not childtickets:
return stream
# Our 'main' display consists of two divs.
buttondiv = tag.div()
tablediv = tag.div()
progresshtml = tag.div()
# Test if the ticket has children: If so, then list in pretty table.
if childtickets:
progresshtml = self._construct_progress(req, ticket)
tablediv = self._contruct_tickets_table(req, ticket, childtickets, priorities)
# trac.ini : child tickets are allowed - Set up 'create new ticket' buttons.
if childtickets_allowed and 'TICKET_CREATE' in req.perm(ticket.resource):
buttondiv = self._contruct_buttons(req, ticket)
snippet.append(tag.h2("Child Tickets",class_="foldable"))
snippet.append(tag.div(progresshtml, tablediv, buttondiv, id="childtickets"))
return stream | filter.after(snippet)
return stream
开发者ID:silk,项目名称:trac-childticketsplugin,代码行数:64,代码来源:childtickets.py
注:本文中的trac.ticket.model.Priority类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论