Closed Bug 779536 Opened 12 years ago Closed 12 years ago

Ability to refer to an attachment by name within a template

Categories

(developer.mozilla.org Graveyard :: Wiki pages, defect)

x86_64
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: openjck, Assigned: jbennett)

References

Details

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

      No description provided.
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.
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
QA Contact: website → jbennett
Assignee: nobody → jbennett
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
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Whiteboard: u= c= s= p= → u= c= s=2012-12-18 p=2
Product: developer.mozilla.org → developer.mozilla.org Graveyard
You need to log in before you can comment on or make changes to this bug.