kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.5 KiB
51 lines
1.5 KiB
11 years ago
|
#-- copyright
|
||
11 years ago
|
# OpenProject Meeting Plugin
|
||
|
#
|
||
|
# Copyright (C) 2011-2014 the OpenProject Foundation (OPF)
|
||
11 years ago
|
#
|
||
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License version 3.
|
||
|
#
|
||
11 years ago
|
# 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.
|
||
|
#
|
||
11 years ago
|
# 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.
|
||
|
#
|
||
|
# See doc/COPYRIGHT.md for more details.
|
||
11 years ago
|
#++
|
||
|
|
||
14 years ago
|
class MeetingParticipant < ActiveRecord::Base
|
||
|
belongs_to :meeting
|
||
|
belongs_to :user
|
||
13 years ago
|
|
||
9 years ago
|
scope :invited, -> { where(invited: true) }
|
||
|
scope :attended, -> { where(attended: true) }
|
||
13 years ago
|
|
||
|
User.before_destroy do |user|
|
||
9 years ago
|
MeetingParticipant.where(['user_id = ?', user.id]).update_all ['user_id = ?', DeletedUser.first]
|
||
13 years ago
|
end
|
||
|
|
||
14 years ago
|
def name
|
||
10 years ago
|
user.present? ? user.name : name
|
||
14 years ago
|
end
|
||
13 years ago
|
|
||
14 years ago
|
def mail
|
||
10 years ago
|
user.present? ? user.mail : mail
|
||
14 years ago
|
end
|
||
13 years ago
|
|
||
14 years ago
|
def <=>(participant)
|
||
10 years ago
|
to_s.downcase <=> participant.to_s.downcase
|
||
14 years ago
|
end
|
||
13 years ago
|
|
||
14 years ago
|
alias :to_s :name
|
||
11 years ago
|
|
||
|
def copy_attributes
|
||
10 years ago
|
# create a clean attribute set allowing to attach participants to different meetings
|
||
|
attributes.reject { |k, _v| ['id', 'meeting_id', 'attended', 'created_at', 'updated_at'].include?(k) }
|
||
11 years ago
|
end
|
||
14 years ago
|
end
|