Opened 13 years ago
Closed 12 years ago
#10280 closed defect (fixed)
Attachments page missing ticket number
Reported by: | Thijs Triemstra | Owned by: | Christian Boos |
---|---|---|---|
Priority: | normal | Milestone: | 0.12.5 |
Component: | attachment | Version: | 0.13dev |
Severity: | normal | Keywords: | bitesized |
Cc: | ryano@… | Branch: | |
Release Notes: |
More robust processing of attachment URLs for accessing the list of attachments of a resource (i.e. |
||
API Changes: | |||
Internal Changes: |
Description (last modified by )
When you visit the root of an attachment page (example) a confusing page is displayed with the title 'Ticket # - Attachments' + the project name. This also happens for a ticket with no attachments at all.
I would expect the ticket number to be included and display a list of available attachments.
Attachments (0)
Change History (8)
comment:1 by , 13 years ago
Description: | modified (diff) |
---|
comment:2 by , 13 years ago
comment:4 by , 12 years ago
Cc: | added |
---|
comment:5 by , 12 years ago
This issue has come up in several plugins: th:#10352, th:#9785, th:#9787.
comment:6 by , 12 years ago
Milestone: | next-minor-0.12.x → 0.12.5 |
---|---|
Owner: | set to |
With the following modification, a request to /attachment/ticket/698
becomes the same as one for /attachment/ticket/698/
.
-
trac/attachment.py
diff --git a/trac/attachment.py b/trac/attachment.py index 484c93d..cbf143d 100644
a b class AttachmentModule(Component): 435 435 filename = None 436 436 437 437 if not parent_realm or not path: 438 raise HTTPBadRequest(_( 'Bad request'))438 raise HTTPBadRequest(_("Improper attachment request")) 439 439 440 440 parent_realm = Resource(parent_realm) 441 441 action = req.args.get('action', 'view') … … class AttachmentModule(Component): 443 443 parent_id = path.rstrip('/') 444 444 else: 445 445 segments = path.split('/') 446 parent_id = '/'.join(segments[:-1]) 447 filename = len(segments) > 1 and segments[-1] 446 if len(segments) > 1: 447 parent_id, filename = '/'.join(segments[:-1]), segments[-1] 448 else: 449 parent_id, filename = segments[0], '' 448 450 449 451 parent = parent_realm(id=parent_id)
There's one subtelty: /attachment/wiki/TracDev/Proposals/
would show the attachments for the wiki page TracDev/Proposals, whereas /attachment/wiki/TracDev/Proposals
would show the attachment named Proposals
for the page TracDev. I think that's OK.
comment:7 by , 12 years ago
…and it's perhaps not worth splitting path for joining moments later:
-
trac/attachment.py
diff --git a/trac/attachment.py b/trac/attachment.py index 484c93d..cbace7a 100644
a b class AttachmentModule(Component): 442 442 if action == 'new': 443 443 parent_id = path.rstrip('/') 444 444 else: 445 segments = path.split('/') 446 parent_id = '/'.join(segments[:-1]) 447 filename = len(segments) > 1 and segments[-1] 445 last_slash = path.rfind('/') 446 if last_slash == -1: 447 parent_id, filename = path, '' 448 else: 449 parent_id, filename = path[:last_slash], path[last_slash + 1:] 448 450 449 451 parent = parent_realm(id=parent_id)
comment:8 by , 12 years ago
Release Notes: | modified (diff) |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Last patch applied in r11356.
Actually the problem happens when the trailing slash is missing, so: