Add lecture kinds
This commit is contained in:
parent
9a5116f29e
commit
fe15365524
@ -10,12 +10,13 @@ class LectureDashboard < Administrate::BaseDashboard
|
||||
ATTRIBUTE_TYPES = {
|
||||
id: Field::Number,
|
||||
attendance: Field::HasOne,
|
||||
course: Field::BelongsTo,
|
||||
event_uuid: Field::String,
|
||||
course: Field::BelongsTo.with_options(searchable: true, searchable_field: 'title'),
|
||||
event_uuid: Field::String.with_options(searchable: false),
|
||||
recording: Field::HasOne,
|
||||
start_time: Field::DateTime,
|
||||
title: Field::String,
|
||||
cancelled: Field::Boolean,
|
||||
kind: Field::Select.with_options(searchable: false, collection: ->(field) { field.resource.class.send(field.attribute.to_s.pluralize).keys }),
|
||||
created_at: Field::DateTime,
|
||||
updated_at: Field::DateTime,
|
||||
}.freeze
|
||||
@ -37,6 +38,8 @@ class LectureDashboard < Administrate::BaseDashboard
|
||||
# an array of attributes that will be displayed on the model's show page.
|
||||
SHOW_PAGE_ATTRIBUTES = %i[
|
||||
id
|
||||
title
|
||||
kind
|
||||
attendance
|
||||
course
|
||||
cancelled
|
||||
@ -53,6 +56,7 @@ class LectureDashboard < Administrate::BaseDashboard
|
||||
# on the model's form (`new` and `edit`) pages.
|
||||
FORM_ATTRIBUTES = %i[
|
||||
attendance
|
||||
kind
|
||||
course
|
||||
cancelled
|
||||
event_uuid
|
||||
|
||||
@ -3,6 +3,11 @@ class Lecture < ApplicationRecord
|
||||
has_one :attendance
|
||||
has_one :recording
|
||||
|
||||
enum :kind, [
|
||||
:lecture,
|
||||
:problem_class,
|
||||
], default: :lecture
|
||||
|
||||
def week_number
|
||||
((start_time.beginning_of_week - course.semester_start_date.to_time) / 1.week).floor + 1
|
||||
end
|
||||
|
||||
5
db/migrate/20231002152546_add_lecture_kind.rb
Normal file
5
db/migrate/20231002152546_add_lecture_kind.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddLectureKind < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
add_column :lectures, :kind, :integer, default: 0
|
||||
end
|
||||
end
|
||||
3
db/schema.rb
generated
3
db/schema.rb
generated
@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.0].define(version: 2023_10_02_150348) do
|
||||
ActiveRecord::Schema[7.0].define(version: 2023_10_02_152546) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
@ -42,6 +42,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_10_02_150348) do
|
||||
t.bigint "course_id"
|
||||
t.string "event_uuid"
|
||||
t.boolean "cancelled", default: false
|
||||
t.integer "kind", default: 0
|
||||
t.index ["course_id"], name: "index_lectures_on_course_id"
|
||||
end
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user