Sha256: 26fe56c4a7b1fcc6389b03c0b2a03f9907243d60e0ab6677ea58dbb3b08c2ea0

Contents?: true

Size: 576 Bytes

Versions: 55

Compression:

Stored size: 576 Bytes

Contents

module WithUserDiscussionValidation
  extend ActiveSupport::Concern

  included do
    # users are not allowed to access discussions during exams
    before_action :validate_not_blocked_in_forum!
    # discussions are not enabled for all organizations nor all users
    before_action :validate_user_can_discuss!
  end

  private

  def validate_not_blocked_in_forum!
    raise Mumuki::Domain::BlockedForumError if current_user&.currently_in_exam?
  end

  def validate_user_can_discuss!
    raise Mumuki::Domain::NotFoundError unless current_user&.can_discuss_here?
  end
end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
mumuki-laboratory-9.0.5 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.0.4 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.0.3 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.0.2 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.0.1 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.0.0 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-8.6.1 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-8.6.0 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-8.5.0 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-8.4.0 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-8.3.0 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-8.2.1 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-8.2.0 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-8.1.3 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-8.1.2 app/controllers/concerns/with_user_discussion_validation.rb