Edgewall Software

Ticket #4019: TicketApiAddMissingFieldsOptional.diff

File TicketApiAddMissingFieldsOptional.diff, 1.3 KB (added by ilias@…, 5 years ago)

patch with added option "all_fields"

  • api.py

     
    8585        return [action for action in actions.get(ticket['status'], ['leave']) 
    8686                if action not in perms or perm_.has_permission(perms[action])] 
    8787 
    88     def get_ticket_fields(self): 
    89         """Returns the list of fields available for tickets.""" 
     88    def get_ticket_fields(self, all_fields=False): 
     89        """Returns the list of fields available for tickets. 
     90        optional Bool parameter 'all_fields': 
     91          True:  return all available fields 
     92          False: return only fields for display within Ticket GUI (default)""" 
    9093        from trac.ticket import model 
    9194 
    9295        db = self.env.get_db_cnx() 
     
    142145            field = {'name': name, 'type': 'text', 'label': name.title()} 
    143146            fields.append(field) 
    144147 
     148        # DateTime fields 
     149        if (all_fields): 
     150            fields.append( {'name': 'time', 'type': 'text', 'label': 'Created'} ) 
     151            fields.append( {'name': 'changetime', 'type': 'text', 'label': 'Modified'} )                
     152 
    145153        for field in self.get_custom_fields(): 
    146154            if field['name'] in [f['name'] for f in fields]: 
    147155                self.log.warning('Duplicate field name "%s" (ignoring)',