diff --git a/app/models/conference.rb b/app/models/conference.rb index 81e9ec32..081cc380 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -11,6 +11,7 @@ class Conference < ApplicationRecord scope :past, (-> { where('end_date < ?', Date.current) }) belongs_to :organization + delegate :code_of_conduct, to: :organization has_paper_trail ignore: %i(updated_at guid revision events_per_week), meta: { conference_id: :id } diff --git a/app/views/conferences/_code_of_conduct.haml b/app/views/conferences/_code_of_conduct.haml new file mode 100644 index 00000000..a41ca646 --- /dev/null +++ b/app/views/conferences/_code_of_conduct.haml @@ -0,0 +1,20 @@ += content_for :splash_nav do + %li + = link_to 'Code of Conduct', '#', + data: { toggle: 'modal', target: '#modal-code-of-conduct'} + +- content_for :modals do + - cache [organization, '#CoC-modal'] do + .modal.fade{ id: "modal-code-of-conduct" } + .modal-dialog + .modal-content + .modal-header + %button.close{ data: { dismiss: 'modal' } } + %i.fa.fa-close + %h3.modal-title Code of Conduct + .modal-body + = markdown organization.code_of_conduct + .modal-footer + = link_to 'permalink', + [:code_of_conduct, organization], + target: '_blank' diff --git a/app/views/conferences/_conference_details.html.haml b/app/views/conferences/_conference_details.html.haml index 84a87303..d07b3913 100644 --- a/app/views/conferences/_conference_details.html.haml +++ b/app/views/conferences/_conference_details.html.haml @@ -1,4 +1,4 @@ -.row +.row{ id: "conference-#{conference.id}" } .col-md-12 .well .row @@ -23,6 +23,10 @@ = link_to "View Conference", conference_path(conference.short_title), class: 'btn btn-default' - if conference.program and conference.program.schedule_public = link_to "Schedule", conference_schedule_path(conference.short_title), class: 'btn btn-default' + - unless conference.code_of_conduct.blank? + = link_to "Code of Conduct", + [:code_of_conduct, conference.organization], + class: 'btn btn-default' - if conference.registration_open? - if conference.user_registered?(current_user) = link_to "My Registration", conference_conference_registration_path(conference.short_title), class: 'btn btn-default' diff --git a/app/views/conferences/show.html.haml b/app/views/conferences/show.html.haml index 461c23d9..c2355dd4 100644 --- a/app/views/conferences/show.html.haml +++ b/app/views/conferences/show.html.haml @@ -11,6 +11,9 @@ = @conference.title #splash + - if @conference.code_of_conduct.present? + = render 'code_of_conduct', organization: @conference.organization + -# header/description = render 'header', conference: @conference, venue: @conference.venue diff --git a/spec/features/code_of_conduct_spec.rb b/spec/features/code_of_conduct_spec.rb index 2caf8e4c..f92063d7 100644 --- a/spec/features/code_of_conduct_spec.rb +++ b/spec/features/code_of_conduct_spec.rb @@ -43,6 +43,24 @@ feature 'Code of Conduct:' do expect(page).to have_text(sample_text) end end + + context 'on a conference' do + let!(:conference) { create(:full_conference, organization: organization) } + + it 'is linked from the index' do + visit conferences_path + within "#conference-#{conference.id}" do + click_on 'Code of Conduct' + end + expect(page).to have_text(sample_text) + end + + it 'is included in the splash page', js: true do + visit conference_path(conference) + click_on 'Code of Conduct' + expect(page).to have_text(sample_text) + end + end end end end