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.9.0 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.8.2 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.8.1 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.8.0 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.7.2 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.7.1 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.7.0 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.6.0 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.5.1 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.5.0 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.4.1 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.4.0 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.3.1 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.3.0 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.2.0 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.1.3 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.1.2 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.1.1 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.1.0 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.0.6 app/controllers/concerns/with_user_discussion_validation.rb