annotate .svn/pristine/2a/2ad19a5d216db9900f8c479e9b99d1592793dd37.svn-base @ 1296:038ba2d95de8 redmine-2.2

Fix redmine-2.2 branch update (add missing svn files)
author Chris Cannam
date Fri, 14 Jun 2013 09:05:06 +0100
parents
children
rev   line source
Chris@1296 1 # Redmine - project management software
Chris@1296 2 # Copyright (C) 2006-2012 Jean-Philippe Lang
Chris@1296 3 #
Chris@1296 4 # This program is free software; you can redistribute it and/or
Chris@1296 5 # modify it under the terms of the GNU General Public License
Chris@1296 6 # as published by the Free Software Foundation; either version 2
Chris@1296 7 # of the License, or (at your option) any later version.
Chris@1296 8 #
Chris@1296 9 # This program is distributed in the hope that it will be useful,
Chris@1296 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@1296 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@1296 12 # GNU General Public License for more details.
Chris@1296 13 #
Chris@1296 14 # You should have received a copy of the GNU General Public License
Chris@1296 15 # along with this program; if not, write to the Free Software
Chris@1296 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@1296 17
Chris@1296 18 module Redmine
Chris@1296 19 module Acts
Chris@1296 20 module Event
Chris@1296 21 def self.included(base)
Chris@1296 22 base.extend ClassMethods
Chris@1296 23 end
Chris@1296 24
Chris@1296 25 module ClassMethods
Chris@1296 26 def acts_as_event(options = {})
Chris@1296 27 return if self.included_modules.include?(Redmine::Acts::Event::InstanceMethods)
Chris@1296 28 default_options = { :datetime => :created_on,
Chris@1296 29 :title => :title,
Chris@1296 30 :description => :description,
Chris@1296 31 :author => :author,
Chris@1296 32 :url => {:controller => 'welcome'},
Chris@1296 33 :type => self.name.underscore.dasherize }
Chris@1296 34
Chris@1296 35 cattr_accessor :event_options
Chris@1296 36 self.event_options = default_options.merge(options)
Chris@1296 37 send :include, Redmine::Acts::Event::InstanceMethods
Chris@1296 38 end
Chris@1296 39 end
Chris@1296 40
Chris@1296 41 module InstanceMethods
Chris@1296 42 def self.included(base)
Chris@1296 43 base.extend ClassMethods
Chris@1296 44 end
Chris@1296 45
Chris@1296 46 %w(datetime title description author type).each do |attr|
Chris@1296 47 src = <<-END_SRC
Chris@1296 48 def event_#{attr}
Chris@1296 49 option = event_options[:#{attr}]
Chris@1296 50 if option.is_a?(Proc)
Chris@1296 51 option.call(self)
Chris@1296 52 elsif option.is_a?(Symbol)
Chris@1296 53 send(option)
Chris@1296 54 else
Chris@1296 55 option
Chris@1296 56 end
Chris@1296 57 end
Chris@1296 58 END_SRC
Chris@1296 59 class_eval src, __FILE__, __LINE__
Chris@1296 60 end
Chris@1296 61
Chris@1296 62 def event_date
Chris@1296 63 event_datetime.to_date
Chris@1296 64 end
Chris@1296 65
Chris@1296 66 def event_url(options = {})
Chris@1296 67 option = event_options[:url]
Chris@1296 68 if option.is_a?(Proc)
Chris@1296 69 option.call(self).merge(options)
Chris@1296 70 elsif option.is_a?(Hash)
Chris@1296 71 option.merge(options)
Chris@1296 72 elsif option.is_a?(Symbol)
Chris@1296 73 send(option).merge(options)
Chris@1296 74 else
Chris@1296 75 option
Chris@1296 76 end
Chris@1296 77 end
Chris@1296 78
Chris@1296 79 # Returns the mail adresses of users that should be notified
Chris@1296 80 def recipients
Chris@1296 81 notified = project.notified_users
Chris@1296 82 notified.reject! {|user| !visible?(user)}
Chris@1296 83 notified.collect(&:mail)
Chris@1296 84 end
Chris@1296 85
Chris@1296 86 module ClassMethods
Chris@1296 87 end
Chris@1296 88 end
Chris@1296 89 end
Chris@1296 90 end
Chris@1296 91 end