diff --git a/app/controllers/assignments_controller.rb b/app/controllers/assignments_controller.rb index 49111fafe22f2f8a7852333bfc50df8ddeaea461..8e5c5e67c80af4ec4870af87ca02f9dcea2405bd 100644 --- a/app/controllers/assignments_controller.rb +++ b/app/controllers/assignments_controller.rb @@ -86,11 +86,12 @@ class AssignmentsController < ApplicationController @user.assignments.each do |assignment| session = assignment.session assignees = session.assignments.map { |a| a.user.name } - desc = [ + desc [ "Assignees: #{assignees.join(', ')}", "Speakers: #{session.speakers.map(&:name).join(', ')}", session.description ] + desc.unshift("Filedrop has data for this session!<br>\n" + conference_session_url(session.conference, session)) if session.filedrop? event = Icalendar::Event.new event.dtstart = Icalendar::Values::DateTime.new(session.starts_at, tzid: session.starts_at.time_zone.tzinfo.name) diff --git a/app/controllers/filedrop_files_controller.rb b/app/controllers/filedrop_files_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..1487eaf31120fda9a179da38a01640a51f0ef084 --- /dev/null +++ b/app/controllers/filedrop_files_controller.rb @@ -0,0 +1,22 @@ +class FiledropFilesController < ApplicationController + before_action :authenticate_user! + before_action :set_filedrop_file, only: [:download] + + def download + # Define the file path within the storage directory + file_path = @filedrop_file.local_path + + # Send the file to the user + if File.exist?(file_path) + send_file file_path, filename: @filedrop_file.name, disposition: 'attachment' + else + render plain: 'File not found', status: :not_found + end + end + + private + + def set_filedrop_file + @filedrop_file = FiledropFile.find(params[:id]) + end +end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 5c13c868c9895be2fa78d05dd5461ba9237ee4c3..99a6a637889170940e11859080bdb4415ae5fb4c 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,4 +1,5 @@ class SessionsController < ApplicationController + before_action :authenticate_user!, except: [:index] before_action :authorize_shiftcoordinator, except: [:index, :show] def index @@ -21,7 +22,7 @@ class SessionsController < ApplicationController def show @conference = Conference.find_by(slug: params[:conference_slug]) - @session = Session.includes(:stage).find_by(conference: @conference, ref_id: params[:ref_id]) + @session = Session.includes(:stage, :filedrop_comments, :filedrop_files).find_by(conference: @conference, ref_id: params[:ref_id]) @users = User.all end diff --git a/app/models/session.rb b/app/models/session.rb index 86ca06a1537296757777eb0ec0271fb27623b694..c53117272523c053cc16b7e0fbe2b21612f3992e 100644 --- a/app/models/session.rb +++ b/app/models/session.rb @@ -50,6 +50,10 @@ class Session < ApplicationRecord assignments.length.positive? end + def filedrop? + return filedrop_files.exists? || filedrop_comments.exists? + end + private def notify_if_changed diff --git a/app/views/filedrop_files/download.html.erb b/app/views/filedrop_files/download.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..60788e4b97e71b53eed212342259dba7d003dc0c --- /dev/null +++ b/app/views/filedrop_files/download.html.erb @@ -0,0 +1,4 @@ +<div> + <h1 class="font-bold text-4xl">FiledropFiles#download</h1> + <p>Find me in app/views/filedrop_files/download.html.erb</p> +</div> diff --git a/app/views/sessions/_session.html.erb b/app/views/sessions/_session.html.erb index 4d01986f5600b19d992fd2db9b8d85b9f78b9877..e58deef374a25736ecd7d20b05fe7f5c9e1490d4 100644 --- a/app/views/sessions/_session.html.erb +++ b/app/views/sessions/_session.html.erb @@ -2,7 +2,7 @@ <%= turbo_frame_tag dom_id(session), method: "morph", class: "w-full", data: { controller: "session", language: session.language } do %> <div class="session shadow hover:shadow-lg overflow-scroll text-sm w-full !h-full min-h-full hover:!min-h-max <%= session.translators_needed? ? "translators-needed" : "no-translators-needed" %> <%= session.backup_needed? ? "backup-needed" : "no-backup-needed" %> <%= session.assignees? ? "has-assignees" : "no-assignees" %> <%= (session.ends_at < Time.now ? "past" : "") %>"> <h4> - <small class="text-2xs uppercase font-light bg-black/10 rounded-sm p-1 mr-1 lang-<%= session.language %>"><%= session.language %></small><% unless session.recorded %><span aria-label="Session is not recorded" title="Session is not recorded"><svg class="inline-block -mt-0.5 w-5 h-5" fill="#000000" version="1.1" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"><path d="m255-1c-141 0-256 115-256 256s115 256 256 256 256-115 256-256-115-256-256-256zm0 17c63 0 121 25 163 65l-65 65-19-48c-0.85-2.6-4.3-5.1-7.7-5.1h-142c-3.4 0-6 1.7-7.7 5.1l-21 55h-49c-17 0-31 14-31 31v169c0 17 14 31 31 31h6.7l-34 34c-39-43-64-100-64-162 0-131 108-239 239-239zm60 239c0 33-26 60-60 60-14 0-26-4.4-36-12l84-83c7.3 9.9 12 22 12 36zm-119 0c0-33 26-60 60-60 14 0 26 4.5 36 12l-84 83c-7.4-9.9-12-22-12-36zm108-60c-13-11-30-17-48-17-43 0-77 34-77 77 0 18 6.2 35 17 48l-64 63h-25c-7.7 0-14-6-14-14v-169c0-7.7 6-14 14-14h55c3.4 0 6.8-2.6 7.7-5.1l21-55h130l19 50-36 36zm-97 120c13 11 30 17 48 17 43 0 77-34 77-77 0-18-6.1-35-16-48l38-38h49c7.7 0 14 6 14 14v169c0 7.7-6 14-14 14h-247l51-51zm48 179c-63 0-120-25-163-65l46-46h265c17 0 31-14 32-31v-169c0-17-14-31-31-31h-34l60-59c39 43 64 100 64 162-1e-3 131-108 239-239 239z"/><path d="m383 187c-9.4 0-17 7.7-17 17s7.7 17 17 17 17-7.7 17-17-7.7-17-17-17z"/></svg></span><% end %> + <small class="text-2xs uppercase font-light bg-black/10 rounded-sm p-1 mr-1 lang-<%= session.language %>"><%= session.language %></small><% unless session.recorded %><span aria-label="Session is not recorded" title="Session is not recorded"><svg class="inline-block -mt-0.5 w-5 h-5" fill="#000000" version="1.1" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"><path d="m255-1c-141 0-256 115-256 256s115 256 256 256 256-115 256-256-115-256-256-256zm0 17c63 0 121 25 163 65l-65 65-19-48c-0.85-2.6-4.3-5.1-7.7-5.1h-142c-3.4 0-6 1.7-7.7 5.1l-21 55h-49c-17 0-31 14-31 31v169c0 17 14 31 31 31h6.7l-34 34c-39-43-64-100-64-162 0-131 108-239 239-239zm60 239c0 33-26 60-60 60-14 0-26-4.4-36-12l84-83c7.3 9.9 12 22 12 36zm-119 0c0-33 26-60 60-60 14 0 26 4.5 36 12l-84 83c-7.4-9.9-12-22-12-36zm108-60c-13-11-30-17-48-17-43 0-77 34-77 77 0 18 6.2 35 17 48l-64 63h-25c-7.7 0-14-6-14-14v-169c0-7.7 6-14 14-14h55c3.4 0 6.8-2.6 7.7-5.1l21-55h130l19 50-36 36zm-97 120c13 11 30 17 48 17 43 0 77-34 77-77 0-18-6.1-35-16-48l38-38h49c7.7 0 14 6 14 14v169c0 7.7-6 14-14 14h-247l51-51zm48 179c-63 0-120-25-163-65l46-46h265c17 0 31-14 32-31v-169c0-17-14-31-31-31h-34l60-59c39 43 64 100 64 162-1e-3 131-108 239-239 239z"/><path d="m383 187c-9.4 0-17 7.7-17 17s7.7 17 17 17 17-7.7 17-17-7.7-17-17-17z"/></svg></span><% end %><% if session.filedrop? %><%= link_to conference_session_path(session.conference, session), data: { turbo: false } do %><span aria-label="Filedrop has data for this session" title="Filedrop has data for this session"><svg class="inline-block -mt-0.5 w-5 h-5" fill="#EA33F7" xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="m720-120 160-160-56-56-64 64v-167h-80v167l-64-64-56 56 160 160ZM560 0v-80h320V0H560ZM240-160q-33 0-56.5-23.5T160-240v-560q0-33 23.5-56.5T240-880h280l240 240v121h-80v-81H480v-200H240v560h240v80H240Zm0-80v-560 560Z"/></svg></span><% end %><% end %> <%= link_to session.title, session.url, target: "_blank" %> </h4> <div class="relative"> diff --git a/app/views/sessions/show.html.erb b/app/views/sessions/show.html.erb index 62fa3cd64aad8b9391c9cdae8a907c544c66fdd6..6b9144d9051e0eb5e030792fadf6e75c8075afc2 100644 --- a/app/views/sessions/show.html.erb +++ b/app/views/sessions/show.html.erb @@ -6,7 +6,39 @@ <h2><%= @session.stage.name %>· <%= @session.session_format %> · <%= @session.track %></h2> <p><%= @session.description.html_safe %></p> - <h3>Assigned Users</h3> + <% if @session.filedrop_comments.any? %> + <h3 class="mt-4">Comments <span class="font-normal">from Speakers' Filedrop</span></h2> + <ul class="space-y-4 my-4"> + <% @session.filedrop_comments.each do |comment| %> + <li class="bg-gray-100 shadow rounded-lg p-2"> + <div class="text-gray-900 whitespace-pre-wrap"><%= comment.body %></div> + <div class="text-gray-500 text-sm mt-2"> + <%= comment.orig_created&.in_time_zone(@session.conference.time_zone || 'UTC')&.strftime("%B %d, %Y %H:%M") %> + </div> + </li> + <% end %> + </ul> + <% end %> + + <h3 class="mt-4">Files <span class="font-normal">from Speakers' Filedrop</span></h3> + <ul class="space-y-4 my-4"> + <% @session.filedrop_files.each do |file| %> + <li class="bg-white shadow rounded-lg p-4"> + <div class="flex justify-between items-center"> + <div> + <div class="text-gray-900 text-lg font-semibold"><%= file.name %></div> + <div class="text-gray-500 text-sm">Size: <%= number_to_human_size(file.size) %></div> + <div class="text-gray-500 text-sm">Checksum: <%= file.checksum %></div> + </div> + <div> + <%= link_to 'Download', download_filedrop_file_path(file), class: "bg-blue-500 text-white px-3 py-2 rounded" %> + </div> + </div> + </li> + <% end %> + </ul> + + <h3 class="mt-4">Assigned Users</h3> <ul class="inline-flex flex-wrap gap-1 my-1"> <% @session.assignments.each do |assignment| %> <li> diff --git a/config/routes.rb b/config/routes.rb index cce0b9be65876b1da221bde24f2e846afa76e7d0..b66d9e15c7db2e780ff88600e404ba616f812299 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -32,6 +32,12 @@ Rails.application.routes.draw do end resources :sessions, param: :ref_id + resources :filedrop_files, only: [] do + member do + get 'download', to: 'filedrop_files#download' + end + end + # get 'conferences/:slug', to: 'conferences#show', as: :conference # get 'conferences/:slug/:date', to: 'conferences#show', as: :conference_day # get 'conferences/:slug/session/:ref_id', to: 'sessions#show', as: :conference_session diff --git a/test/controllers/filedrop_files_controller_test.rb b/test/controllers/filedrop_files_controller_test.rb new file mode 100644 index 0000000000000000000000000000000000000000..70192c3ed4ae4f493957241f91bfab8de3af40c9 --- /dev/null +++ b/test/controllers/filedrop_files_controller_test.rb @@ -0,0 +1,8 @@ +require "test_helper" + +class FiledropFilesControllerTest < ActionDispatch::IntegrationTest + test "should get download" do + get filedrop_files_download_url + assert_response :success + end +end