Merge branch 'develop' oft sta bitbucket.org:jamkazam/jam-cloud into develop

This commit is contained in:
Seth Call 2014-02-27 18:38:12 +00:00
commit fd584967f2
19 changed files with 210 additions and 40 deletions

View File

@ -135,7 +135,7 @@
@body = msg
sendgrid_category "Notification"
sendgrid_unique_args :type => unique_args[:type]
mail(:to => email, :subject => subject) do |format|
mail(:bcc => email, :subject => subject) do |format|
format.text
format.html
end
@ -154,53 +154,54 @@
end
end
def musician_session_join(email, msg)
def musician_session_join(email, msg, session_id)
subject = "Someone you know is in a session on JamKazam"
unique_args = {:type => "musician_session_join"}
@body = msg
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session_id}"
sendgrid_category "Notification"
sendgrid_unique_args :type => unique_args[:type]
mail(:to => email, :subject => subject) do |format|
mail(:bcc => email, :subject => subject) do |format|
format.text
format.html
end
end
def band_session_join(email, msg)
def band_session_join(email, msg, session_id)
subject = "A band that you follow has joined a session"
unique_args = {:type => "band_session_join"}
@body = msg
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session_id}"
sendgrid_category "Notification"
sendgrid_unique_args :type => unique_args[:type]
mail(:to => email, :subject => subject) do |format|
mail(:bcc => email, :subject => subject) do |format|
format.text
format.html
end
end
def musician_recording_saved(email, msg)
subject = msg
subject = "A musician has saved a new recording on JamKazam"
unique_args = {:type => "musician_recording_saved"}
@body = msg
sendgrid_category "Notification"
sendgrid_unique_args :type => unique_args[:type]
mail(:to => email, :subject => subject) do |format|
mail(:bcc => email, :subject => subject) do |format|
format.text
format.html
end
end
def band_recording_saved(email, msg)
subject = msg
subject = "A band has saved a new recording on JamKazam"
unique_args = {:type => "band_recording_saved"}
@body = msg
sendgrid_category "Notification"
sendgrid_unique_args :type => unique_args[:type]
mail(:to => email, :subject => subject) do |format|
mail(:bcc => email, :subject => subject) do |format|
format.text
format.html
end
@ -236,7 +237,7 @@
# @body = msg
# sendgrid_category "Notification"
# sendgrid_unique_args :type => unique_args[:type]
# mail(:to => email, :subject => subject) do |format|
# mail(:bcc => email, :subject => subject) do |format|
# format.text
# format.html
# end

View File

@ -1,3 +1,3 @@
<% provide(:title, 'New Band Session') %>
<p><%= @body %></p>
<p><%= @body %>&nbsp;<a href="<%= @session_url %>">Listen in.</a></p>

View File

@ -1 +1 @@
<%= @body %>
<%= @body %> Listen at <%= @session_url %>.

View File

@ -1,3 +1,3 @@
<% provide(:title, 'Musician in Session') %>
<p><%= @body %></p>
<p><%= @body %>&nbsp;<a href="<%= @session_url %>">Listen in.</a></p>

View File

@ -1 +1 @@
<%= @body %>
<%= @body %> Listen at <%= @session_url %>.

View File

@ -1,14 +1,21 @@
module JamRuby
class GetWork < ActiveRecord::Base
self.table_name = "connections"
def self.get_work(mylocidispid)
list = get_work_list(mylocidispid)
list = self.get_work_list(mylocidispid)
return nil if list.nil?
return nil if list.length == 0
return list[0]
end
def self.get_work_list(mylocidispid)
GetWork.find_by_sql("select get_work(#{mylocidispid}) as client_id")
r = GetWork.select(:client_id).find_by_sql("select get_work(#{mylocidispid}) as client_id")
#puts("r = #{r}")
a = r.map {|i| i.client_id}
#puts("a = #{a}")
a
#return ["blah1", "blah2", "blah3", "blah4", "blah5"]
end
end

View File

