=== trac/ticket/roadmap.py
==================================================================
|
|
|
|
| 2 | 2 | # |
| 3 | 3 | # Copyright (C) 2004-2005 Edgewall Software |
| 4 | 4 | # Copyright (C) 2004-2005 Christopher Lenz <cmlenz@gmx.de> |
| | 5 | # Copyright (C) 2006 Matthew Good <trac@matt-good.net> |
| 5 | 6 | # All rights reserved. |
| 6 | 7 | # |
| 7 | 8 | # This software is licensed as described in the file COPYING, which |
| … |
… |
|
| 13 | 14 | # history and logs, available at http://projects.edgewall.com/trac/. |
| 14 | 15 | # |
| 15 | 16 | # Author: Christopher Lenz <cmlenz@gmx.de> |
| | 17 | # Matthew Good <trac@matt-good.net> |
| 16 | 18 | |
| 17 | 19 | import re |
| | 20 | import sys |
| 18 | 21 | from time import localtime, strftime, time |
| 19 | 22 | |
| 20 | 23 | from trac import __version__ |
| 21 | 24 | from trac.core import * |
| 22 | 25 | from trac.perm import IPermissionRequestor |
| 23 | 26 | from trac.util import escape, format_date, format_datetime, parse_date, \ |
| 24 | | pretty_timedelta, shorten_line, unescape, CRLF, Markup |
| | 27 | pretty_timedelta, shorten_line, unescape, CRLF, Markup, \ |
| | 28 | embedded_numbers, sorted |
| 25 | 29 | from trac.ticket import Milestone, Ticket, TicketSystem |
| 26 | 30 | from trac.Timeline import ITimelineEventProvider |
| 27 | 31 | from trac.web import IRequestHandler |
| … |
… |
|
| 150 | 154 | req.hdf['roadmap.showall'] = showall |
| 151 | 155 | |
| 152 | 156 | db = self.env.get_db_cnx() |
| 153 | | milestones = [] |
| 154 | | for idx, milestone in enumerate(Milestone.select(self.env, showall)): |
| 155 | | hdf = milestone_to_hdf(self.env, db, req, milestone) |
| 156 | | milestones.append(hdf) |
| | 157 | def milestone_order(m): |
| | 158 | return (m.completed or sys.maxint, |
| | 159 | m.due or sys.maxint, |
| | 160 | embedded_numbers(m.name)) |
| | 161 | milestones = sorted(Milestone.select(self.env, showall), |
| | 162 | key=milestone_order) |
| | 163 | milestones = [milestone_to_hdf(self.env, db, req, m) |
| | 164 | for m in milestones] |
| 157 | 165 | req.hdf['roadmap.milestones'] = milestones |
| 158 | 166 | |
| 159 | 167 | for idx,milestone in enumerate(milestones): |
=== trac/util.py
==================================================================
|
|
|
|
| 2 | 2 | # |
| 3 | 3 | # Copyright (C) 2003-2004 Edgewall Software |
| 4 | 4 | # Copyright (C) 2003-2004 Jonas Borgstr�jonas@edgewall.com> |
| | 5 | # Copyright (C) 2006 Matthew Good <trac@matt-good.net> |
| 5 | 6 | # All rights reserved. |
| 6 | 7 | # |
| 7 | 8 | # This software is licensed as described in the file COPYING, which |
| … |
… |
|
| 13 | 14 | # history and logs, available at http://projects.edgewall.com/trac/. |
| 14 | 15 | # |
| 15 | 16 | # Author: Jonas Borgstr�jonas@edgewall.com> |
| | 17 | # Matthew Good <trac@matt-good.net> |
| 16 | 18 | |
| 17 | 19 | import cgi |
| 18 | 20 | import md5 |
| … |
… |
|
| 28 | 30 | |
| 29 | 31 | CRLF = '\r\n' |
| 30 | 32 | |
| | 33 | try: |
| | 34 | sorted |
| | 35 | except NameError: |
| | 36 | def sorted(iterable, key): |
| | 37 | """Partial implementation of the "sorted" function from Python 2.4""" |
| | 38 | lst = [(key(i), i) for i in iterable] |
| | 39 | lst.sort() |
| | 40 | return [i for __, i in lst] |
| 31 | 41 | |
| 32 | 42 | class Markup(str): |
| 33 | 43 | """Marks a string as being safe for inclusion in XML output without needing |
| … |
… |
|
| 260 | 270 | shortline = text[:i]+' ...' |
| 261 | 271 | return shortline |
| 262 | 272 | |
| | 273 | DIGITS = re.compile(r'(\d+)') |
| | 274 | def embedded_numbers(s): |
| | 275 | """Comparison function for natural order sorting based on |
| | 276 | http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/214202.""" |
| | 277 | pieces = DIGITS.split(s) |
| | 278 | pieces[1::2] = map(int, pieces[1::2]) |
| | 279 | return pieces |
| | 280 | |
| 263 | 281 | def hex_entropy(bytes=32): |
| 264 | 282 | import md5 |
| 265 | 283 | import random |