From f16bd28574cd09894ffd9fbd7ae51b73d284af5a Mon Sep 17 00:00:00 2001 From: Steven Miers Date: Tue, 19 May 2015 13:32:15 -0500 Subject: [PATCH] VRFS-3243 : Ability to selectively skip genre validation --- ruby/lib/jam_ruby/models/band.rb | 7 ++++--- web/app/assets/javascripts/band_setup.js | 13 +++++++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ruby/lib/jam_ruby/models/band.rb b/ruby/lib/jam_ruby/models/band.rb index e9fb548c0..a0c3a5033 100644 --- a/ruby/lib/jam_ruby/models/band.rb +++ b/ruby/lib/jam_ruby/models/band.rb @@ -9,7 +9,7 @@ module JamRuby :band_type, :band_status, :concert_count, :add_new_members, :play_commitment, :touring_option, :paid_gigs, :free_gigs, :hourly_rate, :gig_minimum - attr_accessor :updating_photo, :skip_location_validation + attr_accessor :updating_photo, :skip_location_validation, :skip_genre_validation self.primary_key = 'id' @@ -21,7 +21,7 @@ module JamRuby validates :city, presence: true, :unless => :skip_location_validation validate :validate_photo_info - validate :require_at_least_one_genre + validate :require_at_least_one_genre, :unless => :skip_genre_validation validate :limit_max_genres before_save :check_lat_lng @@ -199,7 +199,8 @@ module JamRuby band.genres = genres end - + band.skip_genre_validation = true unless params[:validate_genres] + puts "SKIPPING GENRE VALIDATION: #{band.skip_genre_validation}" band end diff --git a/web/app/assets/javascripts/band_setup.js b/web/app/assets/javascripts/band_setup.js index 429612727..d6cc2cd31 100644 --- a/web/app/assets/javascripts/band_setup.js +++ b/web/app/assets/javascripts/band_setup.js @@ -22,6 +22,8 @@ var nilOptionText = 'n/a'; var bandId = ''; var friendInput=null; + + // TODO: Use a single variable for a mutually exclusive option: var step1, step2; var isSaving = false; @@ -123,7 +125,13 @@ band.city = $("#band-city").val(); band.state = $("#band-region").val(); band.country = $("#band-country").val(); - band.genres = getSelectedGenres(); + + if (step2) { + band.genres = getSelectedGenres(); + band.validate_genres = true + } else { + band.validate_genres = false + } return band; } @@ -240,7 +248,6 @@ $("#band-setup-title").html("edit band"); $("#btn-band-setup-save").html("SAVE CHANGES"); $("#band-change-photo").html('Upload band photo.'); - //$("#name_row").after($("#tdBandPhoto")); $('.band-photo').removeClass("hidden") // retrieve and initialize band profile data points @@ -472,6 +479,8 @@ $("#band-setup-step-1").hide(); } else if (step1) { saveBand(); + step1=false + step2=true } }) .fail(function (jqXHR) {