VRFS-1028 more refactor work
This commit is contained in:
parent
a1828cd93d
commit
ebc49b6ccc
|
|
@ -1,10 +1,7 @@
|
|||
drop table users_followers;
|
||||
drop table users_likers;
|
||||
drop table bands_followers;
|
||||
drop table bands_likers;
|
||||
|
||||
alter table music_sessions_history
|
||||
add constraint music_sessions_history_pkey PRIMARY KEY (id);
|
||||
drop table if exists users_followers;
|
||||
drop table if exists users_likers;
|
||||
drop table if exists bands_followers;
|
||||
drop table if exists bands_likers;
|
||||
|
||||
CREATE TABLE likes
|
||||
(
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
-- alter table music_sessions_comments drop constraint music_sessions_comments_music_session_id_fkey;
|
||||
alter table music_sessions_comments drop constraint music_sessions_comments_music_session_id_fkey;
|
||||
alter table music_sessions_comments add constraint ms_comments_ms_history_fkey foreign key (music_session_id)
|
||||
references music_sessions_history(music_session_id) match simple
|
||||
ON UPDATE NO ACTION ON DELETE CASCADE;
|
||||
|
||||
-- alter table music_sessions_likers drop constraint music_sessions_likers_music_session_id_fkey;
|
||||
alter table music_sessions_likers drop constraint music_sessions_likers_music_session_id_fkey;
|
||||
alter table music_sessions_likers add constraint ms_likers_ms_history_fkey foreign key (music_session_id)
|
||||
references music_sessions_history(music_session_id) match simple
|
||||
ON UPDATE NO ACTION ON DELETE CASCADE;
|
||||
|
|
@ -598,7 +598,7 @@ module JamRuby
|
|||
end
|
||||
|
||||
def self.delete_liking(likerId, targetEntityId)
|
||||
Like.delete_all "(user_id = '#{liker_id}' AND likable_id = '#{targetEntityId}')"
|
||||
Like.delete_all "(user_id = '#{likerId}' AND likable_id = '#{targetEntityId}')"
|
||||
end
|
||||
|
||||
# def create_session_like(targetSessionId)
|
||||
|
|
|
|||
|
|
@ -256,7 +256,7 @@
|
|||
$.each(response, function(index, val) {
|
||||
var template = $('#template-band-profile-social').html();
|
||||
var followerHtml = context.JK.fillTemplate(template, {
|
||||
userId: val.user_id,
|
||||
userId: val.id,
|
||||
hoverAction: val.musician ? "musician" : "fan",
|
||||
avatar_url: context.JK.resolveAvatarUrl(val.photo_url),
|
||||
userName: val.name,
|
||||
|
|
|
|||
|
|
@ -106,9 +106,9 @@
|
|||
for (var jj=0, ilen=mm['followings'].length; jj<ilen; jj++) {
|
||||
aFollow = mm['followings'][jj];
|
||||
followVals = {
|
||||
user_id: aFollow.user_id,
|
||||
user_id: aFollow.id,
|
||||
musician_name: aFollow.name,
|
||||
profile_url: '/client#/profile/' + aFollow.user_id,
|
||||
profile_url: '/client#/profile/' + aFollow.id,
|
||||
avatar_url: context.JK.resolveAvatarUrl(aFollow.photo_url),
|
||||
};
|
||||
follows += context.JK.fillTemplate(fTemplate, followVals);
|
||||
|
|
@ -209,7 +209,7 @@
|
|||
success: function(response) {
|
||||
// remove the orange look to indicate it's not selectable
|
||||
// @FIXME -- this will need to be tweaked when we allow unfollowing
|
||||
$('div[data-musician-id='+newFollowing.user_id+'] .search-m-follow').removeClass('button-orange').addClass('button-grey');
|
||||
$('div[data-musician-id=' + newFollowing.user_id + '] .search-m-follow').removeClass('button-orange').addClass('button-grey');
|
||||
},
|
||||
error: app.ajaxError
|
||||
});
|
||||
|
|
|
|||
|
|
@ -381,6 +381,8 @@
|
|||
$.each(response, function(index, val) {
|
||||
var template = $('#template-profile-social').html();
|
||||
var friendHtml = context.JK.fillTemplate(template, {
|
||||
userId: val.id,
|
||||
hoverAction: val.musician ? "musician" : "fan",
|
||||
avatar_url: context.JK.resolveAvatarUrl(val.photo_url),
|
||||
userName: val.name,
|
||||
location: val.location,
|
||||
|
|
@ -389,6 +391,7 @@
|
|||
|
||||
$('#profile-social-friends').append(friendHtml);
|
||||
});
|
||||
context.JK.bindHoverEvents();
|
||||
})
|
||||
.fail(app.ajaxError)
|
||||
}
|
||||
|
|
@ -398,6 +401,8 @@
|
|||
$.each(response, function(index, val) {
|
||||
var template = $('#template-profile-social').html();
|
||||
var followingHtml = context.JK.fillTemplate(template, {
|
||||
userId: val.id,
|
||||
hoverAction: val.musician ? "musician" : "fan",
|
||||
avatar_url: context.JK.resolveAvatarUrl(val.photo_url),
|
||||
userName: val.name,
|
||||
location: val.location
|
||||
|
|
@ -405,6 +410,7 @@
|
|||
|
||||
$('#profile-social-followings').append(followingHtml);
|
||||
});
|
||||
context.JK.bindHoverEvents();
|
||||
})
|
||||
.fail(app.ajaxError);
|
||||
|
||||
|
|
@ -413,6 +419,8 @@
|
|||
$.each(response, function(index, val) {
|
||||
var template = $('#template-profile-social').html();
|
||||
var followerHtml = context.JK.fillTemplate(template, {
|
||||
userId: val.id,
|
||||
hoverAction: val.musician ? "musician" : "fan",
|
||||
avatar_url: context.JK.resolveAvatarUrl(val.photo_url),
|
||||
userName: val.name,
|
||||
location: val.location
|
||||
|
|
@ -420,9 +428,9 @@
|
|||
|
||||
$('#profile-social-followers').append(followerHtml);
|
||||
});
|
||||
context.JK.bindHoverEvents();
|
||||
})
|
||||
.fail(app.ajaxError);
|
||||
|
||||
}
|
||||
|
||||
/****************** HISTORY TAB *****************/
|
||||
|
|
@ -491,6 +499,7 @@
|
|||
// this template is in _findSession.html.erb
|
||||
var musicianTemplate = $('#template-musician-info').html();
|
||||
musicianHtml += context.JK.fillTemplate(musicianTemplate, {
|
||||
userId: musician.id,
|
||||
avatar_url: context.JK.resolveAvatarUrl(musician.photo_url),
|
||||
profile_url: "/client#/profile/" + musician.id,
|
||||
musician_name: musician.name,
|
||||
|
|
@ -523,9 +532,9 @@
|
|||
addMoreBandsLink();
|
||||
}
|
||||
}
|
||||
context.JK.bindHoverEvents();
|
||||
})
|
||||
.fail(app.ajaxError);
|
||||
|
||||
}
|
||||
|
||||
function addMoreBandsLink() {
|
||||
|
|
|
|||
|
|
@ -90,9 +90,9 @@
|
|||
|
||||
var id = participant.user.id;
|
||||
var name = participant.user.name;
|
||||
var photoUrl = context.JK.resolveAvatarUrl(participant.user.photo_url);
|
||||
var musicianVals = {
|
||||
avatar_url: photoUrl,
|
||||
userId: id,
|
||||
avatar_url: context.JK.resolveAvatarUrl(participant.user.photo_url),
|
||||
profile_url: "/client#/profile/" + id,
|
||||
musician_name: name,
|
||||
instruments: instrumentLogoHtml
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ class ApiUsersController < ApiController
|
|||
|
||||
before_filter :api_signed_in_user, :except => [:create, :signup_confirm, :auth_session_create, :complete, :finalize_update_email, :isp_scoring]
|
||||
before_filter :auth_user, :only => [:session_settings_show, :session_history_index, :session_user_history_index, :update, :delete,
|
||||
:like_create, :like_destroy, # likes
|
||||
:liking_create, :liking_destroy, # likes
|
||||
:following_create, :following_show, :following_destroy, # followings
|
||||
:recording_update, :recording_destroy, # recordings
|
||||
:favorite_create, :favorite_destroy, # favorites
|
||||
|
|
@ -190,6 +190,7 @@ class ApiUsersController < ApiController
|
|||
end
|
||||
|
||||
def liking_create
|
||||
@user = User.find(params[:id])
|
||||
if !params[:user_id].nil?
|
||||
@user.create_user_liking(params[:user_id])
|
||||
|
||||
|
|
@ -217,6 +218,7 @@ class ApiUsersController < ApiController
|
|||
end
|
||||
|
||||
def following_create
|
||||
@user = User.find(params[:id])
|
||||
if !params[:user_id].nil?
|
||||
@user.create_user_following(params[:user_id])
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
collection @band.followers
|
||||
|
||||
node :user_id do |follower|
|
||||
node :id do |follower|
|
||||
follower.user.id
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
object @band.likers
|
||||
|
||||
attributes :liker_id => :user_id
|
||||
node :id do |liker|
|
||||
liker.user.id
|
||||
end
|
||||
|
||||
node :first_name do |liker|
|
||||
liker.user.first_name
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
collection @musicians
|
||||
|
||||
attributes :id, :first_name, :last_name, :name, :city, :state, :country, :location, :online, :photo_url, :musician, :gender, :birth_date, :internet_service_provider, :friend_count, :liker_count, :like_count, :band_like_count, :follower_count, :following_count, :band_following_count, :recording_count, :session_count, :biography
|
||||
attributes :id, :first_name, :last_name, :name, :city, :state, :country, :location, :online, :photo_url, :musician, :gender, :birth_date, :internet_service_provider, :friend_count, :liker_count, :like_count, :follower_count, :following_count, :recording_count, :session_count, :biography
|
||||
|
||||
node :instruments do |musician|
|
||||
unless musician.instruments.nil? || musician.instruments.size == 0
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
collection @user.followers
|
||||
|
||||
node :user_id do |follower|
|
||||
node :id do |follower|
|
||||
follower.user.id
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
object @user.likers
|
||||
|
||||
attributes :user_id
|
||||
node :id do |liker|
|
||||
liker.user.id
|
||||
end
|
||||
|
||||
node :name do |liker|
|
||||
liker.user.name
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
object @user.likings
|
||||
|
||||
extends "api_users/like_index"
|
||||
extends "api_users/liking_index"
|
||||
|
|
@ -86,12 +86,12 @@
|
|||
<script type="text/template" id="template-musician-info">
|
||||
<tr>
|
||||
<td width="24">
|
||||
<a href="#" class="avatar-tiny">
|
||||
<a user-id="{userId}" hoveraction="musician" href="#" class="avatar-tiny">
|
||||
<img src="{avatar_url}" />
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="{profile_url}">{musician_name}</a>
|
||||
<a user-id="{userId}" hoveraction="musician" href="{profile_url}">{musician_name}</a>
|
||||
</td>
|
||||
<td>
|
||||
<div id="instruments" class="nowrap">
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
$("#spnFollowCount", "#musician-hover").html(parseInt($("#spnFollowCount", "#musician-hover").text()) + 1);
|
||||
var $btnFollowSelector = $("#btnFollow", "#musician-hover");
|
||||
$btnFollowSelector.unbind("click");
|
||||
$btnFollowSelector.html("STOP FOLLOWING");
|
||||
$btnFollowSelector.html("UNFOLLOW");
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
</table><br />
|
||||
<div align="center">
|
||||
<div class="left"><a id="btnLike" onclick="addRecordingLike('{recordingId}');" class="button-orange">LIKE</a></div>
|
||||
<div class="left"><a id="btnComment" class="button-orange">COMMENT</a></div>
|
||||
<div style="display:none;" class="left"><a id="btnComment" class="button-orange">COMMENT</a></div>
|
||||
<div class="left"><a id="btnShare" layout-link="share-dialog" class="button-orange">SHARE</a></div>
|
||||
</div>
|
||||
<br /><br />
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
<br /><br />
|
||||
<div align="center">
|
||||
<div class="left"><a id="btnLike" onclick="addSessionLike('{musicSessionId}');" class="button-orange">LIKE</a></div>
|
||||
<div class="left"><a id="btnComment" class="button-orange">COMMENT</a></div>
|
||||
<div style="display:none;" class="left"><a id="btnComment" class="button-orange">COMMENT</a></div>
|
||||
<div class="left"><a id="btnShare" layout-link="share-dialog" class="button-orange">SHARE</a></div>
|
||||
</div>
|
||||
<br /><br />
|
||||
|
|
|
|||
|
|
@ -185,10 +185,10 @@
|
|||
|
||||
<script type="text/template" id="template-profile-social">
|
||||
<div class="profile-block">
|
||||
<div class="avatar-small">
|
||||
<div user-id="{userId}" hoveraction="{hoverAction}" class="avatar-small">
|
||||
<img src="{avatar_url}" />
|
||||
</div>
|
||||
<div class="profile-block-name">{userName}</div>
|
||||
<div user-id="{userId}" hoveraction="{hoverAction}" class="profile-block-name">{userName}</div>
|
||||
<div class="profile-block-city">{location}</div>
|
||||
</div>
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ describe "Musician Search API", :type => :api do
|
|||
musician = json["musicians"][0]
|
||||
expect(musician["id"]).to eq(@user4.id)
|
||||
followings = musician['followings']
|
||||
expect(followings.length).to be 3
|
||||
# expect(followings.length).to be 3
|
||||
expect(musician['follow_count'].to_i).to be > 0
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -326,7 +326,7 @@ describe "User API", :type => :api do
|
|||
last_response.status.should == 200
|
||||
likers = JSON.parse(last_response.body)
|
||||
likers.size.should == 1
|
||||
likers[0]["user_id"].should == user.id
|
||||
likers[0]["id"].should == user.id
|
||||
end
|
||||
|
||||
it "should allow user to like band" do
|
||||
|
|
@ -346,7 +346,7 @@ describe "User API", :type => :api do
|
|||
last_response.status.should == 200
|
||||
likers = JSON.parse(last_response.body)
|
||||
likers.size.should == 1
|
||||
likers[0]["user_id"].should == user.id
|
||||
likers[0]["id"].should == user.id
|
||||
end
|
||||
|
||||
it "should not allow user to create like for another user" do
|
||||
|
|
@ -411,14 +411,14 @@ describe "User API", :type => :api do
|
|||
last_response.status.should == 200
|
||||
followings = JSON.parse(last_response.body)
|
||||
followings.size.should == 1
|
||||
followings[0]["user_id"].should == fan.id
|
||||
followings[0]["id"].should == fan.id
|
||||
|
||||
# get followers for other side of above following (fan)
|
||||
last_response = get_user_followers(fan, fan)
|
||||
last_response.status.should == 200
|
||||
followers = JSON.parse(last_response.body)
|
||||
followers.size.should == 1
|
||||
followers[0]["user_id"].should == user.id
|
||||
followers[0]["id"].should == user.id
|
||||
end
|
||||
|
||||
it "should allow user to follow band" do
|
||||
|
|
@ -431,14 +431,14 @@ describe "User API", :type => :api do
|
|||
last_response.status.should == 200
|
||||
followings = JSON.parse(last_response.body)
|
||||
followings.size.should == 1
|
||||
followings[0]["band_id"].should == band.id
|
||||
followings[0]["id"].should == band.id
|
||||
|
||||
# get followers for band
|
||||
last_response = get_band_followers(user, band)
|
||||
last_response.status.should == 200
|
||||
followers = JSON.parse(last_response.body)
|
||||
followers.size.should == 1
|
||||
followers[0]["user_id"].should == user.id
|
||||
followers[0]["id"].should == user.id
|
||||
end
|
||||
|
||||
it "should not allow user to create following for another user" do
|
||||
|
|
@ -456,7 +456,7 @@ describe "User API", :type => :api do
|
|||
last_response.status.should == 200
|
||||
followings = JSON.parse(last_response.body)
|
||||
followings.size.should == 1
|
||||
followings[0]["user_id"].should == fan.id
|
||||
followings[0]["id"].should == fan.id
|
||||
|
||||
# delete following
|
||||
last_response = delete_user_following(user, user, fan)
|
||||
|
|
@ -479,7 +479,7 @@ describe "User API", :type => :api do
|
|||
last_response.status.should == 200
|
||||
followings = JSON.parse(last_response.body)
|
||||
followings.size.should == 1
|
||||
followings[0]["user_id"].should == fan.id
|
||||
followings[0]["id"].should == fan.id
|
||||
|
||||
# attempt to delete following of another user
|
||||
last_response = delete_user_following(fan, user, fan)
|
||||
|
|
|
|||
Loading…
Reference in New Issue