Edgewall Software

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

     
    2727from trac.ticket.api import ITicketActionController, TicketSystem 
    2828from trac.util.compat import set 
    2929from trac.util.translation import _ 
     30from trac.web.chrome import Chrome 
    3031 
    3132# -- Utilities for the ConfigurableTicketWorkflow 
    3233 
     
    218219        this_action = self.actions[action] 
    219220        status = this_action['newstate']         
    220221        operations = this_action['operations'] 
     222        chrome = Chrome(self.env) 
    221223 
    222224        control = [] # default to nothing 
    223225        hints = [] 
     
    251253                    hints.append(_("The owner will change to %s") % owners[0]) 
    252254            else: 
    253255                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)) 
    255257                     for x in owners], 
    256258                    id=id, name=id)])) 
    257259                hints.append(_("The owner will change")) 
     
    369371                      self._has_perms_for_action(req, info, ticket.resource)] 
    370372        return actions 
    371373 
     374 
  • ticket/templates/ticket.html

     
    310310                    <select py:when="'select'" id="field-${field.name}" name="field_${field.name}"> 
    311311                      <option py:if="field.optional"></option> 
    312312                      <option py:for="option in field.options" 
     313                              value="${option}" 
    313314                              selected="${ticket[field.name] == option or None}" 
    314                               py:content="option"></option> 
     315                              py:content="format_author(option)"></option> 
    315316                      <optgroup py:for="optgroup in field.optgroups" 
    316317                                label="${optgroup.label}"> 
    317318                        <option py:for="option in optgroup.options" 
  • test.py

     
    211211    def get_db_cnx(self): 
    212212        return self.db 
    213213 
    214     def get_known_users(self, db): 
     214    def get_known_users(self, db=None): 
    215215        return self.known_users 
    216216 
    217217 
  • web/chrome.py

     
    277277    show_email_addresses = BoolOption('trac', 'show_email_addresses', 'false', 
    278278        """Show email addresses instead of usernames. If false, we obfuscate 
    279279        email addresses (''since 0.11'').""") 
     280     
     281    show_full_names = BoolOption('trac', 'show_full_names', 'false', 
     282        """Show full names instead of usernames.""") 
     283         
    280284 
    281285    templates = None 
    282286 
     
    319323        import genshi 
    320324        self.env.systeminfo.append(('Genshi', 
    321325                                    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) 
    322330 
    323331    # IEnvironmentSetupParticipant methods 
    324332 
     
    750758        all_cc = self.cc_list(value) 
    751759        if not (self.show_email_addresses or 'EMAIL_VIEW' in context.perm): 
    752760            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] 
    753763        return sep.join(all_cc) 
    754764     
    755765    def format_author(self, req, author): 
    756766        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] 
    757769            return author 
    758770        else: 
    759771            return obfuscate_email_address(author)