Sha256: 7407c9bc58c43647d821c8f9edf2b5064c6b36b823f390665255f4553c0d53ed

Contents?: true

Size: 1.29 KB

Versions: 20

Compression:

Stored size: 1.29 KB

Contents

# <%= autogenerated_model_warning %>

class User < ApplicationRecord
  include CanvasSync::Record
  include CanvasSync::Concerns::ApiSyncable

  canvas_sync_features :defaults

  # include CanvasSync::Concerns::LiveEventSync
  # around_process_live_event do |user, blk|
  #   blk.call
  # rescue Footrest::HttpError::Unauthorized => e
  #   # This can happen when a new user is created, but hasn't setup a login on Canvas yet.
  #   Rails.logger.info("Failed to fetch user #{canvas_user_id}: #{e.backtrace}")
  # end

  validates :canvas_id, uniqueness: true, presence: true
  has_many :pseudonyms, primary_key: :canvas_id, foreign_key: :canvas_user_id
  has_many :enrollments, primary_key: :canvas_id, foreign_key: :canvas_user_id
  has_many :admins, primary_key: :canvas_id, foreign_key: :canvas_user_id
  has_many :admin_roles, through: :admins, source: :role
  has_many :submissions, primary_key: :canvas_id, foreign_key: :canvas_user_id
  has_many :group_memberships, primary_key: :canvas_id, foreign_key: :canvas_user_id
  has_many :rubrics, primary_key: :canvas_id, foreign_key: :canvas_user_id

  api_syncable({
    sis_id: :sis_user_id,
    email: :email,
    login_id: :login_id,
    name: :name,
    sortable_name: :sortable_name,
    first_name: :short_name,
  }, -> (api) { api.user_detail(canvas_id) })
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
canvas_sync-0.22.9 lib/canvas_sync/generators/templates/models/user.rb
canvas_sync-0.22.8 lib/canvas_sync/generators/templates/models/user.rb
canvas_sync-0.22.6 lib/canvas_sync/generators/templates/models/user.rb
canvas_sync-0.22.5 lib/canvas_sync/generators/templates/models/user.rb
canvas_sync-0.22.4 lib/canvas_sync/generators/templates/models/user.rb
canvas_sync-0.22.3 lib/canvas_sync/generators/templates/models/user.rb
canvas_sync-0.22.2 lib/canvas_sync/generators/templates/models/user.rb
canvas_sync-0.22.1 lib/canvas_sync/generators/templates/models/user.rb
canvas_sync-0.22.0 lib/canvas_sync/generators/templates/models/user.rb
canvas_sync-0.22.0.beta8 lib/canvas_sync/generators/templates/models/user.rb
canvas_sync-0.22.0.beta7 lib/canvas_sync/generators/templates/models/user.rb
canvas_sync-0.22.0.beta6 lib/canvas_sync/generators/templates/models/user.rb
canvas_sync-0.22.0.beta5 lib/canvas_sync/generators/templates/models/user.rb
canvas_sync-0.22.0.beta4 lib/canvas_sync/generators/templates/models/user.rb
canvas_sync-0.22.0.beta3 lib/canvas_sync/generators/templates/models/user.rb
canvas_sync-0.22.0.beta2 lib/canvas_sync/generators/templates/models/user.rb
canvas_sync-0.22.0.beta1 lib/canvas_sync/generators/templates/models/user.rb
canvas_sync-0.21.1 lib/canvas_sync/generators/templates/models/user.rb
canvas_sync-0.21.1.beta1 lib/canvas_sync/generators/templates/models/user.rb
canvas_sync-0.21.0 lib/canvas_sync/generators/templates/models/user.rb