To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / .svn / pristine / 45 / 45fedacb83fa4bf0b530842cc4c9e44d1242cd73.svn-base @ 1298:4f746d8966dd
History | View | Annotate | Download (2.03 KB)
| 1 | 1295:622f24f53b42 | Chris | # encoding: utf-8 |
|---|---|---|---|
| 2 | # |
||
| 3 | # Redmine - project management software |
||
| 4 | # Copyright (C) 2006-2013 Jean-Philippe Lang |
||
| 5 | # |
||
| 6 | # This program is free software; you can redistribute it and/or |
||
| 7 | # modify it under the terms of the GNU General Public License |
||
| 8 | # as published by the Free Software Foundation; either version 2 |
||
| 9 | # of the License, or (at your option) any later version. |
||
| 10 | # |
||
| 11 | # This program is distributed in the hope that it will be useful, |
||
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 14 | # GNU General Public License for more details. |
||
| 15 | # |
||
| 16 | # You should have received a copy of the GNU General Public License |
||
| 17 | # along with this program; if not, write to the Free Software |
||
| 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
||
| 19 | |||
| 20 | module AttachmentsHelper |
||
| 21 | # Displays view/delete links to the attachments of the given object |
||
| 22 | # Options: |
||
| 23 | # :author -- author names are not displayed if set to false |
||
| 24 | # :thumbails -- display thumbnails if enabled in settings |
||
| 25 | def link_to_attachments(container, options = {})
|
||
| 26 | options.assert_valid_keys(:author, :thumbnails) |
||
| 27 | |||
| 28 | if container.attachments.any? |
||
| 29 | options = {:deletable => container.attachments_deletable?, :author => true}.merge(options)
|
||
| 30 | render :partial => 'attachments/links', |
||
| 31 | :locals => {:attachments => container.attachments, :options => options, :thumbnails => (options[:thumbnails] && Setting.thumbnails_enabled?)}
|
||
| 32 | end |
||
| 33 | end |
||
| 34 | |||
| 35 | def render_api_attachment(attachment, api) |
||
| 36 | api.attachment do |
||
| 37 | api.id attachment.id |
||
| 38 | api.filename attachment.filename |
||
| 39 | api.filesize attachment.filesize |
||
| 40 | api.content_type attachment.content_type |
||
| 41 | api.description attachment.description |
||
| 42 | api.content_url url_for(:controller => 'attachments', :action => 'download', :id => attachment, :filename => attachment.filename, :only_path => false) |
||
| 43 | api.author(:id => attachment.author.id, :name => attachment.author.name) if attachment.author |
||
| 44 | api.created_on attachment.created_on |
||
| 45 | end |
||
| 46 | end |
||
| 47 | end |