VRFS-877 bug fixes

This commit is contained in:
Brian Smith 2013-12-15 22:53:16 -05:00
parent 5ea5fd3d63
commit d583393598
6 changed files with 43 additions and 8 deletions

View File

@ -1,12 +1,16 @@
module JamRuby
class Band < ActiveRecord::Base
attr_accessible :name, :website, :biography, :city, :state, :country
attr_accessible :name, :website, :biography, :city, :state,
:country, :original_fpfile_photo, :cropped_fpfile_photo,
:cropped_s3_path_photo, :crop_selection_photo, :photo_url
attr_accessor :updating_photo
self.primary_key = 'id'
before_save :stringify_photo_info , :if => :updating_photo
validate :validate_photo_info
validates :biography, no_profanity: true
# musicians
@ -59,6 +63,14 @@ module JamRuby
loc
end
def validate_photo_info
if updating_photo
# we want to mak sure that original_fpfile and cropped_fpfile seems like real fpfile info objects (i.e, json objects from filepicker.io)
errors.add(:original_fpfile_photo, ValidationMessages::INVALID_FPFILE) if self.original_fpfile_photo.nil? || self.original_fpfile_photo["key"].nil? || self.original_fpfile_photo["url"].nil?
errors.add(:cropped_fpfile_photo, ValidationMessages::INVALID_FPFILE) if self.cropped_fpfile_photo.nil? || self.cropped_fpfile_photo["key"].nil? || self.cropped_fpfile_photo["url"].nil?
end
end
def add_member(user_id, admin)
BandMusician.create(:band_id => self.id, :user_id => user_id, :admin => admin)
end
@ -241,5 +253,15 @@ module JamRuby
end
end
end
def stringify_photo_info
# fpfile comes in as a hash, which is a easy-to-use and validate form. However, we store it as a VARCHAR,
# so we need t oconvert it to JSON before storing it (otherwise it gets serialized as a ruby object)
# later, when serving this data out to the REST API, we currently just leave it as a string and make a JSON capable
# client parse it, because it's very rare when it's needed at all
self.original_fpfile_photo = original_fpfile_photo.to_json if !original_fpfile_photo.nil?
self.cropped_fpfile_photo = cropped_fpfile_photo.to_json if !cropped_fpfile_photo.nil?
self.crop_selection_photo = crop_selection_photo.to_json if !crop_selection_photo.nil?
end
end
end

View File

@ -7,7 +7,6 @@
var self = this;
var logger = context.JK.logger;
var rest = context.JK.Rest();
var userId;
var user = {};
var tmpUploadPath = null;
var userDetail = null;
@ -18,8 +17,6 @@
var userDropdown;
function beforeShow(data) {
logger.debug("data.id=" + data.id);
userId = data.id;
}

View File

@ -229,7 +229,8 @@
userNames = [];
userIds = [];
userPhotoUrls = [];
bandId = "1158c8b6-4c92-47dc-82bf-1e390c4f9b2c";// $("#hdn-band-id").val();
//bandId = "1158c8b6-4c92-47dc-82bf-1e390c4f9b2c";
bandId = $("#hdn-band-id").val();
resetForm();
}
@ -271,6 +272,10 @@
$("#band-website").val(band.website);
$("#band-biography").val(band.biography);
if (band.photo_url) {
$("#band-avatar").attr('src', band.photo_url);
}
loadGenres(band.genres);
loadCountries(band.country, function() {

View File

@ -60,9 +60,9 @@
function events() {
// wire up main panel clicks
$('#band-setup-photo-content-scroller').on('click', '#band-setup-photo-upload', function(evt) { evt.stopPropagation(); handleFilePick(); return false; } );
$('#band-setup-photo-content-scroller').on('click', '#band-setup-photo-delete', function(evt) { evt.stopPropagation(); handleDeletePhoto(); return false; } );
$('#band-setup-photo-content-scroller').on('click', '#band-setup-photo-delete', function(evt) { evt.stopPropagation(); handleDeleteBandPhoto(); return false; } );
$('#band-setup-photo-content-scroller').on('click', '#band-setup-photo-cancel', function(evt) { evt.stopPropagation(); navToEditProfile(); return false; } );
$('#band-setup-photo-content-scroller').on('click', '#band-setup-photo-submit', function(evt) { evt.stopPropagation(); handleUpdatePhoto(); return false; } );
$('#band-setup-photo-content-scroller').on('click', '#band-setup-photo-submit', function(evt) { evt.stopPropagation(); handleUpdateBandPhoto(); return false; } );
//$('#band-setup-photo-content-scroller').on('change', 'input[type=filepicker-dragdrop]', function(evt) { evt.stopPropagation(); afterImageUpload(evt.originalEvent.fpfile); return false; } );
}

View File

@ -211,6 +211,12 @@
var cropped_fpfile = options['cropped_fpfile'];
var crop_selection = options['crop_selection'];
logger.debug(JSON.stringify({
original_fpfile : original_fpfile,
cropped_fpfile : cropped_fpfile,
crop_selection : crop_selection
}));
var url = "/api/users/" + id + "/avatar";
return $.ajax({
type: "POST",
@ -259,6 +265,12 @@
var cropped_fpfile = options['cropped_fpfile'];
var crop_selection = options['crop_selection'];
logger.debug(JSON.stringify({
original_fpfile : original_fpfile,
cropped_fpfile : cropped_fpfile,
crop_selection : crop_selection
}));
var url = "/api/bands/" + id + "/photo";
return $.ajax({
type: "POST",

View File

@ -5,7 +5,6 @@
<%= image_tag "shared/icon_session.png", {:height => 19, :width => 19} %>
</div>
<h1>session</h1>
<%= render "screen_navigation" %>
</div>
<!-- session controls -->