@ -507,7 +507,7 @@ module JamRuby
# send email notifications
unless offline_ff.empty?
begin
UserMailer.musician_session_join(offline_ff.map! {|f| f.email}, notification_msg).deliver if APP_CONFIG.send_join_session_email_notifications
UserMailer.musician_session_join(offline_ff.map! {|f| f.email}, notification_msg, music_session.id).deliver if APP_CONFIG.send_join_session_email_notifications
rescue => e
@@log.error("unable to send email to offline participants #{e}")
end
@ -552,7 +552,7 @@ module JamRuby
# send email notifications
unless offline_followers.empty?
UserMailer.band_session_join(offline_followers.map! {|f| f.email}, notification_msg).deliver
UserMailer.band_session_join(offline_followers.map! {|f| f.email}, notification_msg, music_session.id).deliver if APP_CONFIG.send_join_session_email_notifications
end
end
end

View File

@ -8,6 +8,8 @@ module JamRuby
self.table_name = "recorded_tracks"
self.primary_key = 'id'
default_scope order('user_id ASC')
attr_accessor :marking_complete
attr_writer :is_skip_mount_uploader

View File

@ -1,7 +1,8 @@
require 'spec_helper'
describe GetWork do
before do
before(:each) do
end

View File

@ -108,9 +108,9 @@
for (var jj=0, ilen=mm['followings'].length; jj<ilen; jj++) {
aFollow = mm['followings'][jj];
followVals = {
user_id: aFollow.id,
user_id: aFollow.user_id,
musician_name: aFollow.name,
profile_url: '/client#/profile/' + aFollow.id,
profile_url: '/client#/profile/' + aFollow.user_id,
avatar_url: context.JK.resolveAvatarUrl(aFollow.photo_url),
};
follows += context.JK.fillTemplate(fTemplate, followVals);

View File

@ -58,9 +58,15 @@
var sessionDisplayStyle = 'none';
var sessionId = '';
var joinDisplayStyle = 'none';
if (response.sessions !== undefined && response.sessions.length > 0) {
sessionDisplayStyle = 'block';
sessionId = response.sessions[0].id;
var session = response.sessions[0];
sessionId = session.id;
if (context.jamClient && session.musician_access) {
joinDisplayStyle = 'inline';
}
}
var musicianHtml = context.JK.fillTemplate(template, {
@ -74,7 +80,8 @@
recording_count: response.recording_count,
session_count: response.session_count,
session_display: sessionDisplayStyle,
session_id: sessionId,
join_display: joinDisplayStyle,
sessionId: sessionId,
friendAction: response.is_friend ? "removeMusicianFriend" : (response.pending_friend_request ? "" : "sendMusicianFriendRequest"),
followAction: response.is_following ? "removeMusicianFollowing" : "addMusicianFollowing",
biography: response.biography,

View File

@ -8,6 +8,36 @@
var instrumentLogoMap = context.JK.getInstrumentIconMap24();
var hoverSelector = "#recording-hover";
function deDupTracks(recordedTracks) {
var tracks = [];
// this is replicated in recording.rb model
var t = {};
t.instrument_ids = []
$.each(recordedTracks, function(index, track) {
if (index > 0) {
if (recordedTracks[index-1].user.id !== recordedTracks[index].user.id) {
t = {};
t.instrument_ids = [];
t.instrument_ids.push(track.instrument_id);
t.user = track.user;
tracks.push(t);
}
else {
if ($.inArray(track.instrument_id, t.instrument_ids)) {
t.instrument_ids.push(track.instrument_id);
}
}
}
else {
t.user = track.user;
t.instrument_ids.push(track.instrument_id);
tracks.push(t);
}
});
return tracks;
}
this.showBubble = function() {
$(hoverSelector).css({left: position.left-100, top: position.top+20});
$(hoverSelector).fadeIn(500);
@ -18,9 +48,11 @@
var recording = response.recording;
$(hoverSelector).html('');
var deDupedTracks = deDupTracks(recording.recorded_tracks);
// musicians
var musicianHtml = '';
$.each(recording.recorded_tracks, function(index, val) {
$.each(deDupedTracks, function(index, val) {
var instrumentHtml = '';
var musician = val.user;
@ -28,7 +60,9 @@
musicianHtml += '<td width="75"><a href="#">' + musician.name + '</a></td>';
instrumentHtml = '<td><div class="nowrap">';
instrumentHtml += '<img src="' + instrumentLogoMap[val.instrument_id] + '" width="24" height="24" />&nbsp;';
$.each(val.instrument_ids, function(index, val) {
instrumentHtml += '<img src="' + instrumentLogoMap[val] + '" width="24" height="24" />&nbsp;&nbsp;';
})
instrumentHtml += '</div></td>';
musicianHtml += instrumentHtml;
@ -44,7 +78,7 @@
name: claimedRecording.name,
genre: claimedRecording.genre_id.toUpperCase(),
created_at: context.JK.formatDateTime(recording.created_at),
description: response.description,
description: response.description ? response.description : "",
play_count: recording.play_count,
comment_count: recording.comment_count,
like_count: recording.like_count,

View File

@ -224,7 +224,7 @@
}
context.JK.fetchUserNetworkOrServerFailure = function() {
app.notify({
JK.app.notify({
title: "Unable to communicate with server",
text: "Please try again later",
icon_url: "/assets/content/icon_alert_big.png"
@ -232,7 +232,7 @@
}
context.JK.entityNotFound = function(type) {
app.notify({
JK.app.notify({
title: type + " Deleted",
text: "The " + type + " no longer exists.",
icon_url: "/assets/content/icon_alert_big.png"

View File

@ -12,7 +12,9 @@ class ApiScoringController < ApiController
if !c.user.id.eql?(current_user.id) then render :json => {message: 'user does not own client_id'}, :status => 403; return end
# todo this method is a stub
result_client_id = client_id+'peer'
#puts "ApiScoringController#work(#{client_id}) => locidispid #{c.locidispid}"
result_client_id = JamRuby::GetWork.get_work(c.locidispid)
#result_client_id = client_id+'peer'
render :json => {:clientid => result_client_id}, :status => 200
end
@ -26,7 +28,8 @@ class ApiScoringController < ApiController
if !c.user.id.eql?(current_user.id) then render :json => {message: 'user does not own client_id'}, :status => 403; return end
# todo this method is a stub
result_client_ids = [client_id+'peer1', client_id+'peer2']
result_client_ids = JamRuby::GetWork.get_work_list(c.locidispid)
#result_client_ids = [client_id+'peer1', client_id+'peer2']
render :json => {:clientids => result_client_ids}, :status => 200
end

View File

@ -13,7 +13,7 @@ node :share_url do |claimed_recording|
end
child(:recording => :recording) {
attributes :id, :created_at, :duration, :comment_count, :like_count, :play_count, :grouped_tracks
attributes :id, :created_at, :duration, :comment_count, :like_count, :play_count
child(:band => :band) {
attributes :id, :name, :location, :photo_url

View File

@ -1,6 +1,6 @@
object @history
attributes :id, :music_session_id, :description, :genres, :like_count, :comment_count, :created_at, :grouped_tracks
attributes :id, :music_session_id, :description, :genres, :like_count, :comment_count, :created_at
node :share_url do |history|
unless history.share_token.nil?

View File

@ -4,6 +4,7 @@
<script type="text/javascript">
var rest = JK.Rest();
var logger = JK.logger;
// function addLike(userId) {
// rest.addLike({user_id: userId})
@ -15,6 +16,112 @@
// });
// }
/*********** TODO: THE NEXT 6 FUNCTIONS ARE COPIED FROM sessionList.js. REFACTOR TO COMMON PLACE. *************/
function joinClick(sessionId) {
var hasInvitation = false;
var session = null;
// we need to do a real-time check of the session in case the settings have
// changed while the user was sitting on the Find Session screen
$.ajax({
type: "GET",
url: "/api/sessions/" + sessionId,
async: false,
success: function(response) {
session = response;
if ("invitations" in session) {
var invitation;
// user has invitations for this session
for (var i=0; i < session.invitations.length; i++) {
invitation = session.invitations[i];
// session contains an invitation for this user
if (invitation.receiver_id === JK.currentUserId) {
hasInvitation = true;
}
}
}
if (session) {
// if user has an invitation, always open terms and allow joining regardless of settings
if (hasInvitation) {
logger.debug("Found invitation for user " + JK.currentUserId + ", session " + sessionId);
openTerms(sessionId);
}
else {
if (session.musician_access) {
if (session.approval_required) {
openAlert(sessionId);
}
else {
openTerms(sessionId);
}
}
}
}
},
error: function(xhr, textStatus, errorMessage) {
logger.debug("xhr.status = " + xhr.status);
if (xhr.status === 404) {
sessionNotJoinableAlert();
}
else {
JK.app.notify(
{ title: "Unable to Join Session",
text: "There was an unexpected error while attempting to join the session."
},
{ no_cancel: true });
}
}
});
}
function openAlert(sessionId) {
var alertDialog = new JK.AlertDialog(JK.app, "YES",
"You must be approved to join this session. Would you like to send a request to join?",
sessionId, onCreateJoinRequest);
alertDialog.initialize();
JK.app.layout.showDialog('alert');
}
function sessionNotJoinableAlert() {
var alertDialog = new JK.AlertDialog(JK.app, "OK",
"This session is over or is no longer public and cannot be joined. Please click Refresh to update the session list.",
null,
function(evt) {
JK.app.layout.closeDialog('alert');
}
);
alertDialog.initialize();
JK.app.layout.showDialog('alert');
}
function onCreateJoinRequest(sessionId) {
var joinRequest = {};
joinRequest.music_session = sessionId;
joinRequest.user = JK.currentUserId;
rest.createJoinRequest(joinRequest)
.done(function(response) {
}).error(JK.app.ajaxError);
JK.app.layout.closeDialog('alert');
}
function openTerms(sessionId) {
console.log("sessionId=%o", sessionId);
var termsDialog = new JK.TermsDialog(JK.app, sessionId, onTermsAccepted);
console.log("sessionId=%o", sessionId);
termsDialog.initialize();
JK.app.layout.showDialog('terms');
}
function onTermsAccepted(sessionId) {
window.location = '/client#/session/' + sessionId;
}
//////////////////////////////////////////////////////////////////////////////////////////
function addMusicianFollowing(userId) {
rest.addFollowing({user_id: userId})
.done(function(response) {
@ -82,7 +189,11 @@
{session_count} <img src="/assets/content/icon_session_tiny.png" width="12" height="12" align="absmiddle" />
</div>
<br clear="all" /><br />
<div style="display:{session_display}" class="f12"><strong>IN SESSION &mdash; <a href="/client#/session/{session_id}">Click to Join</a></strong></div>
<div style="display:{session_display}" class="f12">
<strong>IN SESSION <span style="display:{join_display}">&mdash;</span>
<a id="btnJoinSession" onclick="joinClick('{sessionId}');" style="display:{join_display}">Click to Join</a>
</strong>
</div>
<br />
<div class="f11">{biography}</div><br />
<small><strong>FOLLOWING:</strong></small><br /><br />

View File

@ -139,6 +139,7 @@
if (percentComplete === 100) {
$imgPlayPauseSelector.attr('src', playButtonPath);
$(".recording-slider").css({'left': 0 + '%'});
$(".recording-current").html("0:00");
}
});

View File

@ -74,7 +74,7 @@ describe ApiScoringController do
json = JSON.parse(response.body, :symbolize_names => true)
json.length.should == 1
json[:clientid].should_not be_nil
json[:clientid].should eql(@mary_client_id+'peer')
[@mary_client_id, @mike_client_id].should include(json[:clientid])
end
it 'try work with mike and mike' do
@ -84,7 +84,7 @@ describe ApiScoringController do
json = JSON.parse(response.body, :symbolize_names => true)
json.length.should == 1
json[:clientid].should_not be_nil
json[:clientid].should eql(@mike_client_id+'peer')
[@mary_client_id, @mike_client_id].should include(json[:clientid])
end
it 'try work with mike and mary' do
@ -136,8 +136,10 @@ describe ApiScoringController do
json[:clientids].should_not be_nil
json[:clientids].should_receive :length
json[:clientids].length == 2
json[:clientids][0].should eql(@mary_client_id+'peer1')
json[:clientids][1].should eql(@mary_client_id+'peer2')
[@mary_client_id, @mike_client_id].should include(json[:clientids][0])
[@mary_client_id, @mike_client_id].should include(json[:clientids][1])
json[:clientids][0].should_not eql(json[:clientids][1])
end
it 'try worklist with mike and mike' do
@ -149,8 +151,9 @@ describe ApiScoringController do
json[:clientids].should_not be_nil
json[:clientids].should_receive :length
json[:clientids].length == 2
json[:clientids][0].should eql(@mike_client_id+'peer1')
json[:clientids][1].should eql(@mike_client_id+'peer2')
[@mary_client_id, @mike_client_id].should include(json[:clientids][0])
[@mary_client_id, @mike_client_id].should include(json[:clientids][1])
json[:clientids][0].should_not eql(json[:clientids][1])
end
it 'try worklist with mary and mike' do