diff --git a/app/controllers/dmsf_controller.rb b/app/controllers/dmsf_controller.rb index af06b2f7..45172c6f 100644 --- a/app/controllers/dmsf_controller.rb +++ b/app/controllers/dmsf_controller.rb @@ -75,7 +75,7 @@ class DmsfController < ApplicationController DmsfMailer.send_documents(User.current, @email_params["to"], @email_params["cc"], @email_params["subject"], @email_params["zipped_content"], @email_params["body"]).deliver File.delete(@email_params["zipped_content"]) - flash[:notice] = l(:notice_email_sent) + flash[:notice] = l(:notice_email_sent, @email_params["to"]) redirect_to({:controller => "dmsf", :action => "show", :id => @project, :folder_id => @folder}) end @@ -203,26 +203,46 @@ class DmsfController < ApplicationController redirect_to :controller => "dmsf", :action => "show", :id => @project end - def notify_activate - if @folder.notification + def notify_activate + if((@folder && @folder.notification) || (@folder.nil? && @project.dmsf_notification)) flash[:warning] = l(:warning_folder_notifications_already_activated) else - @folder.notify_activate + if @folder + @folder.notify_activate + else + @project.dmsf_notification = true + @project.save + end flash[:notice] = l(:notice_folder_notifications_activated) end - redirect_to params[:current] ? params[:current] : - {:controller => "dmsf", :action => "show", :id => @project, :folder_id => @folder.folder} + if params[:current] + redirect_to params[:current] + elsif @folder + redirect_to({:controller => 'dmsf', :action => 'show', :id => @project, :folder_id => @folder.folder}) + else + redirect_to({:controller => 'dmsf', :action => 'show', :id => @project}) + end end def notify_deactivate - if !@folder.notification + if((@folder && !@folder.notification) || (@folder.nil? && !@project.dmsf_notification)) flash[:warning] = l(:warning_folder_notifications_already_deactivated) else - @folder.notify_deactivate + if @folder + @folder.notify_deactivate + else + @project.dmsf_notification = false + @project.save + end flash[:notice] = l(:notice_folder_notifications_deactivated) end - redirect_to params[:current] ? params[:current] : - {:controller => "dmsf", :action => "show", :id => @project, :folder_id => @folder.folder} + if params[:current] + redirect_to params[:current] + elsif @folder + redirect_to({:controller => 'dmsf', :action => 'show', :id => @project, :folder_id => @folder.folder}) + else + redirect_to({:controller => 'dmsf', :action => 'show', :id => @project}) + end end diff --git a/app/controllers/dmsf_files_controller.rb b/app/controllers/dmsf_files_controller.rb index 6b107d33..f87fed4c 100644 --- a/app/controllers/dmsf_files_controller.rb +++ b/app/controllers/dmsf_files_controller.rb @@ -49,7 +49,11 @@ class DmsfFilesController < ApplicationController end end check_project(@revision.file) - send_revision + begin + send_revision + rescue ActionController::MissingFile => e + render_404 + end return end @@ -125,7 +129,7 @@ class DmsfFilesController < ApplicationController begin DmsfMailer.files_updated(User.current, [@file]).deliver rescue ActionView::MissingTemplate => e - Rails.logger.error "Could not send email notifications: " + e + Rails.logger.error "Could not send email notifications: #{e.message}" end redirect_to :action => "show", :id => @file else diff --git a/app/controllers/dmsf_files_copy_controller.rb b/app/controllers/dmsf_files_copy_controller.rb index c1aba7f9..016d0402 100644 --- a/app/controllers/dmsf_files_copy_controller.rb +++ b/app/controllers/dmsf_files_copy_controller.rb @@ -72,7 +72,7 @@ class DmsfFilesCopyController < ApplicationController begin DmsfMailer.files_updated(User.current, [new_file]).deliver rescue ActionView::MissingTemplate => e - Rails.logger.error "Could not send email notifications: " + e + Rails.logger.error "Could not send email notifications: #{e.message}" end redirect_to :controller => "dmsf_files", :action => "show", :id => new_file @@ -110,7 +110,7 @@ class DmsfFilesCopyController < ApplicationController # TODO: implement proper mail notification DmsfMailer.files_updated(User.current, [@file]).deliver rescue ActionView::MissingTemplate => e - Rails.logger.error "Could not send email notifications: " + e + Rails.logger.error "Could not send email notifications: #{e.message}" end redirect_to :controller => "dmsf_files", :action => "show", :id => @file diff --git a/app/controllers/dmsf_upload_controller.rb b/app/controllers/dmsf_upload_controller.rb index 019c3f2b..78037d0f 100644 --- a/app/controllers/dmsf_upload_controller.rb +++ b/app/controllers/dmsf_upload_controller.rb @@ -121,8 +121,7 @@ class DmsfUploadController < ApplicationController new_revision.title = commited_file["title"] new_revision.description = commited_file["description"] new_revision.comment = commited_file["comment"] - new_revision.increase_version(commited_file["version"].to_i, true) - #new_revision.set_workflow(commited_file[:dmsf_workflow_id], nil) + new_revision.increase_version(commited_file["version"].to_i, true) new_revision.mime_type = Redmine::MimeType.of(new_revision.name) new_revision.size = File.size(commited_disk_filepath) @@ -134,8 +133,13 @@ class DmsfUploadController < ApplicationController end if file.locked? - file.unlock! - flash[:notice] = l(:notice_file_unlocked) + begin + file.unlock! + flash[:notice] = l(:notice_file_unlocked) + rescue DmsfLockError => e + flash[:error] = e.message + next + end end # Need to save file first to generate id for it in case of creation. diff --git a/app/models/dmsf_file.rb b/app/models/dmsf_file.rb index 6fd87643..e2294682 100644 --- a/app/models/dmsf_file.rb +++ b/app/models/dmsf_file.rb @@ -125,23 +125,23 @@ class DmsfFile < ActiveRecord::Base end def title - self.last_revision.title + self.last_revision ? self.last_revision.title : self.name end def description - self.last_revision.description + self.last_revision ? self.last_revision.description : '' end def version - self.last_revision.version + self.last_revision ? self.last_revision.version : '0' end def workflow - self.last_revision.workflow + self.last_revision ? self.last_revision.workflow : nil end def size - self.last_revision.size + self.last_revision ? self.last_revision.size : 0 end def dmsf_path @@ -150,15 +150,14 @@ class DmsfFile < ActiveRecord::Base path end - def dmsf_path_str - path = self.dmsf_path - string_path = path.map { |element| element.title } - string_path.join("/") + def dmsf_path_str + self.dmsf_path.map { |element| element.title }.join('/') end def notify? return true if self.notification return true if folder && folder.notify? + return true if !folder && self.project.dmsf_notification return false end diff --git a/app/models/dmsf_folder.rb b/app/models/dmsf_folder.rb index 8ab595e2..45103f67 100644 --- a/app/models/dmsf_folder.rb +++ b/app/models/dmsf_folder.rb @@ -115,6 +115,7 @@ class DmsfFolder < ActiveRecord::Base def notify? return true if self.notification return true if folder && folder.notify? + return true if !folder && self.project.dmsf_notification return false end diff --git a/app/views/dmsf/_path.html.erb b/app/views/dmsf/_path.html.erb deleted file mode 100644 index a937bff4..00000000 --- a/app/views/dmsf/_path.html.erb +++ /dev/null @@ -1,8 +0,0 @@ -<%= link_to(l(:link_documents), {:controller => "dmsf", :action => "show", :id=> @project }) %> -<% path.each do |path_element| %> - / - <%= link_to(h(path_element.title), {:controller => "dmsf", :action => "show", :id=> @project, :folder_id => path_element}) %> - <% if path_element.notification %> - <%= image_tag("notify.png", :plugin => "redmine_dmsf", :title => l(:title_notifications_active)) %> - <% end %> -<% end %> diff --git a/app/views/dmsf/edit.html.erb b/app/views/dmsf/edit.html.erb index 171896ca..90b31c0d 100644 --- a/app/views/dmsf/edit.html.erb +++ b/app/views/dmsf/edit.html.erb @@ -7,9 +7,15 @@ <% create = @pathfolder == @parent %> -
- <%= label_tag("project_dmsf_description", l(:label_description) + ":") %> -
-+ <%= label_tag('project_dmsf_description', "#{l(:label_description)}:") %> +
+- <%= h(file.dmsf_path_str) %> (<%= file.name %>), - <%= number_to_human_size(file.last_revision.size) %>, - version: <%= file.last_revision.major_version %>.<%= file.last_revision.minor_version %> -
- <% end %> - - \ No newline at end of file +User <%= link_to(h(@user), {:only_path => false, :controller => 'users', :action => 'show', :id => @user }) %> +deleted DMSF files in project <%= @project.name %>: +<% @files.each do |file| %> ++ <%= h(file.dmsf_path_str) %> (<%= file.name %>) + <% if file.last_revision %> + , <%= number_to_human_size(file.last_revision.size) %>, version: <%= file.last_revision.major_version %>.<%= file.last_revision.minor_version %> + <% end %> +
+<% end %> diff --git a/app/views/dmsf_mailer/files_deleted.text.erb b/app/views/dmsf_mailer/files_deleted.text.erb index 52905590..fd6fcbb5 100644 --- a/app/views/dmsf_mailer/files_deleted.text.erb +++ b/app/views/dmsf_mailer/files_deleted.text.erb @@ -1,5 +1,7 @@ User <%= @user %> deleted DMSF files in project <%= @project.name %>: <% @files.each do |file| %> - <%= file.dmsf_path_str %> (<%= file.name %>), <%= number_to_human_size(file.last_revision.size) %>, version: <%= file.last_revision.major_version %>.<%= file.last_revision.minor_version %> - + <%= file.dmsf_path_str %> (<%= file.name %>) + <% if file.last_revision %> + , <%= number_to_human_size(file.last_revision.size) %>, version: <%= file.last_revision.major_version %>.<%= file.last_revision.minor_version %> + <% end %> <% end %> \ No newline at end of file diff --git a/app/views/dmsf_mailer/files_deleted.text.html.rhtml b/app/views/dmsf_mailer/files_deleted.text.html.rhtml deleted file mode 100644 index 6c930a4e..00000000 --- a/app/views/dmsf_mailer/files_deleted.text.html.rhtml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - User <%= link_to(h(@user), {:only_path => false, :controller => "users", :action => "show", :id => @user }) %> - deleted DMSF files in project <%= @project.name %>: - <% @files.each do |file| %> -- <%= h(file.dmsf_path_str) %> (<%= file.name %>), - <%= number_to_human_size(file.last_revision.size) %>, - version: <%= file.last_revision.major_version %>.<%= file.last_revision.minor_version %> -
- <% end %> - - \ No newline at end of file diff --git a/app/views/dmsf_mailer/files_deleted.text.plain.rhtml b/app/views/dmsf_mailer/files_deleted.text.plain.rhtml deleted file mode 100644 index 52905590..00000000 --- a/app/views/dmsf_mailer/files_deleted.text.plain.rhtml +++ /dev/null @@ -1,5 +0,0 @@ -User <%= @user %> deleted DMSF files in project <%= @project.name %>: -<% @files.each do |file| %> - <%= file.dmsf_path_str %> (<%= file.name %>), <%= number_to_human_size(file.last_revision.size) %>, version: <%= file.last_revision.major_version %>.<%= file.last_revision.minor_version %> - -<% end %> \ No newline at end of file diff --git a/app/views/dmsf_mailer/files_updated.html.erb b/app/views/dmsf_mailer/files_updated.html.erb index 5c6c2bc0..aa38a991 100644 --- a/app/views/dmsf_mailer/files_updated.html.erb +++ b/app/views/dmsf_mailer/files_updated.html.erb @@ -1,25 +1,18 @@ - - - - - - - User <%= link_to(h(@user), {:only_path => false, :controller => "users", :action => "show", :id => @user }) %> - actualized DMSF files in project <%= @project.name %>: - <% @files.each do |file| %> -
- <%= link_to(h(file.dmsf_path_str),
- {:only_path => false, :controller => "dmsf_files", :action => "show", :id => file,
- :download => ""}) %> (<%= file.name %>),
- <%= number_to_human_size(file.last_revision.size) %>,
- version: <%= file.last_revision.major_version %>.<%= file.last_revision.minor_version %>,
- <%= "#{file.last_revision.workflow_str(true)}," unless file.last_revision.workflow_str(true).blank? %>
- <%= link_to("Details",
- {:only_path => false, :controller => "dmsf_files", :action => "show", :id => file}) %>
- <% unless file.last_revision.comment.blank? %>
-
<%= h(file.last_revision.comment) %>
- <% end %>
-
+ <%= link_to(h(file.dmsf_path_str),
+ {:only_path => false, :controller => "dmsf_files", :action => "show", :id => file,
+ :download => ""}) %> (<%= file.name %>),
+ <%= number_to_human_size(file.last_revision.size) %>,
+ version: <%= file.last_revision.major_version %>.<%= file.last_revision.minor_version %>,
+ <%= "#{file.last_revision.workflow_str(true)}," unless file.last_revision.workflow_str(true).blank? %>
+ <%= link_to("Details",
+ {:only_path => false, :controller => "dmsf_files", :action => "show", :id => file}) %>
+ <% unless file.last_revision.comment.blank? %>
+
<%= h(file.last_revision.comment) %>
+ <% end %>
+
- <%= link_to(h(file.dmsf_path_str),
- {:only_path => false, :controller => "dmsf_files", :action => "show", :id => file,
- :download => ""}) %> (<%= file.name %>),
- <%= number_to_human_size(file.last_revision.size) %>,
- version: <%= file.last_revision.major_version %>.<%= file.last_revision.minor_version %>,
- <%= "#{file.last_revision.workflow_str(true)}," unless file.last_revision.workflow_str(true).blank? %>
- <%= link_to("Details",
- {:only_path => false, :controller => "dmsf_files", :action => "show", :id => file}) %>
- <% unless file.last_revision.comment.blank? %>
-
<%= h(file.last_revision.comment) %>
- <% end %>
-
Dear user,
-- <%= @text1 %> -
-- <%= @text2 %> -
- - \ No newline at end of file +Dear user,
++ <%= @text1 %> +
++ <%= @text2 %> +
+ \ No newline at end of file diff --git a/app/views/dmsf_upload/upload_files.html.erb b/app/views/dmsf_upload/upload_files.html.erb index 38a1532b..4a43f9b1 100644 --- a/app/views/dmsf_upload/upload_files.html.erb +++ b/app/views/dmsf_upload/upload_files.html.erb @@ -3,9 +3,13 @@diff --git a/config/locales/cs.yml b/config/locales/cs.yml index 59b804b9..54465479 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -3,8 +3,7 @@ cs: dmsf: DMSF label_dmsf_file_plural: Dmsf soubory warning_no_entries_selected: Není nic vybráno - error_email_to_must_be_entered: Musí být zadán adresát - notice_email_sent: Email byl odeslán + error_email_to_must_be_entered: Musí být zadán adresát warning_file_already_locked: Soubor už je zamčen notice_file_locked: Soubor byl zamčen warning_file_not_locked: Soubor není zamčen diff --git a/config/locales/de.yml b/config/locales/de.yml index 4b1634b6..b34b979d 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -3,8 +3,7 @@ de: dmsf: DMS label_dmsf_file_plural: DMS warning_no_entries_selected: Keine Einträge ausgewählt - error_email_to_must_be_entered: Es muss ein Email-Empfänger angegeben werden. - notice_email_sent: Email gesendet + error_email_to_must_be_entered: Es muss ein Email-Empfänger angegeben werden. warning_file_already_locked: Datei schon gesperrt notice_file_locked: Datei gesperrt warning_file_not_locked: Datei nicht gesperrt diff --git a/config/locales/en.yml b/config/locales/en.yml index 692733f2..4f38d307 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -3,8 +3,7 @@ en: dmsf: DMSF label_dmsf_file_plural: Dmsf files warning_no_entries_selected: No entries selected - error_email_to_must_be_entered: Email To must be entered - notice_email_sent: Email sent + error_email_to_must_be_entered: Email To must be entered warning_file_already_locked: File already locked notice_file_locked: File locked warning_file_not_locked: File not locked diff --git a/config/locales/es.yml b/config/locales/es.yml index fef545c9..d5c5e7c2 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -3,8 +3,7 @@ es: dmsf: DMSF label_dmsf_file_plural: DMSF Archivos warning_no_entries_selected: No ha seleccionado ningún ítem - error_email_to_must_be_entered: Ingrese un email - notice_email_sent: Email sent + error_email_to_must_be_entered: Ingrese un email warning_file_already_locked: El archivo ya está bloqueado notice_file_locked: Archivo bloqueado warning_file_not_locked: Archivo no bloqueado diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 16f0f84f..7de2f395 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -3,8 +3,7 @@ fr: dmsf: DMSF label_dmsf_file_plural: Fichiers DMSF warning_no_entries_selected: Aucun fichier sélectionné - error_email_to_must_be_entered: La saisie d'une adresse mail est obligatoire - notice_email_sent: Mail envoyé + error_email_to_must_be_entered: La saisie d'une adresse mail est obligatoire warning_file_already_locked: Fichier déjà verrouillé notice_file_locked: Fichier verrouillé warning_file_not_locked: Fichier déverrouillé diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 64447a7c..3c8101ea 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -3,8 +3,7 @@ ja: dmsf: DMSF label_dmsf_file_plural: Dmsf ファイル warning_no_entries_selected: エントリーが選ばれていません - error_email_to_must_be_entered: 電子メールの To 先は省略できません - notice_email_sent: 電子メールを送信しました + error_email_to_must_be_entered: 電子メールの To 先は省略できません warning_file_already_locked: ファイルは既にロックされています notice_file_locked: ファイルをロックしました warning_file_not_locked: ファイルはロックされていません diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 9c4ccc24..4f4d999e 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -3,8 +3,7 @@ ru: dmsf: DMSF label_dmsf_file_plural: Файлы DMSF warning_no_entries_selected: Файлы не выбраны - error_email_to_must_be_entered: Нужно указать, на какую почту отправить письмо - notice_email_sent: Письмо отправлено + error_email_to_must_be_entered: Нужно указать, на какую почту отправить письмо warning_file_already_locked: Файл уже заблокирован notice_file_locked: Файл заблокирован warning_file_not_locked: Файл не заблокирован diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 0034d3c0..e5b45007 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -3,8 +3,7 @@ zh: dmsf: 文档管家 label_dmsf_file_plural: Dmsf files warning_no_entries_selected: 未选择任何条目 - error_email_to_must_be_entered: 请输入电子邮件 - notice_email_sent: 邮件已发送 + error_email_to_must_be_entered: 请输入电子邮件 warning_file_already_locked: 文件已经锁定 notice_file_locked: 文件锁定 warning_file_not_locked: 文件未锁定 diff --git a/db/migrate/20130819013955_update_projects.rb b/db/migrate/20130819013955_update_projects.rb new file mode 100644 index 00000000..c41f2e2d --- /dev/null +++ b/db/migrate/20130819013955_update_projects.rb @@ -0,0 +1,28 @@ +# Redmine plugin for Document Management System "Features" +# +# Copyright (C) 2013 Karel Picman