mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Refactored proposal. Enabled cancancan
This commit is contained in:
parent
0ae7991943
commit
c982cbb88a
13 changed files with 204 additions and 231 deletions
|
|
@ -31,10 +31,11 @@ class Event < ActiveRecord::Base
|
|||
|
||||
validate :abstract_limit
|
||||
validate :before_end_of_conference
|
||||
validate :biography_exists
|
||||
validate :name_and_biography_exists
|
||||
validates :title, presence: true
|
||||
validates :abstract, presence: true
|
||||
validates :event_type, presence: true
|
||||
validates :conference, presence: true
|
||||
validates :media_type, inclusion: { in: Conference.media_types.values }, allow_blank: true
|
||||
|
||||
scope :confirmed, -> { where(state: 'confirmed') }
|
||||
|
|
@ -218,8 +219,9 @@ class Event < ActiveRecord::Base
|
|||
errors.add(:abstract, "cannot have more than #{max_words} words") if len > max_words
|
||||
end
|
||||
|
||||
def biography_exists
|
||||
errors.add(:user_biography, 'must be filled out') if submitter.biography_word_count == 0
|
||||
def name_and_biography_exists
|
||||
errors.add(:biography, "cant' be blank") if submitter.biography.blank?
|
||||
errors.add(:username, " can't be blank") if submitter.name.blank?
|
||||
end
|
||||
|
||||
# TODO: create a module to be mixed into model to perform same operation
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue