Edgewall Software

Ticket #2561: attachment-result-format.patch

File attachment-result-format.patch, 1.5 KB (added by Remy Blank <remy.blank@…>, 4 months ago)

Change attachment search result format to <filename> (<parent_name>)

  • trac/attachment.py

    diff --git a/trac/attachment.py b/trac/attachment.py
    a b  
    497497            attachment = resource_realm(id=id).child('attachment', filename) 
    498498            if 'ATTACHMENT_VIEW' in req.perm(attachment): 
    499499                yield (get_resource_url(self.env, attachment, req.href), 
    500                        "%s: %s" % (get_resource_shortname(self.env,  
    501                                                           attachment.parent), 
    502                                    filename), 
     500                       get_resource_shortname(self.env, attachment), 
    503501                       datetime.fromtimestamp(time, utc), author, 
    504502                       shorten_result(desc, terms)) 
    505503     
     
    530528 
    531529    def get_resource_description(self, resource, format=None, **kwargs): 
    532530        if format == 'compact': 
    533             return '%s:%s' % (get_resource_shortname(self.env, 
    534                                                      resource.parent), 
    535                               resource.filename) 
     531            return '%s (%s)' % (resource.id, 
     532                    get_resource_name(self.env, resource.parent)) 
    536533        elif format == 'summary': 
    537534            return Attachment(self.env, resource).description 
    538535        if resource.id: 
    539             return _("Attachment '%(id)s' in %(parent)s", id=resource.id, 
     536            return _('Attachment "%(id)s" in %(parent)s', id=resource.id, 
    540537                     parent=get_resource_name(self.env, resource.parent)) 
    541538        else: 
    542539            return _("Attachments of %(parent)s",