From 7d2135f8519e93dd2ed26eb32d7a2b5d81877757 Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Fri, 10 Jul 2020 20:18:10 -0700 Subject: [PATCH] Add the ability for Rooms to have a URL. The URL is shown on the schedule and the event/proposal page. The URL is only when a user is logged in and registered. --- app/assets/javascripts/osem-schedule.js | 3 +++ app/controllers/admin/rooms_controller.rb | 2 +- app/views/admin/rooms/_form.html.haml | 3 +++ app/views/admin/rooms/index.html.haml | 13 ++++++----- app/views/proposals/show.html.haml | 22 +++++++++++-------- app/views/schedules/_event.html.haml | 3 +++ app/views/schedules/show.html.haml | 2 +- db/migrate/20200710215300_add_url_to_rooms.rb | 5 +++++ db/schema.rb | 3 ++- 9 files changed, 39 insertions(+), 17 deletions(-) create mode 100644 db/migrate/20200710215300_add_url_to_rooms.rb diff --git a/app/assets/javascripts/osem-schedule.js b/app/assets/javascripts/osem-schedule.js index aeb76ae3..ac1099d1 100644 --- a/app/assets/javascripts/osem-schedule.js +++ b/app/assets/javascripts/osem-schedule.js @@ -115,6 +115,9 @@ $(document).ready( function() { }); function eventClicked(e, element){ + if (e.target.href) { + return; + } var url = $(element).data('url'); if(e.ctrlKey) window.open(url,'_blank'); diff --git a/app/controllers/admin/rooms_controller.rb b/app/controllers/admin/rooms_controller.rb index c4fac65d..58c2fd83 100644 --- a/app/controllers/admin/rooms_controller.rb +++ b/app/controllers/admin/rooms_controller.rb @@ -48,7 +48,7 @@ module Admin private def room_params - params.require(:room).permit(:name, :size) + params.require(:room).permit(:name, :size, :url) end end end diff --git a/app/views/admin/rooms/_form.html.haml b/app/views/admin/rooms/_form.html.haml index 90de99e0..951e4094 100644 --- a/app/views/admin/rooms/_form.html.haml +++ b/app/views/admin/rooms/_form.html.haml @@ -11,5 +11,8 @@ = semantic_form_for(@room, url: (@room.new_record? ? admin_conference_venue_rooms_path : admin_conference_venue_room_path(@conference.short_title, @room))) do |f| = f.input :name, input_html: { autofocus: true } = f.input :size, label: 'Capacity', input_html: {size: 5} + = f.input :url, label: 'URL' + %p.small + The URL is only visible to registered attendees. %p.text-right = f.action :submit, as: :button, button_html: { class: 'btn btn-primary' } diff --git a/app/views/admin/rooms/index.html.haml b/app/views/admin/rooms/index.html.haml index 2d1545f6..fd548d59 100644 --- a/app/views/admin/rooms/index.html.haml +++ b/app/views/admin/rooms/index.html.haml @@ -12,6 +12,7 @@ %thead %th Name %th Capacity + %th URL %th Actions %tbody - @rooms.each_with_index do |room, index| @@ -21,11 +22,13 @@ %td = room.size %td - = link_to 'Edit', edit_admin_conference_venue_room_path(@conference.short_title, room.id), - method: :get, class: 'btn btn-primary' - = link_to 'Delete', admin_conference_venue_room_path(@conference.short_title, room.id), - method: :delete, class: 'btn btn-danger', - data: { confirm: "Do you really want to delete #{room.name}? Attention: This room will be removed from all Events that have it set"} + = room.url + %td + = link_to 'Edit', edit_admin_conference_venue_room_path(@conference.short_title, room.id), class: 'btn btn-primary' + = link_to('Delete', + admin_conference_venue_room_path(@conference.short_title, room.id), + method: :delete, class: 'btn btn-danger', + data: { confirm: "Do you really want to delete #{room.name}? Attention: This room will be removed from all Events that have it set"}) .row .col-md-12.text-right = link_to 'Add Room', new_admin_conference_venue_room_path(@conference.short_title), class: 'btn btn-primary' diff --git a/app/views/proposals/show.html.haml b/app/views/proposals/show.html.haml index a7a155bb..08388ac0 100644 --- a/app/views/proposals/show.html.haml +++ b/app/views/proposals/show.html.haml @@ -8,21 +8,25 @@ %meta{ property: "og:image:secure_url", content: @speakers_ordered.first.gravatar_url } .container - .row - .col-md-12.page-header + .row.page-header + .col-md-10 %h2 = @event.title - if @event.subtitle %br %small = @event.subtitle - .btn-group.pull-right - - if can? :update, @event - = link_to 'Registrations', registrations_conference_program_proposal_path(@conference.short_title, @event), class: 'btn btn-mini btn-success' - - if can? :edit, @event - = link_to "Edit", edit_conference_program_proposal_path(@conference.short_title, @event), class: 'btn btn-mini btn-primary' - - if can? :schedule, @conference - = link_to "Schedule", conference_schedule_path(@conference.short_title), class: 'btn btn-success' + - if @event.room&.url && @conference.user_registered?(current_user) + %h3 + = link_to('Join Event', @event.room.url, target: '_blank') + .col-md-2 + %p{style: "margin-top: 20px"} + - if can?(:update, @event) && @event.require_registration? + = link_to 'Registrations', registrations_conference_program_proposal_path(@conference.short_title, @event), class: 'btn btn-mini btn-success' + - if can?(:edit, @event) + = link_to "Edit", edit_conference_program_proposal_path(@conference.short_title, @event), class: 'btn btn-mini btn-primary' + - if can? :schedule, @conference + = link_to "Schedule", conference_schedule_path(@conference.short_title), class: 'btn btn-success' .row .col-md-3 diff --git a/app/views/schedules/_event.html.haml b/app/views/schedules/_event.html.haml index 99ced63b..601afdf5 100644 --- a/app/views/schedules/_event.html.haml +++ b/app/views/schedules/_event.html.haml @@ -17,6 +17,9 @@ %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') %p = markdown(truncate(event.abstract, length: 400)) = link_to 'more', conference_program_proposal_path(@conference.short_title, event.id) if event.abstract.length > 400 diff --git a/app/views/schedules/show.html.haml b/app/views/schedules/show.html.haml index 355cafad..c1ca83aa 100644 --- a/app/views/schedules/show.html.haml +++ b/app/views/schedules/show.html.haml @@ -1,5 +1,5 @@ .container - = render partial: 'schedule_tabs', locals: { active: 'schedule' } + = render partial: 'schedule_tabs', locals: { active: 'schedule' } #schedule-content %h1.text-center diff --git a/db/migrate/20200710215300_add_url_to_rooms.rb b/db/migrate/20200710215300_add_url_to_rooms.rb new file mode 100644 index 00000000..65e46907 --- /dev/null +++ b/db/migrate/20200710215300_add_url_to_rooms.rb @@ -0,0 +1,5 @@ +class AddUrlToRooms < ActiveRecord::Migration[5.2] + def change + add_column :rooms, :url, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 3f862d87..dbae1f2e 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.define(version: 2020_03_31_214534) do +ActiveRecord::Schema.define(version: 2020_07_10_215300) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -406,6 +406,7 @@ ActiveRecord::Schema.define(version: 2020_03_31_214534) do t.string "name", null: false t.integer "size" t.integer "venue_id", null: false + t.text "url" end create_table "schedules", force: :cascade do |t|