Notifications Always On (#262)

Commit: 68dd2e4c831b192cebed155877e6100e2691ec6b
defaulted DMSF to always send notifications. This changes the default notification to use the Global notification setting in the DMSF settings as per issue #262.
This commit is contained in:
William Schey 2015-01-20 16:04:31 +10:00
parent e7778698a1
commit ed91504785
4 changed files with 57 additions and 5 deletions

View File

@ -311,7 +311,7 @@ class DmsfController < ApplicationController
if @folder
@folder.notify_deactivate
else
@project.dmsf_notification = false
@project.dmsf_notification = nil
@project.save
end
flash[:notice] = l(:notice_folder_notifications_deactivated)

View File

@ -66,7 +66,17 @@ class DmsfFile < ActiveRecord::Base
:url => Proc.new {|o| {:controller => 'dmsf_files', :action => 'show', :id => o}},
:datetime => Proc.new {|o| o.updated_at },
:author => Proc.new {|o| o.last_revision.user }
before_create :default_values
def default_values
@notifications = Setting.plugin_redmine_dmsf['dmsf_default_notifications']
if @notifications == '1'
self.notification = true
else
self.notification = nil
end
end
@@storage_path = nil
def self.storage_path
@ -176,7 +186,7 @@ class DmsfFile < ActiveRecord::Base
end
def notify_deactivate
self.notification = false
self.notification = nil
self.save!
end

View File

@ -63,7 +63,17 @@ class DmsfFolder < ActiveRecord::Base
:url => Proc.new {|o| {:controller => 'dmsf', :action => 'show', :id => o.project, :folder_id => o}},
:datetime => Proc.new {|o| o.updated_at },
:author => Proc.new {|o| o.user }
before_create :default_values
def default_values
@notifications = Setting.plugin_redmine_dmsf['dmsf_default_notifications']
if @notifications == '1'
self.notification = true
else
self.notification = nil
end
end
def check_cycle
folders = []
self.subfolders.each {|f| folders.push(f)}
@ -138,7 +148,7 @@ class DmsfFolder < ActiveRecord::Base
end
def notify_deactivate
self.notification = false
self.notification = nil
self.save!
end

View File

@ -0,0 +1,32 @@
# Redmine plugin for Document Management System "Features"
#
# Copyright (C) 2014 Karel Pičman <karel.picman@lbcfree.net>
#
# 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 NotificationsNullable < ActiveRecord::Migration
def up
# Switch on the default notifications for new projects and folders
change_column :projects, :dmsf_notification, :boolean, :default => false, :null => true
change_column :dmsf_folders, :notification, :boolean, :default => false, :null => true
change_column :dmsf_files, :notification, :boolean, :default => false, :null => true
end
def down
change_column :projects, :dmsf_notification, :boolean, :default => true, :null => false
change_column :dmsf_folders, :notification, :boolean, :default => true, :null => false
change_column :dmsf_files, :notification, :boolean, :default => true, :null => false
end
end