Add functionality to set default live video URL
All checks were successful
Build and Publish Docker Container / build (push) Successful in 6m21s
All checks were successful
Build and Publish Docker Container / build (push) Successful in 6m21s
A new method has been added to the `CoursesController` which allows admins to fill default live video URLs for online lectures that don't have one. This feature is accessible via a button on the courses admin page. The routing for this new action has also been set up.
This commit is contained in:
parent
c97041597b
commit
f81005408e
@ -1,9 +1,13 @@
|
|||||||
module Admin
|
module Admin
|
||||||
class CoursesController < Admin::ApplicationController
|
class CoursesController < Admin::ApplicationController
|
||||||
def renumber_lectures
|
def renumber_lectures
|
||||||
course = Course.find(params[:id])
|
requested_resource.renumber_lectures!
|
||||||
course.renumber_lectures!
|
redirect_to admin_course_url(requested_resource), notice: "Lectures renumbered"
|
||||||
redirect_to admin_course_url(course), notice: "Lectures renumbered!"
|
end
|
||||||
|
|
||||||
|
def fill_in_default_live_video_url
|
||||||
|
requested_resource.fill_in_default_live_video_url!
|
||||||
|
redirect_to admin_course_url(requested_resource), notice: "Filled in default live video URL"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Overwrite any of the RESTful controller actions to implement custom behavior
|
# Overwrite any of the RESTful controller actions to implement custom behavior
|
||||||
|
|||||||
@ -87,6 +87,6 @@ class Course < ApplicationRecord
|
|||||||
|
|
||||||
def fill_in_default_live_video_url!
|
def fill_in_default_live_video_url!
|
||||||
raise "No default live video URL set" if self.default_live_video_url.nil?
|
raise "No default live video URL set" if self.default_live_video_url.nil?
|
||||||
lectures.where(live_video_url: nil).update_all!(live_video_url: self.default_live_video_url)
|
lectures.where(live_video_url: nil).update_all(live_video_url: self.default_live_video_url)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -3,3 +3,9 @@
|
|||||||
[namespace, page.resource, :renumber_lectures],
|
[namespace, page.resource, :renumber_lectures],
|
||||||
class: "button",
|
class: "button",
|
||||||
) if accessible_action?(page.resource, :renumber_lectures) %>
|
) if accessible_action?(page.resource, :renumber_lectures) %>
|
||||||
|
|
||||||
|
<%= link_to(
|
||||||
|
"Fill in default live video URL",
|
||||||
|
[namespace, page.resource, :fill_in_default_live_video_url],
|
||||||
|
class: "button",
|
||||||
|
) if accessible_action?(page.resource, :fill_in_default_live_video_url) && page.resource.default_live_video_url.present? %>
|
||||||
|
|||||||
@ -9,6 +9,7 @@ Rails.application.routes.draw do
|
|||||||
root to: "courses#index"
|
root to: "courses#index"
|
||||||
|
|
||||||
get '/courses/:id/renumber_lectures', to: 'courses#renumber_lectures', as: :course_renumber_lectures
|
get '/courses/:id/renumber_lectures', to: 'courses#renumber_lectures', as: :course_renumber_lectures
|
||||||
|
get '/courses/:id/fill_in_default_live_video_url', to: 'courses#fill_in_default_live_video_url', as: :course_fill_in_default_live_video_url
|
||||||
end
|
end
|
||||||
|
|
||||||
root controller: :attendance_tracker, action: :index
|
root controller: :attendance_tracker, action: :index
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user