diff --git a/admin/app/views/admin/test_drive_packages/_test_drive_package_teacher_fields.html.slim b/admin/app/views/admin/test_drive_packages/_test_drive_package_teacher_fields.html.slim index 40039250b..fdb47b3ba 100644 --- a/admin/app/views/admin/test_drive_packages/_test_drive_package_teacher_fields.html.slim +++ b/admin/app/views/admin/test_drive_packages/_test_drive_package_teacher_fields.html.slim @@ -3,6 +3,6 @@ ol.nested-fields //= f.input :test_drive_package, :required=>true, value: @test_drive_package, include_blank: true = f.input :user, :required=>true, collection: User.where(is_a_teacher: true, phantom: false), include_blank: true - = f.input :short_bio + = f.input :short_bio_temp = link_to_remove_association "Delete Teacher", f, class: 'button', style: 'margin-left:10px' diff --git a/db/manifest b/db/manifest index 8a56701fd..685148214 100755 --- a/db/manifest +++ b/db/manifest @@ -356,4 +356,5 @@ remove_stripe_acct_id.sql track_user_on_lesson.sql audio_in_music_notations.sql lesson_time_tracking.sql -packaged_test_drive.sql \ No newline at end of file +packaged_test_drive.sql +packaged_test_drive2.sql \ No newline at end of file diff --git a/db/up/packaged_test_drive2.sql b/db/up/packaged_test_drive2.sql new file mode 100644 index 000000000..c5c7209c9 --- /dev/null +++ b/db/up/packaged_test_drive2.sql @@ -0,0 +1,2 @@ +ALTER TABLE lesson_booking_slots ADD COLUMN from_package BOOL DEFAULT FALSE; +ALTER TABLE lesson_bookings ADD COLUMN test_drive_package_choice_id VARCHAR(64) REFERENCES test_drive_package_choices(id); diff --git a/ruby/lib/jam_ruby/models/lesson_booking.rb b/ruby/lib/jam_ruby/models/lesson_booking.rb index ca52d8131..03268b051 100644 --- a/ruby/lib/jam_ruby/models/lesson_booking.rb +++ b/ruby/lib/jam_ruby/models/lesson_booking.rb @@ -45,6 +45,7 @@ module JamRuby belongs_to :default_slot, class_name: "JamRuby::LessonBookingSlot", foreign_key: :default_slot_id, inverse_of: :defaulted_booking, :dependent => :destroy belongs_to :counter_slot, class_name: "JamRuby::LessonBookingSlot", foreign_key: :counter_slot_id, inverse_of: :countered_booking, :dependent => :destroy belongs_to :school, class_name: "JamRuby::School" + belongs_to :test_drive_package_choice, class_name: "JamRuby::TestDrivePackageChoice" has_many :lesson_booking_slots, class_name: "JamRuby::LessonBookingSlot", :dependent => :destroy has_many :lesson_sessions, class_name: "JamRuby::LessonSession", :dependent => :destroy has_many :lesson_package_purchases, class_name: "JamRuby::LessonPackagePurchase", :dependent => :destroy @@ -139,6 +140,9 @@ module JamRuby booked_price end + def no_slots + default_slot.from_package + end def alt_slot found = nil @@ -193,12 +197,16 @@ module JamRuby self.counterer = proposer self.countered_at = Time.now self.sent_counter_reminder = false + + if self.default_slot.from_package + self.default_slot = slot + end #self.status = STATUS_COUNTERED self.save end def automatically_default_slot - if is_requested? + if is_requested? && default_slot.nil? if lesson_booking_slots.length > 0 self.default_slot = lesson_booking_slots[0] end @@ -680,8 +688,10 @@ module JamRuby end def validate_lesson_booking_slots - if lesson_booking_slots.length == 0 || lesson_booking_slots.length == 1 - errors.add(:lesson_booking_slots, "must have two times specified") + if test_drive_package_choice.nil? + if lesson_booking_slots.length == 0 || lesson_booking_slots.length == 1 + errors.add(:lesson_booking_slots, "must have two times specified") + end end end @@ -711,19 +721,22 @@ module JamRuby !!school end + def self.book_packaged_test_drive(user, teacher, description, test_drive_package_choice) + book_test_drive(user, teacher, LessonBookingSlot.packaged_slots, description, test_drive_package_choice) + end def self.book_free(user, teacher, lesson_booking_slots, description) self.book(user, teacher, LessonBooking::LESSON_TYPE_FREE, lesson_booking_slots, false, 30, PAYMENT_STYLE_ELSEWHERE, description) end - def self.book_test_drive(user, teacher, lesson_booking_slots, description) - self.book(user, teacher, LessonBooking::LESSON_TYPE_TEST_DRIVE, lesson_booking_slots, false, 30, PAYMENT_STYLE_ELSEWHERE, description) + def self.book_test_drive(user, teacher, lesson_booking_slots, description, test_drive_package_choice = nil) + self.book(user, teacher, LessonBooking::LESSON_TYPE_TEST_DRIVE, lesson_booking_slots, false, 30, PAYMENT_STYLE_ELSEWHERE, description, test_drive_package_choice) end def self.book_normal(user, teacher, lesson_booking_slots, description, recurring, payment_style, lesson_length) self.book(user, teacher, LessonBooking::LESSON_TYPE_PAID, lesson_booking_slots, recurring, lesson_length, payment_style, description) end - def self.book(user, teacher, lesson_type, lesson_booking_slots, recurring, lesson_length, payment_style, description) + def self.book(user, teacher, lesson_type, lesson_booking_slots, recurring, lesson_length, payment_style, description, test_drive_package_choice = nil) lesson_booking = nil LessonBooking.transaction do @@ -739,6 +752,7 @@ module JamRuby lesson_booking.payment_style = payment_style lesson_booking.description = description lesson_booking.status = STATUS_REQUESTED + lesson_booking.test_drive_package_choice = test_drive_package_choice if lesson_booking.teacher && lesson_booking.teacher.teacher.school lesson_booking.school = lesson_booking.teacher.teacher.school end diff --git a/ruby/lib/jam_ruby/models/lesson_booking_slot.rb b/ruby/lib/jam_ruby/models/lesson_booking_slot.rb index 6c64a39e6..d9d38ca47 100644 --- a/ruby/lib/jam_ruby/models/lesson_booking_slot.rb +++ b/ruby/lib/jam_ruby/models/lesson_booking_slot.rb @@ -74,6 +74,18 @@ module JamRuby (Time.now + APP_CONFIG.minimum_lesson_booking_hrs * 60 * 60) end + # create a canned slot for a TestDrivePackage. The most important thing here is that it expires in 30 days + def self.packaged_slots + slot = LessonBookingSlot.new + slot.from_package = true + slot.preferred_day = Date.today + 30 + slot.slot_type = LessonBookingSlot::SLOT_TYPE_SINGLE + slot.hour = 1 + slot.minute = 0 + slot.timezone = 'America/Chicago' + [slot] + end + def scheduled_times(needed_sessions, minimum_start_time) #puts "NEEDED SESSIONS #{needed_sessions} #{minimum_start_time}" diff --git a/ruby/lib/jam_ruby/models/lesson_package_purchase.rb b/ruby/lib/jam_ruby/models/lesson_package_purchase.rb index d0e592358..a38976b93 100644 --- a/ruby/lib/jam_ruby/models/lesson_package_purchase.rb +++ b/ruby/lib/jam_ruby/models/lesson_package_purchase.rb @@ -55,7 +55,7 @@ module JamRuby def to_s - "#{name} (#{amount_charged})" + "#{name}" end def name diff --git a/ruby/lib/jam_ruby/models/lesson_session.rb b/ruby/lib/jam_ruby/models/lesson_session.rb index e4225be2e..13f47819f 100644 --- a/ruby/lib/jam_ruby/models/lesson_session.rb +++ b/ruby/lib/jam_ruby/models/lesson_session.rb @@ -66,7 +66,6 @@ module JamRuby validate :validate_canceled, :if => :canceling validate :validate_autocancel, :if => :autocanceling - after_save :after_counter, :if => :countering after_save :manage_slot_changes after_create :create_charge @@ -444,10 +443,6 @@ module JamRuby self.lesson_booking.save(:validate => false) end - def after_counter - send_counter(@countered_lesson, @countered_slot) - end - def scheduled_start if music_session music_session.scheduled_start @@ -458,10 +453,12 @@ module JamRuby end def send_counter(countered_lesson, countered_slot) - if countered_slot.is_teacher_created? - UserMailer.student_lesson_counter(countered_lesson, countered_slot).deliver - else - UserMailer.teacher_lesson_counter(countered_lesson, countered_slot).deliver + if !lesson_booking.errors.any? + if countered_slot.is_teacher_created? + UserMailer.student_lesson_counter(countered_lesson, countered_slot).deliver + else + UserMailer.teacher_lesson_counter(countered_lesson, countered_slot).deliver + end end self.countering = false end @@ -522,6 +519,7 @@ module JamRuby self.countering_flag = false end + def validate_accepted if self.status_was != STATUS_REQUESTED && self.status_was != STATUS_COUNTERED self.errors.add(:status, "This session is already #{self.status_was}.") @@ -632,7 +630,7 @@ module JamRuby # if the school owner is a teacher, show his bookings too extra_teacher = " OR lesson_sessions.teacher_id = '#{user.teacher.id}'" end - query = query.where('lesson_sessions.teacher_id in (?)' + extra_teacher, user.owned_school.teachers.map {|t| t.user.id}) + query = query.where('lesson_sessions.teacher_id in (?)' + extra_teacher, user.owned_school.teachers.map { |t| t.user.id }) query = query.where('lesson_sessions.status = ? OR lesson_sessions.status = ?', LessonSession::STATUS_REQUESTED, LessonSession::STATUS_COUNTERED) else # this is a normal teacher (not a school owner) @@ -819,7 +817,7 @@ module JamRuby self.countered_lesson = self self.status = STATUS_COUNTERED #if !update_all - self.counter_slot = slot + self.counter_slot = slot #end if self.save #if update_all && !lesson_booking.counter(self, proposer, slot) @@ -832,6 +830,7 @@ module JamRuby raise ActiveRecord::Rollback end + send_counter(@countered_lesson, @countered_slot) message = '' if message.nil? msg = ChatMessage.create(slot.proposer, music_session, message, ChatMessage::CHANNEL_LESSON, nil, slot.recipient, self, "New Time Proposed") Notification.send_lesson_message('counter', self, slot.is_teacher_created?) diff --git a/ruby/lib/jam_ruby/models/test_drive_package.rb b/ruby/lib/jam_ruby/models/test_drive_package.rb index d85f1b086..bfdbd138f 100644 --- a/ruby/lib/jam_ruby/models/test_drive_package.rb +++ b/ruby/lib/jam_ruby/models/test_drive_package.rb @@ -13,6 +13,9 @@ module JamRuby #validate :teacher_count + def lesson_package_type + LessonPackageType.package_for_test_drive_count(package_type.to_i) + end def teacher_count if package_type != test_drive_package_teachers.length self.errors.add(:test_drive_package_teachers, "wrong number of teachers specified for the given package type #{package_type}") diff --git a/ruby/lib/jam_ruby/models/test_drive_package_choice.rb b/ruby/lib/jam_ruby/models/test_drive_package_choice.rb index 569e1e352..17e9eec87 100644 --- a/ruby/lib/jam_ruby/models/test_drive_package_choice.rb +++ b/ruby/lib/jam_ruby/models/test_drive_package_choice.rb @@ -5,9 +5,9 @@ module JamRuby @@log = Logging.logger[TestDrivePackageChoice] belongs_to :test_drive_package, class_name: "JamRuby::TestDrivePackage" - belongs_to :user, class_name: "JamRuby::User" - has_many :test_drive_package_choice_teachers, class_name: "JamRuby::TestDrivePackageChoiceTeacher", foreign_key: :teacher_id - + belongs_to :user, class_name: "JamRuby::User", foreign_key: :user_id, inverse_of: :test_drive_package_choices + has_many :test_drive_package_choice_teachers, class_name: "JamRuby::TestDrivePackageChoiceTeacher", inverse_of: :test_drive_package_choice + has_many :lesson_bookings, class_name: "JamRuby::LessonBooking" end end diff --git a/ruby/lib/jam_ruby/models/test_drive_package_choice_teacher.rb b/ruby/lib/jam_ruby/models/test_drive_package_choice_teacher.rb index 02397f886..356880073 100644 --- a/ruby/lib/jam_ruby/models/test_drive_package_choice_teacher.rb +++ b/ruby/lib/jam_ruby/models/test_drive_package_choice_teacher.rb @@ -4,7 +4,7 @@ module JamRuby @@log = Logging.logger[TestDrivePackageChoiceTeacher] - belongs_to :test_drive_package_choice, class_name: "JamRuby::TestDrivePackageChoice" + belongs_to :test_drive_package_choice, class_name: "JamRuby::TestDrivePackageChoice", inverse_of: :test_drive_package_choice_teachers belongs_to :teacher, class_name: "JamRuby::User", foreign_key: :teacher_id end diff --git a/ruby/lib/jam_ruby/models/test_drive_package_teacher.rb b/ruby/lib/jam_ruby/models/test_drive_package_teacher.rb index ab5d29fcf..2b0208189 100644 --- a/ruby/lib/jam_ruby/models/test_drive_package_teacher.rb +++ b/ruby/lib/jam_ruby/models/test_drive_package_teacher.rb @@ -4,8 +4,8 @@ module JamRuby @@log = Logging.logger[TestDrivePackageTeacher] - attr_accessor :short_bio_temp - attr_accessible :user_id, :test_drive_package_id, :short_bio, as: :admin + attr_writer :short_bio_temp + attr_accessible :user_id, :test_drive_package_id, :short_bio, :short_bio_temp, as: :admin belongs_to :test_drive_package, class_name: "JamRuby::TestDrivePackage" belongs_to :user, class_name: "JamRuby::User" @@ -18,12 +18,19 @@ module JamRuby # silly pass through for activeadmin. We pass short_bio set here on to teacher def after_save if user && user.teacher - user.teacher.short_bio = short_bio - user.teacher.save! + if @another_bio.present? + user.teacher.short_bio = @another_bio + user.teacher.save! + end end end - def short_bio + def short_bio_temp=(short_bio) + self.updated_at = Time.now + self.short_bio = short_bio + @another_bio = short_bio + end + def short_bio_temp if user && user.teacher user.teacher.short_bio end diff --git a/ruby/lib/jam_ruby/models/user.rb b/ruby/lib/jam_ruby/models/user.rb index ad92ac057..2fe371f8b 100644 --- a/ruby/lib/jam_ruby/models/user.rb +++ b/ruby/lib/jam_ruby/models/user.rb @@ -41,7 +41,7 @@ module JamRuby attr_accessible :first_name, :last_name, :email, :city, :password, :password_confirmation, :state, :country, :birth_date, :subscribe_email, :terms_of_service, :original_fpfile, :cropped_fpfile, :cropped_large_fpfile, :cropped_s3_path, :cropped_large_s3_path, :photo_url, :large_photo_url, :crop_selection # updating_password corresponds to a lost_password - attr_accessor :validate_instruments, :updating_password, :updating_email, :updated_email, :update_email_confirmation_url, :administratively_created, :current_password, :setting_password, :confirm_current_password, :updating_avatar, :updating_progression_field, :mods_json, :expecting_gift_card + attr_accessor :test_drive_packaging, :validate_instruments, :updating_password, :updating_email, :updated_email, :update_email_confirmation_url, :administratively_created, :current_password, :setting_password, :confirm_current_password, :updating_avatar, :updating_progression_field, :mods_json, :expecting_gift_card belongs_to :icecast_server_group, class_name: "JamRuby::IcecastServerGroup", inverse_of: :users, foreign_key: 'icecast_server_group_id' @@ -176,6 +176,8 @@ module JamRuby has_many :teacher_lesson_bookings, :class_name => "JamRuby::LessonBooking", :foreign_key => "teacher_id", inverse_of: :teacher has_many :teacher_distributions, :class_name => "JamRuby::TeacherDistribution", :foreign_key => "teacher_id", inverse_of: :teacher has_many :teacher_payments, :class_name => "JamRuby::TeacherPayment", :foreign_key => "teacher_id", inverse_of: :teacher + has_many :test_drive_package_choice_teachers, :class_name => "JamRuby::TestDrivePackageChoiceTeacher", :foreign_key => "teacher_id" + has_many :test_drive_package_choices, :class_name => "JamRuby::TestDrivePackageChoice", :foreign_key => "user_id", inverse_of: :user belongs_to :desired_package, :class_name => "JamRuby::LessonPackageType", :foreign_key => "lesson_package_type_id", inverse_of: :user_desired_packages # used to hold whether user last wanted test drive 4/2/1 # Shopping carts @@ -203,7 +205,7 @@ module JamRuby has_many :taught_lessons, :class_name => "JamRuby::LessonSession", inverse_of: :teacher, foreign_key: :teacher_id belongs_to :school, :class_name => "JamRuby::School", inverse_of: :students has_one :owned_school, :class_name => "JamRuby::School", inverse_of: :user - + has_many :test_drive_package_choices, :class_name =>"JamRuby::TestDrivePackageChoice" has_many :jamblasters_users, class_name: "JamRuby::JamblasterUser" has_many :jamblasters, class_name: 'JamRuby::Jamblaster', through: :jamblasters_users @@ -1076,6 +1078,27 @@ module JamRuby end end + def handle_test_drive_package(package, details) + self.test_drive_packaging = true + choice = TestDrivePackageChoice.new + choice.user = self + choice.test_drive_package = package + details[:teachers].each do |teacher| + teacher_choice = TestDrivePackageChoiceTeacher.new + teacher_choice.teacher = User.find(teacher[:id]) + choice.test_drive_package_choice_teachers << teacher_choice + end + + choice.save! + + choice.test_drive_package_choice_teachers.each do |teacher_choice| + booking = LessonBooking.book_packaged_test_drive(self, teacher_choice.teacher, "Please suggest a time that works for you.", choice) + if booking.errors.any? + raise "unable to create booking in package user:#{self.email}" + end + end + end + # throws ActiveRecord::RecordNotFound if instrument is invalid # throws an email delivery error if unable to connect out to SMTP def self.signup(options) @@ -1107,6 +1130,9 @@ module JamRuby school_id = options[:school_id] school_interest = options[:school_interest] origin = options[:origin] + test_drive_package_details = options[:test_drive_package] + + test_drive_package = TestDrivePackage.find_by_name(test_drive_package_details[:name]) school = School.find(school_id) if school_id user = User.new @@ -1351,6 +1377,7 @@ module JamRuby user.save end if affiliate_referral_id.present? + user.handle_test_drive_package(test_drive_package, test_drive_package_details) if test_drive_package if user.is_a_student UserMailer.student_welcome_message(user).deliver @@ -1981,9 +2008,10 @@ module JamRuby customer end - def card_approved(token, zip, booking_id) + def card_approved(token, zip, booking_id, test_drive_package_choice_id = nil) approved_booking = nil + choice = nil found_uncollectables = nil User.transaction do self.stripe_token = token if token @@ -1999,6 +2027,13 @@ module JamRuby end end + if test_drive_package_choice_id + choice = TestDrivePackageChoice.find(test_drive_package_choice_id) + choice.lesson_bookings.each do|booking| + booking.card_approved + end + end + if uncollectables.count > 0 found_uncollectables = uncollectables uncollectables.update_all(billing_should_retry: true) @@ -2007,7 +2042,7 @@ module JamRuby end end end - [approved_booking, found_uncollectables] + [approved_booking, found_uncollectables, choice] end def update_name(name) @@ -2038,6 +2073,7 @@ module JamRuby purchase = nil lesson_package_type = nil uncollectables = nil + choice = nil User.transaction do if params[:name].present? @@ -2046,12 +2082,15 @@ module JamRuby end end - booking, uncollectables = card_approved(params[:token], params[:zip], params[:booking_id]) + booking, uncollectables, choice = card_approved(params[:token], params[:zip], params[:booking_id], params[:test_drive_package_choice_id]) if params[:test_drive] self.reload if booking lesson_package_type = booking.resolved_test_drive_package + elsif choice + choice.test_drive_package.lesson_package_type end + if lesson_package_type.nil? lesson_package_type = LessonPackageType.test_drive_4 end @@ -2071,7 +2110,7 @@ module JamRuby end - {lesson: booking, test_drive: test_drive, purchase: purchase, lesson_package_type: lesson_package_type, uncollectables: uncollectables} + {lesson: booking, test_drive: test_drive, purchase: purchase, lesson_package_type: lesson_package_type, uncollectables: uncollectables, package: choice} end def requested_test_drive(teacher = nil) diff --git a/ruby/spec/factories.rb b/ruby/spec/factories.rb index 893a4a2b5..86dbaeb1f 100644 --- a/ruby/spec/factories.rb +++ b/ruby/spec/factories.rb @@ -108,6 +108,7 @@ FactoryGirl.define do association :user, factory: :user price_per_lesson_60_cents 3000 price_per_month_60_cents 3000 + short_bio 'abc def uueue doc neck' end factory :musician_instrument, :class => JamRuby::MusicianInstrument do diff --git a/ruby/spec/jam_ruby/models/user_spec.rb b/ruby/spec/jam_ruby/models/user_spec.rb index 6a40ce0bc..41ec0b1b8 100644 --- a/ruby/spec/jam_ruby/models/user_spec.rb +++ b/ruby/spec/jam_ruby/models/user_spec.rb @@ -905,6 +905,30 @@ describe User do uncollectable.is_card_declined?.should be_false end end + describe "handle_test_drive_package" do + let(:user) {FactoryGirl.create(:user)} + + it "4-count" do + package_size = 4 + package = FactoryGirl.create(:test_drive_package, :four_pack) + detail = {} + teachers = [] + detail[:teachers] = teachers + package.test_drive_package_teachers.each do |package_teacher| + teachers << {id: package_teacher.user.id} + end + user.handle_test_drive_package(package, detail) + + user.errors.any?.should be_false + + LessonSession.where(user_id: user.id).count.should eql package_size + user.student_lesson_bookings.count.should eql package_size + user.student_lesson_bookings.each do |booking| + booking.status.should eql LessonBooking::STATUS_REQUESTED + booking.card_presumed_ok.should be_false + end + end + end =begin describe "update avatar" do diff --git a/web/app/assets/javascripts/everywhere/everywhere.js b/web/app/assets/javascripts/everywhere/everywhere.js index a6e5a721d..29eba67cd 100644 --- a/web/app/assets/javascripts/everywhere/everywhere.js +++ b/web/app/assets/javascripts/everywhere/everywhere.js @@ -271,7 +271,6 @@ var show = false; - console.log("data.newScreen", data.newScreen) if (data.newScreen && activate.indexOf(data.newScreen) > -1) { show = true; } diff --git a/web/app/assets/javascripts/helpBubbleHelper.js b/web/app/assets/javascripts/helpBubbleHelper.js index df99b0bac..ea23a8f73 100644 --- a/web/app/assets/javascripts/helpBubbleHelper.js +++ b/web/app/assets/javascripts/helpBubbleHelper.js @@ -237,6 +237,8 @@ } helpBubble.testDrivePackageGo = function($element, $offsetParent, package_type) { - return context.JK.prodBubble($element, 'test-drive-package-go', {plural: package_type != '1'}, bigHelpDarkOptions({offsetParent:$offsetParent, width:260, positions:['bottom']})) + return context.JK.prodBubble($element, 'test-drive-package-go', {plural: package_type != '1'}, bigHelpDarkOptions({offsetParent:$offsetParent, width:300, duration:13000, positions:['bottom'], postShow: function(container) { + subtlePulse(container) + }})) } })(window, jQuery); \ No newline at end of file diff --git a/web/app/assets/javascripts/jam_rest.js b/web/app/assets/javascripts/jam_rest.js index 1c00aac3e..bd8dd4f7a 100644 --- a/web/app/assets/javascripts/jam_rest.js +++ b/web/app/assets/javascripts/jam_rest.js @@ -2133,6 +2133,15 @@ }) } + function getTestDrivePackageChoice(options) { + options = options || {} + return $.ajax({ + type: "GET", + url: '/api/test_drive_package_choice/' + options.id, + dataType: "json", + contentType: 'application/json' + }) + } function getLessonBooking(options) { options = options || {} @@ -2717,6 +2726,7 @@ this.portOverCarts = portOverCarts; this.bookLesson = bookLesson; this.attachRecordingToLesson = attachRecordingToLesson; + this.getTestDrivePackageChoice = getTestDrivePackageChoice; this.getLessonBooking = getLessonBooking; this.getUnprocessedLesson = getUnprocessedLesson; this.getUnprocessedLessonOrIntent = getUnprocessedLessonOrIntent; diff --git a/web/app/assets/javascripts/landing/landing.js b/web/app/assets/javascripts/landing/landing.js index de23401db..3cc86db70 100644 --- a/web/app/assets/javascripts/landing/landing.js +++ b/web/app/assets/javascripts/landing/landing.js @@ -20,6 +20,9 @@ //= require jquery.ba-bbq //= require jquery.icheck //= require jquery.exists +//= require jquery.manageVsts +//= require jquery.lessonSessionActions +//= require ResizeSensor //= require AAA_Log //= require AAC_underscore //= require alert @@ -35,6 +38,7 @@ //= require ui_helper //= require jam_rest //= require ga +//= require recordingModel //= require web/signup_helper //= require web/signin_helper //= require web/signin diff --git a/web/app/assets/javascripts/react-components/JamClassScreen.js.jsx.coffee b/web/app/assets/javascripts/react-components/JamClassScreen.js.jsx.coffee index 2c68b006b..dd0a7227d 100644 --- a/web/app/assets/javascripts/react-components/JamClassScreen.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/JamClassScreen.js.jsx.coffee @@ -114,7 +114,10 @@ LessonTimerActions = context.LessonTimerActions text: "Start time for session set to 65 mins ago" }))) else if data.lessonAction == 'enter-payment' - window.location.href = "/client#/jamclass/lesson-payment/lesson-booking_#{lessonId}" + if lesson.lesson_booking.test_drive_package_choice_id? + window.location.href = "/client#/jamclass/lesson-payment/package_#{lesson.lesson_booking.test_drive_package_choice_id}" + else + window.location.href = "/client#/jamclass/lesson-payment/lesson-booking_#{lessonId}" else context.JK.showAlert('unknown lesson action', 'The option in the menu is unknown') @@ -527,7 +530,10 @@ LessonTimerActions = context.LessonTimerActions else unreadMessages = null - if lessonData.status == 'countered' + if lessonData.lesson_booking.no_slots + timeStmt = 'No time has been scheduled yet' + + else if lessonData.status == 'countered' timeStmt = lessonData.counter_slot.pretty_scheduled_start_with_timezone else timeStmt = lessonData.music_session.pretty_scheduled_start_with_timezone diff --git a/web/app/assets/javascripts/react-components/LessonBooking.js.jsx.coffee b/web/app/assets/javascripts/react-components/LessonBooking.js.jsx.coffee index 023b9a66b..5d09da185 100644 --- a/web/app/assets/javascripts/react-components/LessonBooking.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/LessonBooking.js.jsx.coffee @@ -50,6 +50,10 @@ UserStore = context.UserStore slot.creatorRoleRelative = "your" slot.mySlot = @mySlot(slot) + # for a test drive packaged delai, while we do create a slot to satisfy certain aspects of the backend, it's not 'real'. So we say 'noSlots' until someone has proposed something + noSlots: () -> + @state.booking?.no_slots + processBooking:(booking) -> booking.neverAccepted = booking.accepter_id? booking.isCounter = booking.counter_slot? && booking.status != 'canceled' && booking.status != 'suspended' @@ -58,6 +62,7 @@ UserStore = context.UserStore booking.isRequested = booking.status == 'requested' && !booking.isCounter booking.isCanceled = booking.status == 'canceled' booking.isSuspended = booking.status == 'suspended' + if booking.isCounter if booking.counter_slot['is_teacher_created?'] booking.countererId = booking.teacher_id @@ -472,7 +477,10 @@ UserStore = context.UserStore selfLastToAct: () -> if @isRequested() - @studentViewing() + if @isCounter() + @counterer().id == @myself().id + else + @studentViewing() else if @isCounter() @counterer().id == @myself().id else if @isCanceled() @@ -647,7 +655,8 @@ UserStore = context.UserStore selfLastToAct: this.selfLastToAct(), counterErrors: this.state.counterErrors, cancelErrors: this.state.cancelErrors, - focusedLesson: this.focusedLesson() + focusedLesson: this.focusedLesson(), + noSlots: this.noSlots() } render: () -> @@ -813,9 +822,15 @@ UserStore = context.UserStore createDetail: () -> if @hasFocusedLesson() || !@isRecurring() if @onlyOption() && @rescheduling() - detail = `
You are proposing to change the date/time of the lesson currently scheduled for {this.slotTime(this.state.booking.default_slot)}
` + if @noSlots() + detail = `You are proposing a date/time for this lesson.
` + else + detail = `You are proposing to change the date/time of the lesson currently scheduled for {this.slotTime(this.state.booking.default_slot)}
` else - detail = `Your {this.lessonDesc()} will take place this {this.slotTime(this.state.booking.default_slot)}
` + if @noSlots() + detail = `Your lesson has no scheduled time yet.
` + else + detail = `Your {this.lessonDesc()} will take place this {this.slotTime(this.state.booking.default_slot)}
` else if @onlyOption() && @rescheduling() detail = `You are proposing to change the date/time of the lesson currently scheduled for {this.slotTime(this.state.booking.default_slot)}
` @@ -916,13 +931,20 @@ UserStore = context.UserStore else action = `Has requested a {this.lessonDesc()} lesson, for which you will be paid {this.lessonPaymentAmt()}.
` + + if @noSlots() + slots = [] + else + slots = [this.state.booking.default_slot] + if this.state.booking.alt_slot? + slots.push(this.state.booking.alt_slot) `{explanation} diff --git a/web/app/assets/javascripts/react-components/TestDrivePackageDialog.js.jsx.coffee b/web/app/assets/javascripts/react-components/TestDrivePackageDialog.js.jsx.coffee index 1f2a7f893..26dfcaea1 100644 --- a/web/app/assets/javascripts/react-components/TestDrivePackageDialog.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/TestDrivePackageDialog.js.jsx.coffee @@ -22,13 +22,33 @@ context = window getInitialState: () -> { - target: null, - page_data: null + target: null, + page_data: null } componentDidMount: () -> @root = $(@getDOMNode()) + @dialog = @root.closest('.dialog') + + renderTeacher: (teacher) -> + photo_url = '/assets/shared/avatar_generic.png' + if teacher.photo_url? + photo_url = teacher.photo_url + + `
- Check the boxes under the 2 instructors you want to select for your TestDrive package. Then click the Select button below. + Check the boxes under the 2 instructors you want to select for your TestDrive package. Then click the Select + button below.
` else - help = + help = `- Check the box under the instructor you want to select for your TestDrive package. Then click the Select button below. + Check the box under the instructor you want to select for your TestDrive package. Then click the Select button + below.
` teachers = [] + if @state.page_data?.package?.teachers? + for teacher in @state.page_data.package.teachers + teachers.push(@renderTeacher(teacher)) + teacherHolderClasses = {"teacher-holder" : true, "two": teachers.length == 2, "four": teachers.length == 4} + dialogInnerClasses = {"dialog-inner": true, "two": teachers.length == 2, "four": teachers.length == 4} `Like the TestDrive concept, but 4 teachers is too many for you?
Sign up for this amazing TestDrive offer now!
+When you sign up below, we will ask you to pay for your TestDrive package, and then we'll forward + your lesson requests to these teachers for scheduling.
+ +We will not share your email. See our privacy + policy
+ {register} +We'll give you 1:1 help to get set up and ready to go with our free app.
+Sign up now. You have no obligation to buy anything. Signing up makes you eligible for our TestDrive + offers.
+ +After signing up, you can search our community of world-class instructors. If you book a TestDrive lesson + you can choose to TestDrive 4, 2, or 1 teachers at that time.
+ +We will not share your email. See our privacy + policy
+ {register} +And pick your teachers now!
+ +We'll give you 1:1 help to get set up and ready to go with our free app.
+Sign up now. You have no obligation to buy anything. Signing up makes you eligible for our TestDrive - offers.
- -After signing up, you can search our community of world-class instructors. If you book a TestDrive lesson - you can choose to TestDrive 4, 2, or 1 teachers at that time.
- -We will not share your email. See our privacy - policy
- {register} -And pick your teachers now!
- -We'll give you 1:1 help to get set up and ready to go with our free app.
-