From 71c22417d4650d418572b244450bf93f12c6f3d6 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Sun, 6 Jul 2014 23:07:58 -0400 Subject: [PATCH] VRFS-1823 allow anonymous users to view session info page --- .../assets/javascripts/notificationPanel.js | 2 +- .../controllers/music_sessions_controller.rb | 15 +- .../music_sessions/session_info.html.haml | 138 +++++++++--------- web/spec/features/session_info_spec.rb | 2 +- 4 files changed, 79 insertions(+), 78 deletions(-) diff --git a/web/app/assets/javascripts/notificationPanel.js b/web/app/assets/javascripts/notificationPanel.js index fde7bf6ca..275f4cfb6 100644 --- a/web/app/assets/javascripts/notificationPanel.js +++ b/web/app/assets/javascripts/notificationPanel.js @@ -830,7 +830,7 @@ "text": payload.msg, "icon_url": context.JK.resolveAvatarUrl(payload.photo_url) }, [{ - id: "btn-view-profile", + id: "btn-manage-rsvp", text: "Manage RSVP", "layout-action": "close", href: "/client#/account/sessionDetail/" + payload.session_id, diff --git a/web/app/controllers/music_sessions_controller.rb b/web/app/controllers/music_sessions_controller.rb index 226142a58..a2dd17760 100644 --- a/web/app/controllers/music_sessions_controller.rb +++ b/web/app/controllers/music_sessions_controller.rb @@ -8,17 +8,11 @@ class MusicSessionsController < ApplicationController end def session_info + @can_view = true + @music_session = MusicSession.find(params[:id]) - # check whether user is logged in - if current_user.nil? - @music_session = MusicSession.new - @can_view = false - render :layout => "web", :status => 404 - - else - - @music_session = MusicSession.find(params[:id]) + unless current_user.nil? invitations = Invitation.where("music_session_id = ? AND receiver_id = ?", @music_session.id, current_user.id) has_invitation = !invitations.blank? @@ -53,6 +47,9 @@ class MusicSessionsController < ApplicationController end render :layout => "web" + + else + render :layout => "web" end end diff --git a/web/app/views/music_sessions/session_info.html.haml b/web/app/views/music_sessions/session_info.html.haml index 906ad80af..59297bcf2 100644 --- a/web/app/views/music_sessions/session_info.html.haml +++ b/web/app/views/music_sessions/session_info.html.haml @@ -15,10 +15,11 @@ %span.f12 Session Creator %br/ %br/ - - if current_user.id != @music_session.creator.id || (@open_slots.blank? && !@approved_rsvps.include?(current_user)) - .f12.call-to-action - %br/ - %a.button-orange{:id => "btn-action"} + - if !current_user.nil? + - if (current_user.id != @music_session.creator.id) || (@open_slots.blank? && !@approved_rsvps.include?(current_user)) + .f12.call-to-action + %br/ + %a.button-orange{:id => "btn-action"} .landing-details .left.f20.teal %strong SESSION @@ -40,11 +41,12 @@ %strong Description: .right.w75.ib.mb10.description = @music_session.description - .clearall.left.w20.ib.mb10 - %strong Notation Files: - .right.w75.ib.mb10.notations - - @music_session.music_notations.each do |n| - %a.gold{:href => n.file_url, :target => "_blank"}= n.file_name + - if !current_user.nil? + .clearall.left.w20.ib.mb10 + %strong Notation Files: + .right.w75.ib.mb10.notations + - @music_session.music_notations.each do |n| + %a.gold{:href => n.file_url, :target => "_blank"}= n.file_name .clearall.left.w20.ib.mb10 %strong Language: .right.w75.ib.mb10.language @@ -67,70 +69,71 @@ %br{clear:'all'}/ - .landing-sidebar - %br/ - %h2 SESSION MUSICIANS - %br/ - .left.w65.ib - %strong RSVPs - .right.w30.ib.f11 Your latency - - if @approved_rsvps.blank? - None - - @approved_rsvps.each_with_index do |rsvp, index| - .clearall.left.w100.h20.ib.mb10.rsvp-details - .avatar-tiny{'hoveraction' => "musician", 'user-id' => rsvp.id} - - if rsvp.photo_url.nil? - = image_tag 'shared/avatar_generic.png', :alt => "" - - else - %img{:src => "#{rsvp.photo_url}"} - .left.f11.ml10.rsvp-name - = rsvp.name - .left.ml10 - - rsvp.instrument_list.each do |i| - %img.instrument-icon{'instrument-id' => i[:id], height:24, width:24} - .right.w30.ib.f11.center.latency-tags + - unless current_user.nil? + .landing-sidebar + %br/ + %h2 SESSION MUSICIANS + %br/ + .left.w65.ib + %strong RSVPs + .right.w30.ib.f11 Your latency + - if @approved_rsvps.blank? + None + - @approved_rsvps.each_with_index do |rsvp, index| + .clearall.left.w100.h20.ib.mb10.rsvp-details + .avatar-tiny{'hoveraction' => "musician", 'user-id' => rsvp.id} + - if rsvp.photo_url.nil? + = image_tag 'shared/avatar_generic.png', :alt => "" + - else + %img{:src => "#{rsvp.photo_url}"} + .left.f11.ml10.rsvp-name + = rsvp.name + .left.ml10 + - rsvp.instrument_list.each do |i| + %img.instrument-icon{'instrument-id' => i[:id], height:24, width:24} + .right.w30.ib.f11.center.latency-tags - %br{:clear => "all"}/ - %br/ - .left.w65.ib.still-needed - %strong Still Needed - - if @open_slots.blank? - .clearall.left.w100.h20.ib.mb10 - All slots are taken - - else - - @open_slots.each do |slot| + %br{:clear => "all"}/ + %br/ + .left.w65.ib.still-needed + %strong Still Needed + - if @open_slots.blank? .clearall.left.w100.h20.ib.mb10 - .ib.h20 - %img.instrument-icon{'instrument-id' => slot.instrument_id, height:24, width:24} - .f11.ml10.ib.h20 - = slot.instrument_id.capitalize - = "(#{slot.proficiency_desc})" + All slots are taken + - else + - @open_slots.each do |slot| + .clearall.left.w100.h20.ib.mb10 + .ib.h20 + %img.instrument-icon{'instrument-id' => slot.instrument_id, height:24, width:24} + .f11.ml10.ib.h20 + = slot.instrument_id.capitalize + = "(#{slot.proficiency_desc})" - %br{:clear => "all"}/ - %br/ - .w65.ib.invited - %strong Invited - %br/ - - if @pending_invitations.blank? - None - - @pending_invitations.each_with_index do |invite, index| - - if index == 0 - .avatar-tiny.needed{'hoveraction' => "musician", 'user-id' => invite.id} - - unless invite.photo_url.blank? - = image_tag "#{invite.photo_url}", alt: "" - - else - = image_tag "shared/avatar_generic.png", alt: "" - - else - .ml10.avatar-tiny.needed - - unless invite.photo_url.blank? - = image_tag "#{invite.photo_url}", alt: "" - - else - = image_tag "shared/avatar_generic.png", alt: "" + %br{:clear => "all"}/ + %br/ + .w65.ib.invited + %strong Invited + %br/ + - if @pending_invitations.blank? + None + - @pending_invitations.each_with_index do |invite, index| + - if index == 0 + .avatar-tiny.needed{'hoveraction' => "musician", 'user-id' => invite.id} + - unless invite.photo_url.blank? + = image_tag "#{invite.photo_url}", alt: "" + - else + = image_tag "shared/avatar_generic.png", alt: "" + - else + .ml10.avatar-tiny.needed + - unless invite.photo_url.blank? + = image_tag "#{invite.photo_url}", alt: "" + - else + = image_tag "shared/avatar_generic.png", alt: "" - else .left.f20.teal - %strong.not-found SESSION NOT FOUND + %strong.not-found PRIVATE SESSION %br/ .clearall.left.w20.ib.mb10 @@ -138,7 +141,8 @@ %br/ - content_for :after_black_bar do %br/ - = render :partial => "shared/comments", :locals => {:comments => @music_session.session_info_comments, :id => "txtSessionInfoComment", :info_page => true} + - unless current_user.nil? + = render :partial => "shared/comments", :locals => {:comments => @music_session.session_info_comments, :id => "txtSessionInfoComment", :info_page => true} - content_for :extra_js do :javascript diff --git a/web/spec/features/session_info_spec.rb b/web/spec/features/session_info_spec.rb index 4dfab932a..bf76e81e4 100644 --- a/web/spec/features/session_info_spec.rb +++ b/web/spec/features/session_info_spec.rb @@ -111,7 +111,7 @@ describe "Session Info", :js => true, :type => :feature, :capybara_feature => tr end def ensure_failure - find('strong.not-found', text: "SESSION NOT FOUND") + find('strong.not-found', text: "PRIVATE SESSION") end describe "view" do