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.23.0 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.22.0 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.21.0 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.20.1 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.20.0 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.19.0 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.18.1 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.18.0 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.17.0 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.16.0 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.15.0 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.14.1 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.14.0 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.13.2 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.13.1 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.13.0 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.12.1 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.12.0 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.11.0 app/controllers/concerns/with_user_discussion_validation.rb
mumuki-laboratory-9.10.0 app/controllers/concerns/with_user_discussion_validation.rb