Ability to refer to an attachment by name within a template

RESOLVED FIXED

Status

Mozilla Developer Network
Wiki pages
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: openjck, Assigned: ubernostrum)

Tracking

(Blocks: 1 bug)

Details

(Whiteboard: u= c= s=2012-12-18 p=2)

Comment hidden (empty)
(Reporter)

Comment 1

5 years ago
Forgot comment 0.

Sheppy mentioned that he would like to be able to refer to an attachment by file name within templates. Sheppy: are there any other requirements that you would like to add to this feature?
Not specifically related to this, no.
(Reporter)

Updated

5 years ago
Blocks: 766741
I knew this one would come at some point.  At the moment, the "files" property given to kumascript is an array.  Would it be best if I also created a key=>value object as well, called "filesByName", which you could reference by specific file name?  Or would you prefer I create a kumascript function called "mdn.getFileByName" that found the file ... by name?

Both are feasible, just want to know what would be used most often.
Well, as it stands, we can iterate over the list of files until we find the one we want. The problem right now is that currently it's possible for one article to have multiple files by the same name, which makes this not work after all.

What this is mostly about is preventing one article from having multiple files by the same name attached (which starts getting into some core design changes to the attachment system and how it works, unfortunately).

In the short term, we can use UI to prevent people from doing this, maybe. Then adding a routine to the JS libs to find a file by name on the given page would be nice to have as well (especially since often, these attachments are not specifically linked to in the article, which breaks the way attachments are currently implemented, since we don't have a database to track non-linked-to articles).

This gets into quite a can of worms.
Version: Kuma → unspecified
Component: Website → Landing pages
Product: Mozilla Developer Network → Mozilla Developer Network
(Assignee)

Updated

5 years ago
QA Contact: website → jbennett
(Assignee)

Updated

5 years ago
Assignee: nobody → jbennett

Comment 5

5 years ago
Commits pushed to master at https://github.com/mozilla/kuma

https://github.com/mozilla/kuma/commit/1c9c8c8a2b572d422c46c327ec3cfd44790ce5e7
Fix bug 779536: support for referring to files by name.

This is only the Django side of the support, and requires a merge of
the m2m-attachment code for bug 779543. It adds a 'files_dict' method
to Document, which returns a dictionary, keyed by the name on the
intermediate DocumentAttachment, of dictionaries of file information.

https://github.com/mozilla/kuma/commit/563eedf07e99ebf31c45af3e6b935fa11c4dd2e1
Merge pull request #774 from ubernostrum/files-by-name

Bug 779536: files by name

Updated

5 years ago
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
(Assignee)

Updated

5 years ago
Whiteboard: u= c= s= p= → u= c= s=2012-12-18 p=2
You need to log in before you can comment on or make changes to this bug.