Ticket #7339: trac-show_full_names.diff
| File trac-show_full_names.diff, 4.0 KB (added by michael.grundberg@…, 7 months ago) |
|---|
-
ticket/default_workflow.py
27 27 from trac.ticket.api import ITicketActionController, TicketSystem 28 28 from trac.util.compat import set 29 29 from trac.util.translation import _ 30 from trac.web.chrome import Chrome 30 31 31 32 # -- Utilities for the ConfigurableTicketWorkflow 32 33 … … 218 219 this_action = self.actions[action] 219 220 status = this_action['newstate'] 220 221 operations = this_action['operations'] 222 chrome = Chrome(self.env) 221 223 222 224 control = [] # default to nothing 223 225 hints = [] … … 251 253 hints.append(_("The owner will change to %s") % owners[0]) 252 254 else: 253 255 control.append(tag([_("to "), tag.select( 254 [tag.option( x, selected=(x == selected_owner or None))256 [tag.option(chrome.format_author(req, x), value=x, selected=(x == selected_owner or None)) 255 257 for x in owners], 256 258 id=id, name=id)])) 257 259 hints.append(_("The owner will change")) … … 369 371 self._has_perms_for_action(req, info, ticket.resource)] 370 372 return actions 371 373 374 -
ticket/templates/ticket.html
310 310 <select py:when="'select'" id="field-${field.name}" name="field_${field.name}"> 311 311 <option py:if="field.optional"></option> 312 312 <option py:for="option in field.options" 313 value="${option}" 313 314 selected="${ticket[field.name] == option or None}" 314 py:content=" option"></option>315 py:content="format_author(option)"></option> 315 316 <optgroup py:for="optgroup in field.optgroups" 316 317 label="${optgroup.label}"> 317 318 <option py:for="option in optgroup.options" -
test.py
211 211 def get_db_cnx(self): 212 212 return self.db 213 213 214 def get_known_users(self, db ):214 def get_known_users(self, db=None): 215 215 return self.known_users 216 216 217 217 -
web/chrome.py
277 277 show_email_addresses = BoolOption('trac', 'show_email_addresses', 'false', 278 278 """Show email addresses instead of usernames. If false, we obfuscate 279 279 email addresses (''since 0.11'').""") 280 281 show_full_names = BoolOption('trac', 'show_full_names', 'false', 282 """Show full names instead of usernames.""") 283 280 284 281 285 templates = None 282 286 … … 319 323 import genshi 320 324 self.env.systeminfo.append(('Genshi', 321 325 get_pkginfo(genshi).get('version'))) 326 # Get the user infor of all known users 327 self.user_map = {} 328 for username, name, email in self.env.get_known_users(): 329 self.user_map[username] = (name, email) 322 330 323 331 # IEnvironmentSetupParticipant methods 324 332 … … 750 758 all_cc = self.cc_list(value) 751 759 if not (self.show_email_addresses or 'EMAIL_VIEW' in context.perm): 752 760 all_cc = [obfuscate_email_address(cc) for cc in all_cc] 761 else: 762 all_cc = [self.format_author(context, cc) for cc in all_cc] 753 763 return sep.join(all_cc) 754 764 755 765 def format_author(self, req, author): 756 766 if self.show_email_addresses or not req or 'EMAIL_VIEW' in req.perm: 767 if self.show_full_names and self.user_map.has_key(author) and self.user_map[author][0]: 768 return self.user_map[author][0] 757 769 return author 758 770 else: 759 771 return obfuscate_email_address(author)
