diff --git a/Gemfile b/Gemfile index 5ea418d..2e375fa 100644 --- a/Gemfile +++ b/Gemfile @@ -73,3 +73,4 @@ end gem "tailwindcss-rails", "~> 2.0" gem "font-awesome-sass" +gem "httparty" diff --git a/Gemfile.lock b/Gemfile.lock index 59a2e27..ceae68b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -93,6 +93,9 @@ GEM sassc (~> 2.0) globalid (1.2.1) activesupport (>= 6.1) + httparty (0.21.0) + mini_mime (>= 1.0.0) + multi_xml (>= 0.5.2) i18n (1.14.1) concurrent-ruby (~> 1.0) importmap-rails (1.2.1) @@ -119,6 +122,7 @@ GEM mini_mime (1.1.5) minitest (5.20.0) msgpack (1.7.2) + multi_xml (0.6.0) net-imap (0.3.7) date net-protocol @@ -229,6 +233,7 @@ DEPENDENCIES capybara debug font-awesome-sass + httparty importmap-rails jbuilder pg (~> 1.1) diff --git a/app/lib/Panopto.rb b/app/lib/Panopto.rb new file mode 100644 index 0000000..955e2c6 --- /dev/null +++ b/app/lib/Panopto.rb @@ -0,0 +1,8 @@ +module Panopto + # @param [String] folder_id + def self.list_folder(folder_id) + HTTParty.get("https://lectures.joshuacoles.me/list", query: { + folderId: folder_id + }) + end +end diff --git a/app/models/lecture.rb b/app/models/lecture.rb index 3b8a22e..0f30e48 100644 --- a/app/models/lecture.rb +++ b/app/models/lecture.rb @@ -18,6 +18,8 @@ class Lecture < ApplicationRecord end def recording_url - "https://google.com" + return nil if recording_id.nil? + + "https://uniofbath.cloud.panopto.eu/Panopto/Pages/Viewer.aspx?id=#{recording_id}" end end diff --git a/db/migrate/20230929181725_make_lecture_recording_id_unique.rb b/db/migrate/20230929181725_make_lecture_recording_id_unique.rb new file mode 100644 index 0000000..45f4d8d --- /dev/null +++ b/db/migrate/20230929181725_make_lecture_recording_id_unique.rb @@ -0,0 +1,5 @@ +class MakeLectureRecordingIdUnique < ActiveRecord::Migration[7.0] + def change + add_index :lectures, :recording_id, unique: true + end +end diff --git a/db/schema.rb b/db/schema.rb index 2ef1f50..d8955e7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_09_29_171856) do +ActiveRecord::Schema[7.0].define(version: 2023_09_29_181725) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -32,6 +32,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_09_29_171856) do t.datetime "updated_at", null: false t.bigint "course_id" t.index ["course_id"], name: "index_lectures_on_course_id" + t.index ["recording_id"], name: "index_lectures_on_recording_id", unique: true end end