From d8a6f27734c014da8e492107e24d85b725fd56fe Mon Sep 17 00:00:00 2001 From: Joshua Coles Date: Sun, 1 Oct 2023 20:00:23 +0100 Subject: [PATCH] Customise dashboards --- app/dashboards/course_dashboard.rb | 25 +++++++++++++------------ app/dashboards/lecture_dashboard.rb | 12 ++++++------ app/models/course.rb | 4 ++++ 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/app/dashboards/course_dashboard.rb b/app/dashboards/course_dashboard.rb index b812a63..1396d39 100644 --- a/app/dashboards/course_dashboard.rb +++ b/app/dashboards/course_dashboard.rb @@ -10,6 +10,7 @@ class CourseDashboard < Administrate::BaseDashboard ATTRIBUTE_TYPES = { id: Field::Number, lectures: Field::HasMany, + recordings: Field::HasMany, panopto_folders: Field::String.with_options(searchable: false), semester_start_date: Field::Date, title: Field::String, @@ -25,22 +26,23 @@ class CourseDashboard < Administrate::BaseDashboard # By default, it's limited to four items to reduce clutter on index pages. # Feel free to add, remove, or rearrange items. COLLECTION_ATTRIBUTES = %i[ - id + title + unit_code lectures - panopto_folders - semester_start_date + recordings ].freeze # SHOW_PAGE_ATTRIBUTES # an array of attributes that will be displayed on the model's show page. SHOW_PAGE_ATTRIBUTES = %i[ id - lectures + title + unit_code panopto_folders semester_start_date - title toggl_project - unit_code + lectures + recordings created_at updated_at ].freeze @@ -49,12 +51,11 @@ class CourseDashboard < Administrate::BaseDashboard # an array of attributes that will be displayed # on the model's form (`new` and `edit`) pages. FORM_ATTRIBUTES = %i[ - lectures + title + unit_code panopto_folders semester_start_date - title toggl_project - unit_code ].freeze # COLLECTION_FILTERS @@ -72,7 +73,7 @@ class CourseDashboard < Administrate::BaseDashboard # Overwrite this method to customize how courses are displayed # across all pages of the admin dashboard. # - # def display_resource(course) - # "Course ##{course.id}" - # end + def display_resource(course) + course.title + end end diff --git a/app/dashboards/lecture_dashboard.rb b/app/dashboards/lecture_dashboard.rb index cda6db2..6e438a3 100644 --- a/app/dashboards/lecture_dashboard.rb +++ b/app/dashboards/lecture_dashboard.rb @@ -25,10 +25,10 @@ class LectureDashboard < Administrate::BaseDashboard # By default, it's limited to four items to reduce clutter on index pages. # Feel free to add, remove, or rearrange items. COLLECTION_ATTRIBUTES = %i[ - id - attendance + title course - event_uuid + start_time + recording ].freeze # SHOW_PAGE_ATTRIBUTES @@ -72,7 +72,7 @@ class LectureDashboard < Administrate::BaseDashboard # Overwrite this method to customize how lectures are displayed # across all pages of the admin dashboard. # - # def display_resource(lecture) - # "Lecture ##{lecture.id}" - # end + def display_resource(lecture) + lecture.title + end end diff --git a/app/models/course.rb b/app/models/course.rb index 53f605b..9caa9c9 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -1,3 +1,7 @@ class Course < ApplicationRecord has_many :lectures + + # A course has a standalone connection to its recordings. To be shown they must be associated with a lecture but we + # track those not associated with a lecture to avoid duplication. + has_many :recordings end