diff options
author | Johan Sørensen <johan@johansorensen.com> | 2009-02-18 14:57:20 +0100 |
---|---|---|
committer | Johan Sørensen <johan@johansorensen.com> | 2009-04-22 15:14:28 +0200 |
commit | 74b4c751c7eddfcb2ee7fca4c79d23aaf953bdd8 (patch) | |
tree | 4e4dca120f83ce3054905e33777feec51a697405 /app/models/committership.rb | |
parent | 4ee4624144fa6545507a27f4fe8c5009e9f3e990 (diff) | |
download | gitorious-mainline-outdated-74b4c751c7eddfcb2ee7fca4c79d23aaf953bdd8.zip gitorious-mainline-outdated-74b4c751c7eddfcb2ee7fca4c79d23aaf953bdd8.tar.gz gitorious-mainline-outdated-74b4c751c7eddfcb2ee7fca4c79d23aaf953bdd8.tar.bz2 |
[migration] Renamed participations to Committerships
Diffstat (limited to 'app/models/committership.rb')
-rw-r--r-- | app/models/committership.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/app/models/committership.rb b/app/models/committership.rb new file mode 100644 index 0000000..1711d32 --- /dev/null +++ b/app/models/committership.rb @@ -0,0 +1,44 @@ +#-- +# Copyright (C) 2009 Johan Sørensen <johan@johansorensen.com> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +#++ + +class Committership < ActiveRecord::Base + belongs_to :committer, :polymorphic => true + belongs_to :repository + belongs_to :creator, :class_name => 'User' + + validates_presence_of :committer_id, :committer_type, :repository_id + + def breadcrumb_parent + Breadcrumb::Committerships.new(repository) + end + + def title + new_record? ? "New commit team" : "Commit team" + end + + # returns all the users in this committership, eg if it's a group it'll + # return an array of the group members, otherwise a single-member array of + # the user + def members + case committer + when Group + committer.members + else + [committer] + end + end +end |