Add better capacity for live lectures

This commit is contained in:
Joshua Coles 2023-10-08 16:24:31 +01:00
parent 9da49ceed8
commit 18f2399c0e
3 changed files with 15 additions and 1 deletions

View File

@ -19,6 +19,10 @@ class LectureController < ApplicationController
project_id: lecture.course.toggl_project,
)
if lecture.is_live?
redirect_to lecture.live_video_url, allow_other_host: true
end
if lecture.recording.present?
redirect_to lecture.recording.recording_url, allow_other_host: true
end

View File

@ -38,4 +38,13 @@ class Lecture < ApplicationRecord
def live_video_url
nil
end
# NAIVE: Assumes that lectures are 50 minutes long, this is true currently but not assured.
def end_time
start_time + 50.hour
end
def is_live?
live_video_url.present? && start_time.past? && end_time.future?
end
end

View File

@ -60,7 +60,8 @@
class: 'action-button'
%>
<% elsif lecture.start_time.past? && !lecture.attended? %>
<%= button_to "Start",
<% start_label = if lecture.is_live? then "Join" else "Start" end %>
<%= button_to start_label,
lectures_start_path(id: lecture.id),
class: 'action-button'
%>