Ticket #222: trac.ticket.222.diff
| File trac.ticket.222.diff, 5.9 kB (added by ivanoe@…, 4 years ago) |
|---|
-
templates/header.cs
39 39 <form id="search" action="<?cs var:trac.href.search ?>" method="get"> 40 40 <?cs if:trac.acl.SEARCH_VIEW ?><div> 41 41 <label for="proj-search">Search:</label> 42 <input type="text" id="proj-search" name="q" size=" 10" value="" />42 <input type="text" id="proj-search" name="q" size="25" value="" /> 43 43 <input type="submit" value="Search" /> 44 44 <input type="hidden" name="wiki" value="on" /> 45 45 <input type="hidden" name="changeset" value="on" /> -
templates/newticket.cs
59 59 <label for="milestone">Milestone:</label><?cs 60 60 call:hdf_select(newticket.milestones, "milestone", newticket.milestone) ?><br /> 61 61 <label for="owner">Assign to:</label> 62 <input type="text" id="owner" name="owner" size="20" value="<?cs 63 var:newticket.owner ?>" /><br /> 62 <?cs call:hdf_select(newticket.owners, "owner", newticket.owner) ?><br /> 64 63 <label for="cc">Cc:</label> 65 64 <input type="text" id="cc" name="cc" size="30" value="<?cs var:newticket.cc ?>" /> 66 65 </div> -
templates/ticket.cs
235 235 <?cs call:action_radio('reassign') ?> 236 236 <label for="reassign">reassign</label> 237 237 <label for="reassign_owner">to:</label> 238 <input type="text" id="reassign_owner" name="reassign_owner" size="40" value="<?cs 239 if:args.reassign_to ?><?cs var:args.reassign_to ?><?cs 240 else ?><?cs var:trac.authname ?><?cs /if ?>" /><?cs 238 <?cs call:hdf_select(ticket.owners, "reassign_owner", args.reassign_to) ?><?cs 241 239 /if ?><?cs 242 240 if $ticket.status == "new" || $ticket.status == "assigned" || $ticket.status == "reopened" ?> 243 241 <script type="text/javascript"> -
trac/Ticket.py
19 19 # 20 20 # Author: Jonas Borgstr�jonas@edgewall.com> 21 21 22 import os 22 23 import re 23 24 import time 24 25 import string … … 263 264 hdf.setValue('%s.height' % pfx, f['height']) 264 265 i += 1 265 266 267 class TicketModuleBase(Module): 268 """ 269 Contains common members for Ticket and NewTicket 270 """ 271 def _add_users_to_hdf(self, key): 272 """ 273 Adds list of configured users to hdf. The list of users is taken from apache password file, 274 if one is configured using environment value 'TRAC_PWDFILE' in httpd.conf. 275 Otherwise the list of users is retrieved from the 'permission' table. 276 Anonymous user is excluded. Empty user is added. 277 """ 278 passwordfile = os.getenv( 'TRAC_PWDFILE' ) 279 if passwordfile: 280 pwdfile = None 281 # Get list of users from the configured apache password file 282 try: 283 pwdfile = open( passwordfile, 'r' ) 284 for line in pwdfile: 285 pos = string.find(line, ':') 286 if ( pos == -1 ): 287 self.log.warn( 'corrupted passwordfile or unknown file format' ) 288 else: 289 util.hdf_add_if_missing(self.req.hdf, key, line[:pos]) 290 finally: 291 if pwdfile: 292 pwdfile.close() 293 else: 294 # Get list of users from trac 'permission' table 295 util.sql_to_hdf(self.db, 'SELECT distinct username FROM permission WHERE username NOT IN ' 296 '(SELECT DISTINCT action FROM permission) AND username <> \'anonymous\' ORDER BY username', 297 self.req.hdf, key) 266 298 267 class NewticketModule(Module): 299 util.hdf_add_if_missing(self.req.hdf, key, '') 300 util.hdf_sort(self.req.hdf, key) 301 302 303 class NewticketModule(TicketModuleBase): 268 304 template_name = 'newticket.cs' 269 305 270 306 def create_ticket(self): … … 327 363 self.req.hdf, 'newticket.milestones') 328 364 util.sql_to_hdf(self.db, 'SELECT name FROM version ORDER BY name', 329 365 self.req.hdf, 'newticket.versions') 330 331 366 insert_custom_fields(self.env, self.req.hdf, ticket) 367 self._add_users_to_hdf( 'newticket.owners' ) 332 368 333 369 334 class TicketModule ( Module):370 class TicketModule (TicketModuleBase): 335 371 template_name = 'ticket.cs' 336 372 337 373 def save_changes (self, id): … … 390 426 util.sql_to_hdf(self.db, "SELECT name FROM enum WHERE type='resolution'" 391 427 " ORDER BY value", 392 428 self.req.hdf, 'enums.resolution') 429 self._add_users_to_hdf( 'ticket.owners' ) 393 430 util.hdf_add_if_missing(self.req.hdf, 'ticket.components', ticket['component']) 394 431 util.hdf_add_if_missing(self.req.hdf, 'ticket.milestones', ticket['milestone']) 395 432 util.hdf_add_if_missing(self.req.hdf, 'ticket.versions', ticket['version']) -
trac/util.py
173 173 hdf.setValue('%s.%d.name' % (prefix, idx), row[0]) 174 174 idx = idx + 1 175 175 176 def hdf_sort (hdf, prefix): 177 """ 178 sorts all the values found in hdf for given prefix 179 """ 180 node = hdf.getObj(prefix + '.0') 181 values = [] 182 while node: 183 child = node.child() 184 if child: 185 values.append( child.value() ) 186 node = node.next() 187 188 values.sort() 189 for i in range(len(values)): 190 add_to_hdf(values[i], hdf, '%s.%d.name' % (prefix, i)) 191 176 192 def hdf_add_if_missing(hdf, prefix, value): 177 193 """Loop through the hdf values and add @value if id doesn't exist""" 178 194 node = hdf.getObj(prefix + '.0')
