Add archived to dashboard and change homepage to only show active (ie not archived) courses
This commit is contained in:
parent
04566509dc
commit
4485624f79
@ -1,16 +1,16 @@
|
|||||||
class AttendanceTrackerController < ApplicationController
|
class AttendanceTrackerController < ApplicationController
|
||||||
def index
|
def index
|
||||||
@courses = Course.all.sort_by(&:title)
|
@courses = Course.active.sort_by(&:title)
|
||||||
@current_lecture = get_current_lecture
|
@current_lecture = get_current_lecture
|
||||||
end
|
end
|
||||||
|
|
||||||
def overview
|
def overview
|
||||||
@courses = Course.all.sort_by(&:title)
|
@courses = Course.active.sort_by(&:title)
|
||||||
@current_lecture = get_current_lecture
|
@current_lecture = get_current_lecture
|
||||||
end
|
end
|
||||||
|
|
||||||
def today
|
def today
|
||||||
@courses = Course.all.sort_by(&:title)
|
@courses = Course.active.sort_by(&:title)
|
||||||
@date = Date.today
|
@date = Date.today
|
||||||
@current_lecture = get_current_lecture
|
@current_lecture = get_current_lecture
|
||||||
@lectures = @courses.flat_map { |course| course.lectures.filter { |a| a.start_time.today? } }.sort_by { |l| l.start_time }
|
@lectures = @courses.flat_map { |course| course.lectures.filter { |a| a.start_time.today? } }.sort_by { |l| l.start_time }
|
||||||
|
|||||||
@ -15,6 +15,7 @@ class CourseDashboard < Administrate::BaseDashboard
|
|||||||
panopto_folders: Field::String.with_options(searchable: false),
|
panopto_folders: Field::String.with_options(searchable: false),
|
||||||
semester_start_date: Field::Date,
|
semester_start_date: Field::Date,
|
||||||
title: Field::String,
|
title: Field::String,
|
||||||
|
archived: Field::Boolean,
|
||||||
homepage: Field::String,
|
homepage: Field::String,
|
||||||
toggl_project: Field::Number,
|
toggl_project: Field::Number,
|
||||||
unit_code: Field::String,
|
unit_code: Field::String,
|
||||||
@ -30,6 +31,7 @@ class CourseDashboard < Administrate::BaseDashboard
|
|||||||
COLLECTION_ATTRIBUTES = %i[
|
COLLECTION_ATTRIBUTES = %i[
|
||||||
title
|
title
|
||||||
unit_code
|
unit_code
|
||||||
|
archived
|
||||||
homepage
|
homepage
|
||||||
lectures
|
lectures
|
||||||
work_items
|
work_items
|
||||||
@ -42,6 +44,7 @@ class CourseDashboard < Administrate::BaseDashboard
|
|||||||
id
|
id
|
||||||
title
|
title
|
||||||
unit_code
|
unit_code
|
||||||
|
archived
|
||||||
homepage
|
homepage
|
||||||
panopto_folders
|
panopto_folders
|
||||||
semester_start_date
|
semester_start_date
|
||||||
@ -59,6 +62,7 @@ class CourseDashboard < Administrate::BaseDashboard
|
|||||||
FORM_ATTRIBUTES = %i[
|
FORM_ATTRIBUTES = %i[
|
||||||
title
|
title
|
||||||
unit_code
|
unit_code
|
||||||
|
archived
|
||||||
homepage
|
homepage
|
||||||
panopto_folders
|
panopto_folders
|
||||||
semester_start_date
|
semester_start_date
|
||||||
@ -75,7 +79,10 @@ class CourseDashboard < Administrate::BaseDashboard
|
|||||||
# COLLECTION_FILTERS = {
|
# COLLECTION_FILTERS = {
|
||||||
# open: ->(resources) { resources.where(open: true) }
|
# open: ->(resources) { resources.where(open: true) }
|
||||||
# }.freeze
|
# }.freeze
|
||||||
COLLECTION_FILTERS = {}.freeze
|
COLLECTION_FILTERS = {
|
||||||
|
archived: ->(resources) { resources.where(archived: true) },
|
||||||
|
active: ->(resources) { resources.where(archived: false) }
|
||||||
|
}.freeze
|
||||||
|
|
||||||
# Overwrite this method to customize how courses are displayed
|
# Overwrite this method to customize how courses are displayed
|
||||||
# across all pages of the admin dashboard.
|
# across all pages of the admin dashboard.
|
||||||
|
|||||||
@ -6,6 +6,8 @@ class Course < ApplicationRecord
|
|||||||
# we them independently to avoid re-importing lectures.
|
# we them independently to avoid re-importing lectures.
|
||||||
has_many :recordings, dependent: :destroy
|
has_many :recordings, dependent: :destroy
|
||||||
|
|
||||||
|
scope :active, -> { where(archived: false) }
|
||||||
|
|
||||||
def lectures_and_work_items
|
def lectures_and_work_items
|
||||||
(lectures + work_items).sort_by(&:start_time)
|
(lectures + work_items).sort_by(&:start_time)
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user