Commit 745a0b07 authored by Gualter's avatar Gualter

Remove subcategories and conference_match from user model (#213)

parent d948ff2a
class ConferenceUserSubcategory < ActiveRecord::Base
belongs_to :conference_user
belongs_to :subcategory
validates :subcategory_id, uniqueness: { scope: :conference_user_id, message: 'A subcategory cannot be assigned more than once!' }
validate :conferences_match
validate :is_reviewer
validate :not_more_than_four
private
def conferences_match
unless conference_user.conference == subcategory.conference
errors.add(:base, 'The assigned subcategory needs to be in the same conference as the user is reviewer in!')
end
end
def is_reviewer
unless conference_user.role == 'reviewer'
errors.add(:base, 'The user needs to have the role of \'reviewer\' to have a subcategory assigned to him/her!')
......@@ -27,4 +19,4 @@ class ConferenceUserSubcategory < ActiveRecord::Base
errors.add(:base, 'There can be at most 4 subcategories per conference added to a user')
end
end
end
\ No newline at end of file
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment