* VRFS-1228 - can add, but not update ,user biography

This commit is contained in:
Seth Call 2014-02-25 05:41:43 +00:00
parent 051fcd8b04
commit 7753a2d4b3
8 changed files with 759 additions and 646 deletions

View File

@ -102,6 +102,7 @@ module JamRuby
validates :first_name, presence: true, length: {maximum: 50}, no_profanity: true
validates :last_name, presence: true, length: {maximum: 50}, no_profanity: true
validates :biography, length: {maximum: 4000}, no_profanity: true
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, presence: true, format: {with: VALID_EMAIL_REGEX}
validates :update_email, presence: true, format: {with: VALID_EMAIL_REGEX}, :if => :updating_email

View File

@ -232,7 +232,7 @@
}
}
else {
logger.error("Unexpected ajax error: " + textStatus + ", msg:" + errorMessage);
app.notify({title: textStatus, text: errorMessage, detail: jqXHR.responseText});
}
}
@ -293,6 +293,7 @@
if (jqXHR.status == 422) {
var errors = JSON.parse(jqXHR.responseText);
var $errors = context.JK.format_all_errors(errors);
console.log("$errors", $errors)
this.notify({title: title, text: $errors, icon_url: "/assets/content/icon_alert_big.png"})
}
else {

File diff suppressed because it is too large Load Diff

View File

@ -239,11 +239,14 @@
});
}
// Uber-simple templating
// var template = "Hey {name}";
// var vals = { name: "Jon" };
// _fillTemplate(template, vals);
// --> "Hey Jon"
//
// use context._.template for something more powerful
context.JK.fillTemplate = function(template, vals) {
for(var val in vals)
template=template.replace(new RegExp('{'+val+'}','g'), vals[val]);

View File

@ -1,5 +1,23 @@
@import "client/common.css.scss";
#user-profile {
#profile-biography {
a.enter-bio {
}
textarea {
width:100%;
height:150px;
padding:0;
}
.update-biography {
display:none;
}
}
}
.profile-head {
}

View File

@ -43,7 +43,7 @@ class ApiUsersController < ApiController
@user.update_instruments(params[:instruments].nil? ? [] : params[:instruments]) if params.has_key?(:instruments)
@user.show_whats_next = params[:show_whats_next] if params.has_key?(:show_whats_next)
@user.subscribe_email = params[:subscribe_email] if params.has_key?(:subscribe_email)
@user.biography = params[:biography] if params.has_key?(:biography)
@user.save
if @user.errors.any?

View File

@ -1,5 +1,5 @@
<!-- Profile -->
<div layout="screen" layout-id="profile" layout-arg="id" class="screen secondary">
<div layout="screen" layout-id="profile" layout-arg="id" class="screen secondary" id="user-profile">
<div class="content-head">
<div class="content-icon">
<%= image_tag "content/icon_profile.png", :size => "19x19" %>
@ -192,3 +192,24 @@
<div class="profile-block-city">{location}</div>
</div>
</script>
<script type="text/template" id="template-add-user-profile">
<div>
<span>You have no bio to describe yourself as a musician. <a href="#" class="enter-bio">Enter one now!</a></span>
<div class="update-biography">
<div class="field">
<textarea name="biography" class="user-biography"/>
</div>
<br clear="left" /><br />
<div class="right">
<a id="btn-update-user-biography" layout-action="close" class="button-orange">OK</a>
</div>
<div class="right">
<a id="btn-cancel-user-biography" layout-action="close" class="button-grey">CANCEL</a>
</div>
<br clear="all" />
</div>
<div>
</script>

View File

@ -135,6 +135,11 @@ def make_bands
state: state,
country: country,
)
Genre.order('RANDOM()').limit(rand(3)+1).each do |gg|
bb.genres << gg
end
begin
bb.save!
rescue