@@ -21,8 +21,12 class Attachment < ActiveRecord::Base | |||
|
21 | 21 | belongs_to :container, :polymorphic => true |
|
22 | 22 | belongs_to :author, :class_name => "User", :foreign_key => "author_id" |
|
23 | 23 | |
|
24 | @@max_size = $RDM_ATTACHMENT_MAX_SIZE || 5*1024*1024 | |
|
25 | cattr_reader :max_size | |
|
26 | ||
|
24 | 27 | validates_presence_of :container, :filename |
|
25 | ||
|
28 | validates_inclusion_of :filesize, :in => 1..@@max_size | |
|
29 | ||
|
26 | 30 | def file=(incomming_file) |
|
27 | 31 | unless incomming_file.nil? |
|
28 | 32 | @temp_file = incomming_file |
@@ -31,7 +31,7 | |||
|
31 | 31 | <%= start_form_tag ({ :controller => 'documents', :action => 'add_attachment', :id => @document }, :multipart => true, :class => "tabular") %> |
|
32 | 32 | <p id="attachments_p"><label for="attachment_file"><%=l(:label_attachment)%> |
|
33 | 33 | <%= link_to_function image_tag('add'), "addFileField()" %></label> |
|
34 | <%= file_field_tag 'attachments[]', :size => 30 %></p> | |
|
34 | <%= file_field_tag 'attachments[]', :size => 30 %> <em>(<%= l(:label_max_size) %>: <%= human_size(Attachment.max_size) %>)</em></p> | |
|
35 | 35 | <%= submit_tag l(:button_add) %> |
|
36 | 36 | <%= end_form_tag %> |
|
37 | 37 | <% end %> |
@@ -89,7 +89,7 end %> | |||
|
89 | 89 | <%= start_form_tag ({ :controller => 'issues', :action => 'add_attachment', :id => @issue }, :multipart => true, :class => "tabular") %> |
|
90 | 90 | <p id="attachments_p"><label><%=l(:label_attachment_new)%> |
|
91 | 91 | <%= link_to_function image_tag('add'), "addFileField()" %></label> |
|
92 | <%= file_field_tag 'attachments[]', :size => 30 %></p> | |
|
92 | <%= file_field_tag 'attachments[]', :size => 30 %> <em>(<%= l(:label_max_size) %>: <%= human_size(Attachment.max_size) %>)</em></p> | |
|
93 | 93 | <%= submit_tag l(:button_add) %> |
|
94 | 94 | <%= end_form_tag %> |
|
95 | 95 | <% end %> |
@@ -6,7 +6,7 | |||
|
6 | 6 | <div class="box"> |
|
7 | 7 | <p id="attachments_p"><label for="attachment_file"><%=l(:label_attachment)%> |
|
8 | 8 | <%= link_to_function image_tag('add'), "addFileField()" %></label> |
|
9 | <%= file_field_tag 'attachments[]', :size => 30 %></p> | |
|
9 | <%= file_field_tag 'attachments[]', :size => 30 %> <em>(<%= l(:label_max_size) %>: <%= human_size(Attachment.max_size) %>)</em></p> | |
|
10 | 10 | </div> |
|
11 | 11 | |
|
12 | 12 | <%= submit_tag l(:button_create) %> |
@@ -9,7 +9,7 | |||
|
9 | 9 | |
|
10 | 10 | <p id="attachments_p"><label for="attachment_file"><%=l(:label_attachment)%> |
|
11 | 11 | <%= link_to_function image_tag('add'), "addFileField()" %></label> |
|
12 | <%= file_field_tag 'attachments[]', :size => 30 %></p> | |
|
12 | <%= file_field_tag 'attachments[]', :size => 30 %> <em>(<%= l(:label_max_size) %>: <%= human_size(Attachment.max_size) %>)</em></p> | |
|
13 | 13 | </div> |
|
14 | 14 | <%= submit_tag l(:button_add) %> |
|
15 | 15 | <%= end_form_tag %> No newline at end of file |
@@ -27,7 +27,7 | |||
|
27 | 27 | |
|
28 | 28 | <p id="attachments_p"><label for="attachment_file"><%=l(:label_attachment)%> |
|
29 | 29 | <%= link_to_function image_tag('add'), "addFileField()" %></label> |
|
30 | <%= file_field_tag 'attachments[]', :size => 30 %></p> | |
|
30 | <%= file_field_tag 'attachments[]', :size => 30 %> <em>(<%= l(:label_max_size) %>: <%= human_size(Attachment.max_size) %>)</em></p> | |
|
31 | 31 | |
|
32 | 32 | </div> |
|
33 | 33 | <!--[eoform:issue]--> |
@@ -63,3 +63,7 | |||
|
63 | 63 | # Textile formatting is automativaly disabled if RedCloth is not available |
|
64 | 64 | # Set to true to manually disable. |
|
65 | 65 | # $RDM_TEXTILE_DISABLED = true |
|
66 | ||
|
67 | # Maximum size for attachments (in bytes) | |
|
68 | # Default to 5 MB | |
|
69 | # $RDM_ATTACHMENT_MAX_SIZE = 5*1024*1024 |
@@ -295,6 +295,7 label_modified: geändert | |||
|
295 | 295 | label_deleted: gelöscht |
|
296 | 296 | label_latest_revision: Neueste Neuausgabe |
|
297 | 297 | label_view_revisions: Die Neuausgaben ansehen |
|
298 | label_max_size: Maximale Größe | |
|
298 | 299 | |
|
299 | 300 | button_login: Einloggen |
|
300 | 301 | button_submit: Einreichen |
@@ -295,6 +295,7 label_modified: modified | |||
|
295 | 295 | label_deleted: deleted |
|
296 | 296 | label_latest_revision: Latest revision |
|
297 | 297 | label_view_revisions: View revisions |
|
298 | label_max_size: Maximum size | |
|
298 | 299 | |
|
299 | 300 | button_login: Login |
|
300 | 301 | button_submit: Submit |
General Comments 0
You need to be logged in to leave comments.
Login now