From 31dfd62fbd4dfc7c4d93bed34427aba40f4d27b7 Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Fri, 17 Jul 2020 10:03:07 -0700 Subject: [PATCH] Better design for room URLs --- app/helpers/events_helper.rb | 18 ++++++++++++++++++ app/models/event.rb | 2 ++ app/views/proposals/show.html.haml | 5 ++--- app/views/schedules/_event.html.haml | 6 +++--- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index 31384a2c..82815a1c 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -173,6 +173,24 @@ module EventsHelper ) end + def join_event_link(event, current_user) + return unless event.url.present? && current_user + + conference = event.conference + is_today = event.time&.today? + if current_user.roles.where(id: conference.roles).any? + # Show Pre-Event links for any memeber of the conference team. + link_to("Join Live Event #{'(Pre-Event)' unless is_today}", + event.url, target: '_blank') + elsif current_user.registered_to_event?(conference) + if is_today + link_to('Join Live Event', event.url, target: '_blank') + else + link_to('Live Event Link Coming Soon', '#') + end + end + end + private def active_dropdown(selection, options) diff --git a/app/models/event.rb b/app/models/event.rb index 3c9fe4f1..7b21ee73 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -31,6 +31,8 @@ class Event < ApplicationRecord belongs_to :track belongs_to :difficulty_level belongs_to :program + belongs_to :room + delegate :url, to: :room, allow_nil: true accepts_nested_attributes_for :event_users, allow_destroy: true accepts_nested_attributes_for :speakers, allow_destroy: true diff --git a/app/views/proposals/show.html.haml b/app/views/proposals/show.html.haml index 0de85205..a5fd187f 100644 --- a/app/views/proposals/show.html.haml +++ b/app/views/proposals/show.html.haml @@ -16,9 +16,8 @@ %br %small = @event.subtitle - - if @event.room&.url && @conference.user_registered?(current_user) - %h3 - = link_to('Join Event', @event.room.url, target: '_blank') + %h3 + = join_event_link(@event, current_user) .col-md-2 %p{style: "margin-top: 20px"} - if can?(:update, @event) && @event.require_registration? diff --git a/app/views/schedules/_event.html.haml b/app/views/schedules/_event.html.haml index 7ec7122f..63a65233 100644 --- a/app/views/schedules/_event.html.haml +++ b/app/views/schedules/_event.html.haml @@ -17,11 +17,11 @@ %h4 - if(event.speakers.any?) presented by #{event.speaker_names} - - if event.room&.url && @conference.user_registered?(current_user) - %p - = link_to('Join Event', event.room.url, target: '_blank') + %h5 + = join_event_link(event, current_user) %p = markdown(truncate(event.abstract, length: 400)) + -# TODO: More informative text or aria-label. = link_to 'more', conference_program_proposal_path(@conference.short_title, event.id) if event.abstract.length > 400 - if event_schedule.present? %span.track