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