diff options
author | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-02-27 12:22:29 +0100 |
---|---|---|
committer | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-02-27 12:22:29 +0100 |
commit | 67c1a0a951403a546250ea860a3e3d199cae2fce (patch) | |
tree | f86ec6cedf081a1a57005eca1661e9bead34e4de /app/models/group_permission.rb | |
parent | 5d8ce5f4775ac8bc5f523964e6e36f63ff3c4683 (diff) | |
parent | 211f558a86ae30cdd5b392ab1376e1393f97e22c (diff) |
Merge branch 'develop'5.1-beta6
Diffstat (limited to 'app/models/group_permission.rb')
-rw-r--r-- | app/models/group_permission.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/app/models/group_permission.rb b/app/models/group_permission.rb new file mode 100644 index 0000000..fe988ba --- /dev/null +++ b/app/models/group_permission.rb @@ -0,0 +1,24 @@ +class GroupPermission < ActiveRecord::Base + attr_accessible :group_id, :permission, :target_group_id + + PERMISSION_TYPES = ['pickup'] + + belongs_to :group + belongs_to :target_group, :class_name => "Group" + + validates :target_group_id, + :presence => true, + :uniqueness => { :scope => [:group_id, :permission] } + + validates :target_group, + :presence => true + + validates :permission, + :presence => true, + :uniqueness => { :scope => [:group_id, :target_group_id] }, + :inclusion => { :in => PERMISSION_TYPES } + + def to_s + "#{self.permission} => #{self.target_group}" + end +end |