Email notifications of the root folder

This commit is contained in:
Karel Picman 2013-08-19 15:26:47 +02:00
parent 3964f77cdc
commit 126523c7bd
11 changed files with 140 additions and 123 deletions

View File

@ -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

View File

@ -157,6 +157,7 @@ class DmsfFile < 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

View File

@ -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

View File

@ -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 %>

View File

@ -1,40 +1,56 @@
<% html_title(l(:dmsf)) %>
<div class="contextual">
<% if User.current.allowed_to?(:folder_manipulation, @project) %>
<% if !@folder.nil? && (!@folder.locked_for_user? || User.current.allowed_to?(:force_file_unlock, @project)) %>
<% if @folder.locked? %>
<% unless @folder.unlockable? %>
<%= image_tag("locked.png", :plugin => :redmine_dmsf, :title => l(:title_folder_parent_locked, :name => @folder.folder.lock.reverse[0].folder.title)) unless @folder.nil?%>
<% else %>
<%= link_to_function(image_tag("unlock.png", :plugin => "redmine_dmsf"),
"manipulation_link('#{url_for(:action => 'unlock', :id => @project, :folder_id => @folder, :current => request.url)}')",
:title => l(:title_unlock_folder)) unless @folder.nil?%>
<% end %>
<% else %>
<%= link_to_function(image_tag("lock.png", :plugin => "redmine_dmsf"),
"manipulation_link('#{url_for(:action => 'lock', :id => @project, :folder_id => @folder, :current => request.url)}')",
:title => l(:title_lock_folder)) unless @folder.nil?%>
<% end %>
<% end %>
<% if @folder.nil? %>
&nbsp;
<%= link_to("", {:action => "edit_root", :id => @project},
:title => l(:link_edit, :title => l(:link_documents)), :class => "icon icon-edit") %>
<% elsif (!@folder.nil? && !@folder.locked_for_user? ) %>
&nbsp;
<%= link_to("", {:action => "edit", :id => @project, :folder_id => @folder },
:title => l(:link_edit, :title => h(@folder.title)), :class => "icon icon-edit") %>
<% end %>
&nbsp;
<%= link_to("", {:action => "new", :id => @project, :parent_id => @folder },
:title => l(:link_create_folder), :class => "icon icon-add") unless (!@folder.nil? && @folder.locked_for_user?) %>
<% end %>
<% if User.current.allowed_to?(:folder_manipulation, @project) %>
<% if @folder.nil? %>
&nbsp;
<%= link_to('', {:action => 'edit_root', :id => @project},
:title => l(:link_edit, :title => l(:link_documents)), :class => 'icon icon-edit') %>
<% elsif (@folder && !@folder.locked_for_user? ) %>
&nbsp;
<%= link_to('', {:action => 'edit', :id => @project, :folder_id => @folder },
:title => l(:link_edit, :title => h(@folder.title)), :class => 'icon icon-edit') %>
<% end %>
<% if @folder && (!@folder.locked_for_user? || User.current.allowed_to?(:force_file_unlock, @project)) %>
<% if @folder.locked? %>
<% unless @folder.unlockable? %>
<%= image_tag('locked.png', :plugin => :redmine_dmsf, :title => l(:title_folder_parent_locked, :name => @folder.folder.lock.reverse[0].folder.title)) unless @folder.nil?%>
<% else %>
<%= link_to_function(image_tag('unlock.png', :plugin => 'redmine_dmsf'),
"manipulation_link('#{url_for(:action => 'unlock', :id => @project, :folder_id => @folder, :current => request.url)}')",
:title => l(:title_unlock_folder)) if @folder %>
<% end %>
<% else %>
<%= link_to_function(image_tag('lock.png', :plugin => 'redmine_dmsf'),
"manipulation_link('#{url_for(:action => 'lock', :id => @project, :folder_id => @folder, :current => request.url)}')",
:title => l(:title_lock_folder)) if @folder %>
<% end %>
<% end %>
<% unless @folder %>
&nbsp;
<% if @project.dmsf_notification %>
<%= link_to_function(image_tag('notify.png', :plugin => :redmine_dmsf),
"manipulation_link('#{url_for(:action => 'notify_deactivate', :id => @project)}')",
:title => l(:title_notifications_active_deactivate)) %>
<% else %>
<%= link_to_function(image_tag('notifynot.png', :plugin => :redmine_dmsf),
"manipulation_link('#{url_for(:action => 'notify_activate', :id => @project)}')",
:title => l(:title_notifications_not_active_activate)) %>
<% end %>
<% end %>
&nbsp;
<%= link_to('', {:action => 'new', :id => @project, :parent_id => @folder },
:title => l(:link_create_folder), :class => 'icon icon-add') unless (@folder && @folder.locked_for_user?) %>
<% end %>
</div>
<% path = @folder.nil? ? [] : @folder.dmsf_path %>
<h2>
<%= render(:partial => 'path', :locals => {:path => path}) %>
<h2>
<% path = @folder ? @folder.dmsf_path : [] %>
<%= 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} %>
<% end %>
</h2>
<div class="dmsf-header">

View File

@ -1,25 +1,18 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
</head>
<body>
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| %>
<p>
<%= 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? %>
<br /><span style="font-size: 0.9em">&nbsp;&nbsp;&nbsp;&nbsp;<em><%= h(file.last_revision.comment) %></em></span>
<% end %>
</p>
<% end %>
</body>
</html>
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| %>
<p>
<%= 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? %>
<br /><span style="font-size: 0.9em">&nbsp;&nbsp;&nbsp;&nbsp;<em><%= h(file.last_revision.comment) %></em></span>
<% end %>
</p>
<% end %>

View File

@ -1,25 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
</head>
<body>
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| %>
<p>
<%= 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? %>
<br /><span style="font-size: 0.9em">&nbsp;&nbsp;&nbsp;&nbsp;<em><%= h(file.last_revision.comment) %></em></span>
<% end %>
</p>
<% end %>
</body>
</html>

View File

@ -1,6 +0,0 @@
User <%= @user %> actualized 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.last_revision.workflow_str(true)}" unless file.last_revision.workflow_str(true).blank? %>
<%= url_for({:only_path => false, :controller => "dmsf_files", :action => "show", :id => file}) %>
<% unless file.last_revision.comment.blank? %> comment: <%= file.last_revision.comment %><% end %>
<% end %>

View File

@ -1,15 +1,8 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
</head>
<body>
<p>Dear user,</p>
<p>
<%= @text1 %>
</p>
<p>
<%= @text2 %>
</p>
</body>
</html>
<p>Dear user,</p>
<p>
<%= @text1 %>
</p>
<p>
<%= @text2 %>
</p>

View File

@ -3,9 +3,13 @@
<div class="contextual">
</div>
<% path = @folder.nil? ? [] : @folder.dmsf_path %>
<h2>
<%= render(:partial => '/dmsf/path', :locals => {:path => path}) %>
<h2>
<% path = @folder ? @folder.dmsf_path : [] %>
<%= 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} %>
<% end %>
</h2>
<div class="wiki">

View File

@ -0,0 +1,28 @@
# Redmine plugin for Document Management System "Features"
#
# Copyright (C) 2013 Karel Picman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class UpdateProjects < ActiveRecord::Migration
def self.up
# DMSF - project's root folder notification
add_column :projects, :dmsf_notification, :boolean
end
def self.down
remove_column :porojects, :dmsf_notification
end
end