Ticket #925: patch-customlabelwiki-r1049.diff
| File patch-customlabelwiki-r1049.diff, 4.8 kB (added by pkou <pkou at ua.fm>, 4 years ago) |
|---|
-
trac/Milestone.py
208 208 cursor.execute("SELECT DISTINCT owner AS name FROM ticket " 209 209 "ORDER BY owner") 210 210 elif by not in Ticket.std_fields: 211 fields = get_custom_fields(self. env)211 fields = get_custom_fields(self.req.hdf, self.env, self.db) 212 212 field = [f for f in fields if f['name'] == by] 213 213 if not field: 214 214 return [] … … 308 308 309 309 available_groups = [ 'component', 'version', 'severity', 'priority', 310 310 'owner' ] 311 available_groups += [f['name'] for f in get_custom_fields(self. env)311 available_groups += [f['name'] for f in get_custom_fields(self.req.hdf, self.env, self.db) 312 312 if f['type'] == 'select' or f['type'] == 'radio'] 313 313 add_to_hdf(available_groups, self.req.hdf, 314 314 'milestone.stats.available_groups') -
trac/Query.py
25 25 import perm 26 26 import util 27 27 from Module import Module 28 from Ticket import get_custom_fields, insert_custom_fields,Ticket28 from Ticket import get_custom_fields, Ticket 29 29 30 30 31 31 class QueryModule(Module): … … 33 33 34 34 def get_constraints(self): 35 35 constraints = {} 36 custom_fields = [f['name'] for f in get_custom_fields(self. env)]36 custom_fields = [f['name'] for f in get_custom_fields(self.req.hdf, self.env, self.db)] 37 37 constrained_fields = [k for k in self.args.keys() 38 38 if k in Ticket.std_fields or k in custom_fields] 39 39 for field in constrained_fields: … … 127 127 add_options('severity', constraints, 'query.options.', cursor, 128 128 "SELECT name FROM enum WHERE type='severity' ORDER BY value") 129 129 130 custom_fields = get_custom_fields(self. env)130 custom_fields = get_custom_fields(self.req.hdf, self.env, self.db) 131 131 for custom in custom_fields: 132 132 if custom['type'] == 'select' or custom['type'] == 'radio': 133 133 check = constraints.has_key(custom['name']) … … 167 167 168 168 sql = [] 169 169 sql.append("SELECT " + ", ".join(headers)) 170 custom_fields = [f['name'] for f in get_custom_fields(self. env)]170 custom_fields = [f['name'] for f in get_custom_fields(self.req.hdf, self.env, self.db)] 171 171 for k in [k for k in constraints.keys() if k in custom_fields]: 172 172 sql.append(", %s.value AS %s" % (k, k)) 173 173 sql.append(" FROM ticket") -
trac/Ticket.py
28 28 import perm 29 29 import util 30 30 from Module import Module 31 from WikiFormatter import wiki_to_html 31 from WikiFormatter import wiki_to_html, wiki_to_oneliner 32 32 from Notify import TicketNotifyEmail 33 33 34 34 __all__ = ['Ticket', 'NewticketModule', 'TicketModule'] … … 207 207 else: 208 208 return 0 209 209 210 def get_custom_fields( env):210 def get_custom_fields(hdf, env, db): 211 211 cfg = env.get_config_items('ticket-custom') 212 212 if not cfg: 213 213 return [] … … 223 223 'name': name, 224 224 'type': items[name], 225 225 'order': items.get(name + '.order', '0'), 226 'label': items.get(name + '.label', ''),226 'label': wiki_to_oneliner(items.get(name + '.label', ''), hdf, env, db), 227 227 'value': items.get(name + '.value', '') 228 228 } 229 229 if field['type'] == 'select' or field['type'] == 'radio': … … 237 237 return fields 238 238 239 239 240 def insert_custom_fields( env, hdf, vals = {}):241 fields = get_custom_fields( env)240 def insert_custom_fields(hdf, env, db, vals = {}): 241 fields = get_custom_fields(hdf, env, db) 242 242 i = 0 243 243 for f in fields: 244 244 name = f['name'] … … 328 328 util.sql_to_hdf(self.db, 'SELECT name FROM version ORDER BY name', 329 329 self.req.hdf, 'newticket.versions') 330 330 331 insert_custom_fields(self. env, self.req.hdf, ticket)331 insert_custom_fields(self.req.hdf, self.env, self.db, ticket) 332 332 333 333 334 334 class TicketModule (Module): … … 423 423 hdf.setValue('ticket.changes.%d.new' % idx, util.escape(new)) 424 424 idx = idx + 1 425 425 426 insert_custom_fields( self.env, hdf, ticket)426 insert_custom_fields(hdf, self.env, self.db, ticket) 427 427 # List attached files 428 428 self.env.get_attachments_hdf(self.db, 'ticket', str(id), self.req.hdf, 429 429 'ticket.attachments')
