Admin namespace beendet.
This commit is contained in:
parent
6ddef7267a
commit
172db1d37e
23 changed files with 78 additions and 193 deletions
|
|
@ -12,6 +12,7 @@ class Ordergroup < Group
|
|||
has_many :orders, :through => :group_orders
|
||||
|
||||
validates_numericality_of :account_balance, :message => 'ist keine gültige Zahl'
|
||||
validate :uniqueness_of_members
|
||||
|
||||
after_create :update_stats!
|
||||
|
||||
|
|
@ -78,6 +79,13 @@ class Ordergroup < Group
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Make sure, that a user can only be in one ordergroup
|
||||
def uniqueness_of_members
|
||||
users.each do |user|
|
||||
errors.add :user_tokens, "#{user.nick} ist schon in einer anderen Bestellgruppe" if user.groups.where(:type => 'Ordergroup').size > 1
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue