Ticket #919: category.1105.patch
| File category.1105.patch, 17.8 kB (added by cboos@…, 4 years ago) |
|---|
-
scripts/trac-admin
== scripts/trac-admin ==================================================================
706 706 self._do_wiki_import(filename, page, cursor) 707 707 708 708 709 ## (Ticket) Category 710 _help_category = [('category list', 'Show possible ticket categories'), 711 ('category add <value>', 'Add a category value option'), 712 ('category change <value> <newvalue>', 713 'Change a category value'), 714 ('category remove <value>', 'Remove category value')] 715 716 def complete_category (self, text, line, begidx, endidx): 717 if begidx == 16: 718 comp = self.get_enum_list ('category') 719 elif begidx < 15: 720 comp = ['list','add','change','remove'] 721 return self.word_complete(text, comp) 722 723 def do_category(self, line): 724 self._do_enum('category', line) 725 709 726 ## (Ticket) Priority 710 727 _help_priority = [('priority list', 'Show possible ticket priorities'), 711 728 ('priority add <value>', 'Add a priority value option'), -
trac/core.py
=== trac/core.py ==================================================================
199 199 pass 200 200 201 201 def populate_hdf(hdf, env, db, req): 202 sql_to_hdf(db, "SELECT name FROM enum WHERE type='category' " 203 "ORDER BY value", hdf, 'enums.category') 202 204 sql_to_hdf(db, "SELECT name FROM enum WHERE type='priority' " 203 205 "ORDER BY value", hdf, 'enums.priority') 204 206 sql_to_hdf(db, "SELECT name FROM enum WHERE type='severity' " -
trac/db_default.py
=== trac/db_default.py ==================================================================
21 21 22 22 23 23 # Database version identifier. Used for automatic upgrades. 24 db_version = 724 db_version = 8 25 25 26 26 def __mkreports(reps): 27 27 """Utility function used to create report data in same syntax as the -
trac/Query.py
=== trac/Query.py ==================================================================
59 59 results.append({ 60 60 'id': id, 61 61 'href': self.env.href.ticket(id), 62 'category': row['category'], 62 63 'summary': util.escape(row['summary'] or '(no summary)'), 63 64 'status': row['status'] or '', 64 65 'component': row['component'] or '', … … 78 79 if self.args.has_key('search'): 79 80 self.req.redirect(self.env.href.query(constraints, order, desc, 80 81 action='view')) 82 if self.args.has_key('clear'): 83 self.req.redirect(self.env.href.query()) 81 84 82 85 action = self.args.get('action') 83 86 if not action and not constraints: … … 91 94 92 95 def _render_editor(self, constraints, order, desc): 93 96 self.req.hdf.setValue('title', 'Custom Query') 97 self.req.hdf.setValue('query.clear_href', self.env.href.query(action='edit')) 94 98 util.add_to_hdf(constraints, self.req.hdf, 'query.constraints') 95 99 self.req.hdf.setValue('query.order', order) 96 100 if desc: self.req.hdf.setValue('query.desc', '1') … … 112 116 del constraints[field] 113 117 114 118 cursor = self.db.cursor() 119 add_options('category', constraints, 'query.options.', cursor, 120 "SELECT name FROM enum WHERE type='category' ORDER BY value") 115 121 add_options('status', constraints, 'query.options.', cursor, 116 122 "SELECT name FROM enum WHERE type='status' ORDER BY value") 117 123 add_options('resolution', constraints, 'query.options.', cursor, … … 146 152 147 153 # FIXME: the user should be able to configure which columns should 148 154 # be displayed 149 headers = [ ' id', 'summary', 'status', 'component', 'owner' ]155 headers = [ 'category', 'id', 'summary', 'status', 'component', 'owner' ] 150 156 cols = headers 151 157 if not 'priority' in cols: 152 158 cols.append('priority') … … 176 182 "(id=%s.ticket AND %s.name='%s')" 177 183 % (k, k, k, k)) 178 184 179 for col in [c for c in [' status', 'resolution', 'priority', 'severity']185 for col in [c for c in ['category', 'status', 'resolution', 'priority', 'severity'] 180 186 if c in cols]: 181 187 sql.append(" INNER JOIN (SELECT name AS %s_name, value AS %s_value " \ 182 188 "FROM enum WHERE type='%s')" \ … … 194 200 if clauses: 195 201 sql.append(" WHERE " + " AND ".join(clauses)) 196 202 197 if order in [' status', 'resolution', 'priority', 'severity']:203 if order in ['category', 'status', 'resolution', 'priority', 'severity']: 198 204 sql.append(" ORDER BY %s_value" % order) 199 205 else: 200 206 sql.append(" ORDER BY " + order) -
trac/Timeline.py
=== trac/Timeline.py ==================================================================
58 58 q = [] 59 59 if changeset: 60 60 q.append("SELECT time, rev AS idata, '' AS tdata, 1 AS type, " 61 " message, author "61 " message, author, '' AS category " 62 62 "FROM revision WHERE time>=%s AND time<=%s" % 63 63 (start, stop)) 64 64 if tickets: 65 65 q.append("SELECT time, id AS idata, '' AS tdata, 2 AS type, " 66 " summary AS message, reporter AS author"66 " summary AS message, reporter AS author, category " 67 67 "FROM ticket WHERE time>=%s AND time<=%s" % 68 68 (start, stop)) 69 q.append("SELECT time, ticket AS idata, '' AS tdata, 4 AS type, " 70 "'' AS message, author " 71 "FROM ticket_change WHERE field='status' " 72 "AND newvalue='reopened' AND time>=%s AND time<=%s" % 69 q.append("SELECT t1.time, t1.ticket AS idata, '' AS tdata, 4 AS type, " 70 " '' AS message, t1.author, t0.category AS category " 71 "FROM ticket_change t1 " 72 " LEFT JOIN ticket t0 ON t0.id = t1.ticket " 73 "WHERE t1.field='status' " 74 "AND t1.newvalue='reopened' AND t1.time>=%s AND t1.time<=%s" % 73 75 (start, stop)) 74 76 q.append("SELECT t1.time AS time, t1.ticket AS idata," 75 77 " t2.newvalue AS tdata, 3 AS type," 76 " t3.newvalue AS message, t1.author AS author "78 " t3.newvalue AS message, t1.author AS author, t0.category AS category" 77 79 " FROM ticket_change t1" 80 " LEFT JOIN ticket t0 ON t0.id = t1.ticket" 78 81 " INNER JOIN ticket_change t2 ON t1.ticket = t2.ticket" 79 82 " AND t1.time = t2.time" 80 83 " LEFT OUTER JOIN ticket_change t3 ON t1.time = t3.time" … … 84 87 " AND t1.time >= %s AND t1.time <= %s" % (start,stop)) 85 88 if wiki: 86 89 q.append("SELECT time, -1 AS idata, name AS tdata, 5 AS type, " 87 "comment AS message, author "90 "comment AS message, author, '' AS category " 88 91 "FROM wiki WHERE time>=%s AND time<=%s" % 89 92 (start, stop)) 90 93 if milestone: 91 94 q.append("SELECT time, -1 AS idata, '' AS tdata, 6 AS type, " 92 "name AS message, '' AS author "95 "name AS message, '' AS author, '' AS category " 93 96 "FROM milestone WHERE time>=%s AND time<=%s" % 94 97 (start, stop)) 98 95 99 if ticket_comments: 96 q.append("SELECT time, ticket AS idata, '' AS tdata, 7 AS type, " 97 "newvalue AS message, author AS author " 98 "FROM ticket_change WHERE field = 'comment' " 99 "AND time>=%s AND time<=%s" % (start, stop)) 100 q.append("SELECT t1.time AS time, t1.ticket AS idata, '' AS tdata, 7 AS type, " 101 "t1.newvalue AS message, t1.author AS author, t0.category AS category " 102 "FROM ticket_change t1" 103 " LEFT JOIN ticket t0 ON t0.id = t1.ticket " 104 "WHERE t1.field = 'comment' " 105 "AND t1.time>=%s AND t1.time<=%s" % (start, stop)) 100 106 101 107 q_str = string.join(q, ' UNION ALL ') 102 108 q_str += ' ORDER BY time DESC' … … 121 127 'tdata': row['tdata'], 122 128 'type': int(row['type']), 123 129 'message': row['message'] or '', 130 'category': row['category'], 124 131 'author': util.escape(row['author'] or 'anonymous') 125 132 } 126 133 -
trac/upgrades/db8.py
=== trac/upgrades/db8.py ==================================================================
1 sql = """ 2 -- Add category to 'ticket' 3 CREATE TEMP TABLE ticket_old AS SELECT * FROM ticket; 4 DROP TABLE ticket; 5 CREATE TABLE ticket ( 6 id integer PRIMARY KEY, 7 category text, -- the nature of the ticket 8 time integer, -- the time it was created 9 changetime integer, 10 component text, 11 severity text, 12 priority text, 13 owner text, -- who is this ticket assigned to 14 reporter text, 15 cc text, -- email addresses to notify 16 url text, -- url related to this ticket 17 version text, -- 18 milestone text, -- 19 status text, 20 resolution text, 21 summary text, -- one-line summary 22 description text, -- problem description (long) 23 keywords text 24 ); 25 INSERT INTO ticket(id, category, time, changetime, component, 26 severity, priority, owner, reporter, cc, url, version, 27 milestone, status, resolution, summary, description, keywords) 28 SELECT id, '', time, changetime, component, 29 severity, priority, owner, reporter, cc, url, version, 30 milestone, status, resolution, summary, description, keywords FROM ticket_old; 31 32 """ 33 34 def do_upgrade(env, ver, cursor): 35 cursor.execute(sql) -
trac/Ticket.py
Property changes on: trac/upgrades/db8.py ___________________________________________________________________ Name: svn:executable +* === trac/Ticket.py ==================================================================
37 37 class Ticket(UserDict): 38 38 std_fields = ['time', 'component', 'severity', 'priority', 'milestone', 39 39 'reporter', 'owner', 'cc', 'url', 'version', 'status', 'resolution', 40 'keywords', 'summary', 'description' ]40 'keywords', 'summary', 'description', 'category'] 41 41 42 42 def __init__(self, *args): 43 43 UserDict.__init__(self) … … 318 318 self.env.get_config('ticket', 'default_component')) 319 319 ticket.setdefault('milestone', 320 320 self.env.get_config('ticket', 'default_milestone')) 321 ticket.setdefault('category', 322 self.env.get_config('ticket', 'default_category')) 321 323 ticket.setdefault('priority', 322 324 self.env.get_config('ticket', 'default_priority')) 323 325 ticket.setdefault('severity', … … 408 410 util.hdf_add_if_missing(self.req.hdf, 'ticket.components', ticket['component']) 409 411 util.hdf_add_if_missing(self.req.hdf, 'ticket.milestones', ticket['milestone']) 410 412 util.hdf_add_if_missing(self.req.hdf, 'ticket.versions', ticket['version']) 413 util.hdf_add_if_missing(self.req.hdf, 'enums.category', ticket['category']) 411 414 util.hdf_add_if_missing(self.req.hdf, 'enums.priority', ticket['priority']) 412 415 util.hdf_add_if_missing(self.req.hdf, 'enums.severity', ticket['severity']) 413 416 util.hdf_add_if_missing(self.req.hdf, 'enums.resolution', 'fixed') -
templates/ticket.cs
=== templates/ticket.cs ==================================================================
32 32 33 33 <div id="ticket"> 34 34 <div class="date"><?cs var:ticket.opened ?></div> 35 <h1> Ticket #<?cs var:ticket.id ?> <?cs35 <h1><?cs var:ticket.category ?> Ticket #<?cs var:ticket.id ?> <?cs 36 36 if:ticket.status == 'closed' ?>(Closed: <?cs var:ticket.resolution ?>)<?cs 37 37 elif:ticket.status != 'new' ?>(<?cs var:ticket.status ?>)<?cs 38 38 /if ?></h1> … … 166 166 var:ticket.summary ?>" /><?cs 167 167 if $trac.acl.TICKET_ADMIN ?> 168 168 <br /> 169 <label for="category">Category:</label><?cs 170 call:hdf_select(enums.category, "category", ticket.category) ?> 171 <br /> 169 172 <label for="description">Description:</label> 170 173 <div style="float: left"> 171 174 <textarea id="description" name="description" rows="10" cols="68"><?cs -
templates/newticket.cs
=== templates/newticket.cs ==================================================================
9 9 10 10 <div id="content" class="ticket"> 11 11 12 <h3>Create New Ticket:</h3>13 12 <form id="newticket" action="<?cs var:cgi_location ?>#preview" method="post"> 13 <h3>Create New Ticket of <label for="category">category:</label><?cs 14 call:hdf_select(enums.category, "category", newticket.category) ?> 15 </h3> 14 16 <div class="field"> 15 17 <label for="reporter">Your email or username:</label><br /> 16 18 <input type="text" id="reporter" name="reporter" size="40" value="<?cs -
templates/query.cs
=== templates/query.cs ==================================================================
2 2 <?cs include:"header.cs" ?> 3 3 <?cs include:"macros.cs" ?> 4 4 5 <div id="ctxtnav" class="nav"><?cs if:query.edit_href ?> 6 <ul> 7 <li class="last"><a href="<?cs var:query.edit_href ?>">Refine Query</a></li> 5 <div id="ctxtnav" class="nav"> 6 <ul><?cs 7 if:query.edit_href ?> 8 <li class="last"><a href="<?cs var:query.edit_href ?>">Refine Query</a></li><?cs 9 /if ?><?cs 10 if:query.clear_href ?> 11 <li class="last"><a href="<?cs var:query.clear_href ?>">Clear Query</a></li><?cs 12 /if ?> 8 13 </ul> 9 < ?cs /if ?></div>14 </div> 10 15 11 16 <div id="content" class="query"> 12 17 <h1><?cs var:title ?></h1> … … 20 25 <?cs if:query.desc ?><input type="hidden" name="desc" value="1" /><?cs /if ?> 21 26 <legend>Ticket Properties</legend> 22 27 <div> 28 <label for="category" accesskey="t">Category:</label> 29 <?cs call:hdf_select_multiple(query.options.category, 'category', 4) ?> 30 </div> 31 <div> 23 32 <label for="component" accesskey="c">Component:</label> 24 33 <?cs call:hdf_select_multiple(query.options.component, 'component', 4) ?> 25 34 </div> … … 112 121 /if ?> matched this query.</p> 113 122 <table id="tktlist" class="listing"> 114 123 <thead><tr><?cs each:header = query.headers ?><?cs 115 if: name(header) == 0?><th class="ticket<?cs124 if:header.name == 'id' ?><th class="ticket<?cs 116 125 if:header.order ?> <?cs var:header.order ?><?cs /if ?>"> 117 126 <a href="<?cs var:header.href ?>" title="Sort by ID (<?cs 118 127 if:header.order == 'asc' ?>descending<?cs … … 131 140 if:name(result) % 2 ?>odd<?cs else ?>even<?cs /if ?> <?cs 132 141 var:result.priority ?>"> 133 142 <?cs each:header = query.headers ?><?cs 134 if: name(header) == 0?>135 <td class="ticket"><a href="<?cs var:result.href ?>" title="View ticket"> <?cs143 if:header.name == 'id' ?> 144 <td class="ticket"><a href="<?cs var:result.href ?>" title="View ticket">#<?cs 136 145 var:result.id ?></a></td><?cs 137 146 else ?> 138 147 <td><?cs if:header.name == 'summary' ?> -
templates/timeline.cs
=== templates/timeline.cs ==================================================================
68 68 'Changeset <em>['+$item.idata+']</em> by '+$item.author,$item.node_list+item.message) ?> 69 69 <?cs elif:item.type == #2 ?><!-- New ticket --> 70 70 <?cs call:tlitem(item.href, 'newticket', 71 'Ticket <em>#'+$item.idata+'</em> created by '+$item.author, item.message) ?>71 $item.category+' Ticket <em>#'+$item.idata+'</em> created by '+$item.author, item.message) ?> 72 72 <?cs elif:item.type == #3 ?><!-- Closed ticket --> 73 73 <?cs if:item.message ?> 74 74 <?cs set:imessage = ' - ' + $item.message ?> … … 76 76 <?cs set:imessage = '' ?> 77 77 <?cs /if ?> 78 78 <?cs call:tlitem(item.href, 'closedticket', 79 'Ticket <em>#'+$item.idata+'</em> resolved by '+$item.author,79 $item.category+' Ticket <em>#'+$item.idata+'</em> resolved by '+$item.author, 80 80 $item.tdata+$imessage) ?> 81 81 <?cs elif:item.type == #4 ?><!-- Reopened ticket --> 82 82 <?cs call:tlitem(item.href, 'newticket', 83 'Ticket <em>#'+$item.idata+'</em> reopened by '+$item.author, '') ?>83 $item.category+' Ticket <em>#'+$item.idata+'</em> reopened by '+$item.author, '') ?> 84 84 <?cs elif:item.type == #5 ?><!-- Wiki change --> 85 85 <?cs call:tlitem(item.href, 'wiki', 86 86 '<em>'+$item.tdata+'</em> edited by '+$item.author, item.message) ?> … … 89 89 '<em>Milestone '+$item.message+'</em> reached', '') ?> 90 90 <?cs elif:item.type == #7 ?><!-- Ticket comment --> 91 91 <?cs call:tlitem(item.href, 'ticketcomment', 92 'Ticket <em>#'+$item.idata+'</em> contribution by '+$item.author, $item.message) ?>92 $item.category+' Ticket <em>#'+$item.idata+'</em> contribution by '+$item.author, $item.message) ?> 93 93 <?cs /if ?> 94 94 <?cs /each ?> 95 95 <?cs if:len(timeline.items) ?></dl><?cs /if ?>
