VRFS-1670 session info page work
This commit is contained in:
parent
f31248815d
commit
989a2a2b3a
|
|
@ -8,7 +8,7 @@ module JamRuby
|
|||
|
||||
RECURRING_MODES = [NO_RECURRING, RECURRING_WEEKLY]
|
||||
|
||||
attr_accessor :legal_terms, :recurring_mode, :language_description, :scheduled_start_time
|
||||
attr_accessor :legal_terms, :recurring_mode, :language_description, :scheduled_start_time, :access_description
|
||||
|
||||
self.table_name = "music_sessions"
|
||||
|
||||
|
|
@ -305,6 +305,29 @@ module JamRuby
|
|||
end
|
||||
end
|
||||
|
||||
def access_description
|
||||
musician_access_desc = ""
|
||||
fan_access_desc = ""
|
||||
|
||||
if self.musician_access
|
||||
if self.approval_required
|
||||
musician_access_desc = "Interested musicians may join by approval"
|
||||
else
|
||||
musician_access_desc = "Interested musicians may join at will"
|
||||
end
|
||||
end
|
||||
|
||||
if self.fan_access
|
||||
fan_access_desc = "Fans may listen"
|
||||
end
|
||||
|
||||
if self.fan_chat
|
||||
fan_access_desc = "#{fan_access_desc}, chat with each other"
|
||||
end
|
||||
|
||||
return "#{musician_access_desc}. #{fan_access_desc}."
|
||||
end
|
||||
|
||||
# next 3 methods are used for the right sidebar on the session info page
|
||||
|
||||
def approved_rsvps
|
||||
|
|
|
|||
|
|
@ -20,26 +20,46 @@ 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)
|
||||
|
||||
@approved_rsvps = @music_session.approved_rsvps
|
||||
@open_slots = @music_session.open_slots
|
||||
@pending_invitations = @music_session.pending_invitations
|
||||
invitations = Invitation.where("music_session_id = ? AND receiver_id = ?", @music_session.id, current_user.id)
|
||||
has_invitation = !invitations.blank?
|
||||
|
||||
unless @music_session.scheduled_start.nil?
|
||||
# session has not started yet
|
||||
if @music_session.scheduled_start > Time.now.utc
|
||||
if @music_session.musician_access && @music_session.approval_required && invitations.blank?
|
||||
if @music_session.creator.id == current_user.id || @music_session.open_rsvps || has_invitation
|
||||
@can_view = true
|
||||
@can_comment = true
|
||||
else
|
||||
@can_view = false
|
||||
@can_comment = false
|
||||
end
|
||||
|
||||
# only allow comments for invitees before the session has started
|
||||
unless current_user_invitation.blank?
|
||||
unless has_invitation
|
||||
@can_comment = true
|
||||
end
|
||||
|
||||
# session has started
|
||||
else
|
||||
|
||||
if @music_session.musician_access
|
||||
if @music_session.approval_required
|
||||
@can_view = false
|
||||
else
|
||||
@can_view = false
|
||||
end
|
||||
else
|
||||
@can_view = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# run these 3 queries only if the user has access to the page
|
||||
if @can_view
|
||||
@approved_rsvps = @music_session.approved_rsvps
|
||||
@open_slots = @music_session.open_slots
|
||||
@pending_invitations = @music_session.pending_invitations
|
||||
end
|
||||
|
||||
render :layout => "web"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@
|
|||
.clearall.left.w20.ib.mb10
|
||||
%strong Access:
|
||||
.right.w75.ib.mb10
|
||||
= @music_session.musician_access
|
||||
= @music_session.access_description
|
||||
.clearall.left.w20.ib.mb10
|
||||
%strong Legal:
|
||||
.right.w75.ib.mb10
|
||||
|
|
|
|||
Loading…
Reference in New Issue