##// END OF EJS Templates
option to set maximum size of uploaded files...
Jean-Philippe Lang -
r128:6487c1803fa9
parent child
Show More
@@ -21,8 +21,12 class Attachment < ActiveRecord::Base
21 belongs_to :container, :polymorphic => true
21 belongs_to :container, :polymorphic => true
22 belongs_to :author, :class_name => "User", :foreign_key => "author_id"
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 validates_presence_of :container, :filename
27 validates_presence_of :container, :filename
25
28 validates_inclusion_of :filesize, :in => 1..@@max_size
29
26 def file=(incomming_file)
30 def file=(incomming_file)
27 unless incomming_file.nil?
31 unless incomming_file.nil?
28 @temp_file = incomming_file
32 @temp_file = incomming_file
@@ -31,7 +31,7
31 <%= start_form_tag ({ :controller => 'documents', :action => 'add_attachment', :id => @document }, :multipart => true, :class => "tabular") %>
31 <%= start_form_tag ({ :controller => 'documents', :action => 'add_attachment', :id => @document }, :multipart => true, :class => "tabular") %>
32 <p id="attachments_p"><label for="attachment_file"><%=l(:label_attachment)%>&nbsp;
32 <p id="attachments_p"><label for="attachment_file"><%=l(:label_attachment)%>&nbsp;
33 <%= link_to_function image_tag('add'), "addFileField()" %></label>
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 <%= submit_tag l(:button_add) %>
35 <%= submit_tag l(:button_add) %>
36 <%= end_form_tag %>
36 <%= end_form_tag %>
37 <% end %>
37 <% end %>
@@ -89,7 +89,7 end %>
89 <%= start_form_tag ({ :controller => 'issues', :action => 'add_attachment', :id => @issue }, :multipart => true, :class => "tabular") %>
89 <%= start_form_tag ({ :controller => 'issues', :action => 'add_attachment', :id => @issue }, :multipart => true, :class => "tabular") %>
90 <p id="attachments_p"><label><%=l(:label_attachment_new)%>&nbsp;
90 <p id="attachments_p"><label><%=l(:label_attachment_new)%>&nbsp;
91 <%= link_to_function image_tag('add'), "addFileField()" %></label>
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 <%= submit_tag l(:button_add) %>
93 <%= submit_tag l(:button_add) %>
94 <%= end_form_tag %>
94 <%= end_form_tag %>
95 <% end %>
95 <% end %>
@@ -6,7 +6,7
6 <div class="box">
6 <div class="box">
7 <p id="attachments_p"><label for="attachment_file"><%=l(:label_attachment)%>&nbsp;
7 <p id="attachments_p"><label for="attachment_file"><%=l(:label_attachment)%>&nbsp;
8 <%= link_to_function image_tag('add'), "addFileField()" %></label>
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 </div>
10 </div>
11
11
12 <%= submit_tag l(:button_create) %>
12 <%= submit_tag l(:button_create) %>
@@ -9,7 +9,7
9
9
10 <p id="attachments_p"><label for="attachment_file"><%=l(:label_attachment)%>&nbsp;
10 <p id="attachments_p"><label for="attachment_file"><%=l(:label_attachment)%>&nbsp;
11 <%= link_to_function image_tag('add'), "addFileField()" %></label>
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 </div>
13 </div>
14 <%= submit_tag l(:button_add) %>
14 <%= submit_tag l(:button_add) %>
15 <%= end_form_tag %> No newline at end of file
15 <%= end_form_tag %>
@@ -27,7 +27,7
27
27
28 <p id="attachments_p"><label for="attachment_file"><%=l(:label_attachment)%>&nbsp;
28 <p id="attachments_p"><label for="attachment_file"><%=l(:label_attachment)%>&nbsp;
29 <%= link_to_function image_tag('add'), "addFileField()" %></label>
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 </div>
32 </div>
33 <!--[eoform:issue]-->
33 <!--[eoform:issue]-->
@@ -63,3 +63,7
63 # Textile formatting is automativaly disabled if RedCloth is not available
63 # Textile formatting is automativaly disabled if RedCloth is not available
64 # Set to true to manually disable.
64 # Set to true to manually disable.
65 # $RDM_TEXTILE_DISABLED = true
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 label_deleted: gelöscht
295 label_deleted: gelöscht
296 label_latest_revision: Neueste Neuausgabe
296 label_latest_revision: Neueste Neuausgabe
297 label_view_revisions: Die Neuausgaben ansehen
297 label_view_revisions: Die Neuausgaben ansehen
298 label_max_size: Maximale Größe
298
299
299 button_login: Einloggen
300 button_login: Einloggen
300 button_submit: Einreichen
301 button_submit: Einreichen
@@ -295,6 +295,7 label_modified: modified
295 label_deleted: deleted
295 label_deleted: deleted
296 label_latest_revision: Latest revision
296 label_latest_revision: Latest revision
297 label_view_revisions: View revisions
297 label_view_revisions: View revisions
298 label_max_size: Maximum size
298
299
299 button_login: Login
300 button_login: Login
300 button_submit: Submit
301 button_submit: Submit
@@ -295,6 +295,7 label_modified: modificado
295 label_deleted: suprimido
295 label_deleted: suprimido
296 label_latest_revision: La revisión más última
296 label_latest_revision: La revisión más última
297 label_view_revisions: Ver las revisiones
297 label_view_revisions: Ver las revisiones
298 label_max_size: Tamaño máximo
298
299
299 button_login: Conexión
300 button_login: Conexión
300 button_submit: Someter
301 button_submit: Someter
@@ -296,6 +296,7 label_modified: modifié
296 label_deleted: supprimé
296 label_deleted: supprimé
297 label_latest_revision: Dernière révision
297 label_latest_revision: Dernière révision
298 label_view_revisions: Voir les révisions
298 label_view_revisions: Voir les révisions
299 label_max_size: Taille maximale
299
300
300 button_login: Connexion
301 button_login: Connexion
301 button_submit: Soumettre
302 button_submit: Soumettre
General Comments 0
You need to be logged in to leave comments. Login now