Sha256: 10d26f29e7e50b250acef9c8bc192c01d064a44dd79e59f2ca6f1a1455d84cac

Contents?: true

Size: 1.14 KB

Versions: 58

Compression:

Stored size: 1.14 KB

Contents

# #
# AUTO GENERATED MODEL
# This model was auto generated by the CanvasSync Gem.
# You can customize it as needed, but make sure you test
# any changes you make to the auto generated methods.
#


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

  validates :canvas_id, uniqueness: true, presence: true
  has_many :courses, foreign_key: :canvas_term_id, primary_key: :canvas_id

  api_syncable({
    canvas_id: :id,
    name: :name,
    sis_id: :sis_term_id,
    start_at: :start_at,
    end_at: :end_at,
    workflow_state: :workflow_state,
    grading_period_group_id: :grading_period_group_id,
  }, -> (api) {
    terms = api.terms('self').all_pages!
    term_data = terms.find{|term| term['id'] == canvas_id }
    raise Footrest::HttpError::NotFound unless term_data.present?
    term_data
  })

  # This is a sample scope created by the CanvasSync gem; feel
  # free to customize it for your tool's requirements.
  scope :active, -> {
    where(workflow_state: 'active')
      .where("start_at <= ? OR start_at IS NULL", 15.days.from_now)
      .where("end_at >= ? OR end_at IS NULL", 15.days.ago)
  }

end

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
canvas_sync-0.17.23.beta5 spec/dummy/app/models/term.rb
canvas_sync-0.17.23.beta4 spec/dummy/app/models/term.rb
canvas_sync-0.17.23.beta2 spec/dummy/app/models/term.rb
canvas_sync-0.17.23.beta1 spec/dummy/app/models/term.rb
canvas_sync-0.17.20 spec/dummy/app/models/term.rb
canvas_sync-0.17.19 spec/dummy/app/models/term.rb
canvas_sync-0.17.18 spec/dummy/app/models/term.rb
canvas_sync-0.17.17.beta1 spec/dummy/app/models/term.rb
canvas_sync-0.17.16 spec/dummy/app/models/term.rb
canvas_sync-0.17.15 spec/dummy/app/models/term.rb
canvas_sync-0.17.14 spec/dummy/app/models/term.rb
canvas_sync-0.17.13 spec/dummy/app/models/term.rb
canvas_sync-0.17.12 spec/dummy/app/models/term.rb
canvas_sync-0.17.10.beta2 spec/dummy/app/models/term.rb
canvas_sync-0.17.10.beta1 spec/dummy/app/models/term.rb
canvas_sync-0.17.8 spec/dummy/app/models/term.rb
canvas_sync-0.17.8.beta4 spec/dummy/app/models/term.rb
canvas_sync-0.17.8.beta3 spec/dummy/app/models/term.rb
canvas_sync-0.17.8.beta2 spec/dummy/app/models/term.rb
canvas_sync-0.17.8.beta1 spec/dummy/app/models/term.rb