VRFS-1670 session info page work
This commit is contained in:
parent
2cef0872d9
commit
cc4686ab79
|
|
@ -32,7 +32,7 @@ module JamRuby
|
|||
has_many :fan_invitations, :foreign_key => "music_session_id", :inverse_of => :music_session, :class_name => "JamRuby::FanInvitation", :foreign_key => "music_session_id"
|
||||
has_many :invited_fans, :through => :fan_invitations, :class_name => "JamRuby::User", :foreign_key => "receiver_id", :source => :receiver
|
||||
has_many :rsvp_slots, :class_name => "JamRuby::RsvpSlot", :foreign_key => "music_session_id", :dependent => :destroy
|
||||
has_many :music_notations, :class_name => "JamRuby::MusicNotations", :foreign_key => "music_session_id"
|
||||
has_many :music_notations, :class_name => "JamRuby::MusicNotation", :foreign_key => "music_session_id"
|
||||
|
||||
validates :genre, :presence => true
|
||||
validates :description, :presence => true, :no_profanity => true
|
||||
|
|
@ -288,6 +288,56 @@ module JamRuby
|
|||
return "http://www.jamkazam.com/session-legal-policies/jamtracks"
|
||||
else
|
||||
return ""
|
||||
end
|
||||
end
|
||||
|
||||
# next 3 methods are used for the right sidebar on the session info page
|
||||
|
||||
def approved_rsvps
|
||||
users = User.find_by_sql(%Q{select u.id, u.photo_url, u.first_name, u.last_name, rs.instrument_id
|
||||
from rsvp_slots rs
|
||||
inner join rsvp_requests_rsvp_slots rrrs on rrrs.rsvp_slot_id = rs.id
|
||||
inner join rsvp_requests rr on rrrs.rsvp_request_id = rr.id
|
||||
inner join users u on u.id = rr.user_id
|
||||
where rrrs.chosen = true and rs.music_session_id = '#{self.id}'
|
||||
order by u.id})
|
||||
|
||||
users_collapsed_instruments = []
|
||||
user = User.new
|
||||
|
||||
# build User array with instruments collapsed
|
||||
users.each_with_index do |u, index|
|
||||
if index == 0 || users[index].id != users[index-1].id
|
||||
user = User.new
|
||||
user.id = u.id
|
||||
user.photo_url = u.photo_url
|
||||
user.first_name = u.first_name
|
||||
user.last_name = u.last_name
|
||||
user["instruments"] = [u.instrument_id]
|
||||
users_collapsed_instruments << user
|
||||
else
|
||||
user["instruments"] << u.instrument_id
|
||||
end
|
||||
end
|
||||
|
||||
users_collapsed_instruments
|
||||
end
|
||||
|
||||
def open_slots
|
||||
RsvpSlot.find_by_sql(%Q{select rs.*
|
||||
from rsvp_slots rs
|
||||
left join rsvp_requests_rsvp_slots rrrs on rrrs.rsvp_slot_id = rs.id
|
||||
where (rrrs.rsvp_slot_id is null or rrrs.chosen != true)
|
||||
and rs.music_session_id = '#{self.id}'})
|
||||
end
|
||||
|
||||
def pending_invitations
|
||||
Invitation.find_by_sql(%Q{select u.id, u.photo_url, u.first_name, u.last_name
|
||||
from invitations i
|
||||
inner join users u on u.id = i.receiver_id
|
||||
left join rsvp_requests rr on rr.user_id = i.receiver_id
|
||||
where i.music_session_id = '#{self.id}'
|
||||
and rr.user_id is null})
|
||||
end
|
||||
|
||||
def recordings
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@
|
|||
var rest = JK.Rest();
|
||||
|
||||
function initialize(musicSessionId) {
|
||||
console.log('initializing %o', musicSessionId);
|
||||
context.JK.setInstrumentAssetPath($('.instrument-icon', $('.landing-sidebar')));
|
||||
}
|
||||
|
||||
this.initialize = initialize;
|
||||
|
|
|
|||
|
|
@ -283,7 +283,10 @@ small, .small {font-size:11px;}
|
|||
.mt55 {margin-top:55px;}
|
||||
.mt65 {margin-top:65px;}
|
||||
|
||||
.mb5 {margin-bottom:5px;}
|
||||
.mt5 {margin-top:5px}
|
||||
.mt10 {margin-top:10px}
|
||||
.mb5 {margin-bottom:5px}
|
||||
.mb10 {margin-bottom:10px}
|
||||
.mb15 {margin-bottom:15px;}
|
||||
|
||||
.w0 {width:0% !important}
|
||||
|
|
|
|||
|
|
@ -240,6 +240,25 @@ body.web {
|
|||
}
|
||||
}
|
||||
|
||||
.avatar-tiny {
|
||||
float:left;
|
||||
padding:1px;
|
||||
width:24px;
|
||||
height:24px;
|
||||
background-color:#ed3618;
|
||||
-webkit-border-radius:12px;
|
||||
-moz-border-radius:12px;
|
||||
border-radius:12px;
|
||||
}
|
||||
|
||||
.avatar-tiny img {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
-webkit-border-radius:12px;
|
||||
-moz-border-radius:12px;
|
||||
border-radius:12px;
|
||||
}
|
||||
|
||||
.cta {
|
||||
margin-top:40px;
|
||||
text-align:center;
|
||||
|
|
|
|||
|
|
@ -20,21 +20,24 @@ class MusicSessionsController < ApplicationController
|
|||
else
|
||||
|
||||
@music_session = MusicSession.find(params[:id])
|
||||
current_user_invitation = Invitation.where("music_session_id = ? AND receiver_id = ?", music_session.id, current_user.id)
|
||||
current_user_invitation = Invitation.where("music_session_id = ? AND receiver_id = ?", @music_session.id, current_user.id)
|
||||
|
||||
# get all invitations for users that do not have an RSVP request
|
||||
@pending_invitations =
|
||||
@approved_rsvps = @music_session.approved_rsvps
|
||||
@open_slots = @music_session.open_slots
|
||||
@pending_invitations = @music_session.pending_invitations
|
||||
|
||||
unless @music_session.scheduled_start.nil?
|
||||
if @music_session.scheduled_start > Time.now.utc
|
||||
if @music_session.musician_access && @music_session.approval_required && invitations.blank?
|
||||
@can_view = false
|
||||
end
|
||||
# only allow comments for invitees before the session has started
|
||||
unless current_user_invitation.blank?
|
||||
@can_comment = true
|
||||
end
|
||||
else
|
||||
|
||||
if @music_session.scheduled_start > Time.now.utc
|
||||
if @music_session.musician_access && @music_session.approval_required && invitations.blank?
|
||||
@can_view = false
|
||||
end
|
||||
# only allow comments for invitees before the session has started
|
||||
unless current_user_invitation.blank?
|
||||
@can_comment = true
|
||||
end
|
||||
else
|
||||
|
||||
end
|
||||
|
||||
render :layout => "web"
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
%script{type: 'text/template', id: 'template-comments'}
|
||||
.avatar-small.mr10{'user-id' => '{{data.user_id}}', 'hoveraction' => '{{data.hoverAction}}', 'profileaction' => '{{data.hoverAction}}'}
|
||||
%a{'href' => '/client#/profile/{{data.user_id}}'}
|
||||
%img{:'src' => '{{data.avatar_url}}', alt: ''}
|
||||
%img{:src => '{{data.avatar_url}}', alt: ''}
|
||||
.w80.left.p10.lightgrey.mt10.comment-text
|
||||
%a{'user-id' => '{{data.user_id}}', 'hoveraction' => '{{data.hoverAction}}', 'profileaction' => '{{data.hoverAction}}'} {{data.name}}
|
||||
{{data.comment}}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
= image_tag "#{@music_session.creator.photo_url}", alt: ""
|
||||
- else
|
||||
= image_tag "shared/avatar_generic.png", alt: ""
|
||||
- end
|
||||
= @music_session.creator.name
|
||||
%br/
|
||||
%span.f12 Session Creator
|
||||
|
|
@ -17,20 +16,21 @@
|
|||
%br/
|
||||
.f12 Tell the session creator you'd like to play in this session
|
||||
%br/
|
||||
%br/
|
||||
%a.button-orange{:id => "btn-rsvp"}
|
||||
RSVP NOW!
|
||||
.landing-details
|
||||
.left.f20.teal
|
||||
%strong SESSION
|
||||
%br/
|
||||
%strong Date/Time:
|
||||
%br/
|
||||
%br/
|
||||
.clearall.left.w20.ib.mb10
|
||||
%strong Date/Time:
|
||||
.right.w75.ib.mb10
|
||||
= @music_session.scheduled_start
|
||||
.clearall.left.w20.ib.mb10
|
||||
%strong Genre:
|
||||
.right.w75.ib.mb10
|
||||
= @music_session.scheduled_start
|
||||
= @music_session.genre
|
||||
.clearall.left.w20.ib.mb10
|
||||
%strong Name:
|
||||
.right.w75.ib.mb10
|
||||
|
|
@ -43,7 +43,7 @@
|
|||
%strong Notation Files:
|
||||
.right.w75.ib.mb10
|
||||
- @music_session.music_notations.each do |n|
|
||||
%a.gold{:href => n.file_url}
|
||||
%a.gold{:href => n.file_url}
|
||||
.clearall.left.w20.ib.mb10
|
||||
%strong Language:
|
||||
.right.w75.ib.mb10
|
||||
|
|
@ -51,12 +51,12 @@
|
|||
.clearall.left.w20.ib.mb10
|
||||
%strong Access:
|
||||
.right.w75.ib.mb10
|
||||
= @music_session.access
|
||||
= @music_session.musician_access
|
||||
.clearall.left.w20.ib.mb10
|
||||
%strong Legal:
|
||||
.right.w75.ib.mb10
|
||||
= @music_session.legal_policy.capitalize agreement(
|
||||
%a.{:href => @music_session.legal_policy_url, :target => "_blank"} View full legal details)
|
||||
= @music_session.legal_policy
|
||||
%a{:href => "#{@music_session.legal_policy_url}", :target => "_blank"}
|
||||
|
||||
%br{clear:'all'}
|
||||
|
||||
|
|
@ -67,12 +67,30 @@
|
|||
.left.w65.ib
|
||||
%strong RSVPs
|
||||
.right.w30.ib.f11.center Your latency
|
||||
- @approved_rsvps.each_with_index do |rsvp, index|
|
||||
.clearall.left.w65.h20.ib.mb10
|
||||
.avatar-tiny
|
||||
- if rsvp.photo_url.nil?
|
||||
= image_tag 'shared/avatar_generic.png', :alt => ""
|
||||
- else
|
||||
%img{:src => "#{rsvp.photo_url}"}
|
||||
.left.f11.ml10
|
||||
= rsvp.name
|
||||
.left.ml10
|
||||
- rsvp["instruments"].each do |i|
|
||||
%img.instrument-icon{'instrument-id' => i, height:24, width:24}
|
||||
|
||||
- else
|
||||
.left.f20.teal
|
||||
%strong SESSION NOT FOUND
|
||||
%br/
|
||||
.clearall.left.w20.ib.mb10
|
||||
|
||||
.left.f20.teal
|
||||
%strong SESSION NOT FOUND
|
||||
%br/
|
||||
.clearall.left.w20.ib.mb10
|
||||
|
||||
%br{:clear => "all"}/
|
||||
%br/
|
||||
:javascript
|
||||
$(function () {
|
||||
var ss = new window.JK.ShowSessionInfo(JK.app);
|
||||
ss.initialize("#{@music_session.id}");
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe "Session Info", :js => true, :type => :feature, :capybara_feature => true do
|
||||
|
||||
let (:user) { FactoryGirl.create(:user) }
|
||||
|
||||
before(:all) do
|
||||
MusicSession.delete_all
|
||||
end
|
||||
|
||||
before(:each) do
|
||||
create_session(creator: user)
|
||||
formal_leave_by(user)
|
||||
end
|
||||
|
||||
# musician_access = true, approval_required = true
|
||||
it "should allow only session invitees to view for 'XXX' option before session starts" do
|
||||
end
|
||||
|
||||
# musician_access = false, approval_required = false
|
||||
it "should allow only RSVP approvals to view for 'Only RSVP musicians may join' option after session starts" do
|
||||
end
|
||||
|
||||
# musician_access = true, approval_required = false
|
||||
it "should allow anyone to view for 'at will' option after session starts" do
|
||||
end
|
||||
|
||||
# musician_access = true, approval_required = true
|
||||
it "should allow anyone to view for 'join by approval' option after session starts" do
|
||||
end
|
||||
|
||||
end
|
||||
Loading…
Reference in New Issue