Update background image for JamClass VRFS-4018
This commit is contained in:
parent
b0ac61fbea
commit
5c246dc182
|
|
@ -264,6 +264,7 @@ module JamRuby
|
|||
|
||||
start_day = first_day
|
||||
if last_session
|
||||
puts "last session causing a scoot"
|
||||
start_day = last_session.scheduled_start.to_date + 1
|
||||
end
|
||||
|
||||
|
|
@ -276,7 +277,7 @@ module JamRuby
|
|||
times << time
|
||||
end
|
||||
end
|
||||
times
|
||||
{ times: times, session: sessions.first }
|
||||
end
|
||||
|
||||
def determine_needed_sessions(sessions)
|
||||
|
|
@ -457,13 +458,26 @@ module JamRuby
|
|||
end
|
||||
end
|
||||
|
||||
def distribution_price_in_cents
|
||||
def distribution_price_in_cents(target)
|
||||
if is_single_free?
|
||||
0
|
||||
elsif is_test_drive?
|
||||
10 * 100
|
||||
elsif is_normal?
|
||||
booked_price * 100
|
||||
if is_monthly_payment?
|
||||
raise "not a LessonPackagePurchase: #{target.inspect}" if !target.is_a?(LessonPackagePurchase)
|
||||
|
||||
today = Date.today
|
||||
|
||||
start_date = Date.new(target.year, target.month, 1)
|
||||
if today.year == target.year && today.month == target.month
|
||||
# we are in the month being billed. we should set the start date based on today
|
||||
start_date = today
|
||||
end
|
||||
LessonSessionMonthlyPrice.price(self, start_date) * 100
|
||||
else
|
||||
booked_price * 100
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -73,25 +73,44 @@ module JamRuby
|
|||
|
||||
def scheduled_times(needed_sessions, minimum_start_time)
|
||||
|
||||
#puts "NEEDED SESSIONS #{needed_sessions} #{minimum_start_time}"
|
||||
times = []
|
||||
week_offset = 0
|
||||
|
||||
needed_sessions.times do |i|
|
||||
candidate = scheduled_time(i + week_offset)
|
||||
|
||||
#puts "#{i}: candidate #{candidate} week_offset:#{week_offset}"
|
||||
if day_of_week && candidate <= minimum_start_time
|
||||
# move it up a week
|
||||
week_offset += 1
|
||||
candidate = scheduled_time(i + week_offset)
|
||||
|
||||
#puts "retry #1 #{candidate}"
|
||||
# sanity check
|
||||
if candidate <= minimum_start_time
|
||||
week_offset += 1
|
||||
candidate = scheduled_time(i + week_offset)
|
||||
|
||||
#puts "retry #2 #{candidate}"
|
||||
if candidate <= minimum_start_time
|
||||
raise "candidate time less than minimum start time even after scoot: #{lesson_booking.id} #{self.id}"
|
||||
|
||||
week_offset += 1
|
||||
candidate = scheduled_time(i + week_offset)
|
||||
|
||||
#puts "retry #3 #{candidate}"
|
||||
if candidate <= minimum_start_time
|
||||
|
||||
week_offset += 1
|
||||
candidate = scheduled_time(i + week_offset)
|
||||
|
||||
#puts "retry #4 #{candidate}"
|
||||
if candidate <= minimum_start_time
|
||||
raise "candidate time less than minimum start time even after scoot: #{lesson_booking.id} #{self.id}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
times << candidate
|
||||
|
|
|
|||
|
|
@ -71,6 +71,8 @@ module JamRuby
|
|||
|
||||
if lesson_booking && lesson_booking.requires_teacher_distribution?(purchase)
|
||||
purchase.teacher_distribution = TeacherDistribution.create_for_lesson_package_purchase(purchase)
|
||||
# price should always match the teacher_distribution, if there is one
|
||||
purchase.price = purchase.teacher_distribution.amount_in_cents / 100
|
||||
end
|
||||
else
|
||||
purchase.recurring = false
|
||||
|
|
@ -78,10 +80,10 @@ module JamRuby
|
|||
|
||||
if lesson_booking
|
||||
purchase.lesson_package_type = lesson_booking.lesson_package_type
|
||||
purchase.price = lesson_booking.booked_price # lesson_package_type.booked_price(lesson_booking)
|
||||
purchase.price = lesson_booking.booked_price if purchase.price.nil?
|
||||
else
|
||||
purchase.lesson_package_type = lesson_package_type
|
||||
purchase.price = lesson_package_type.price
|
||||
purchase.price = lesson_package_type.price if purchase.price.nil?
|
||||
end
|
||||
|
||||
purchase.save
|
||||
|
|
|
|||
|
|
@ -6,7 +6,22 @@ module JamRuby
|
|||
|
||||
raise "lesson_booking is not monthly paid #{lesson_booking.admin_url}" if !lesson_booking.is_monthly_payment?
|
||||
|
||||
times = lesson_booking.predicted_times_for_month(start_day.year, start_day.month)
|
||||
data = lesson_booking.predicted_times_for_month(start_day.year, start_day.month)
|
||||
|
||||
times = data[:times]
|
||||
session = data[:session]
|
||||
|
||||
true_start = start_day
|
||||
if session
|
||||
# if there is already a session for the month, that is the real star
|
||||
true_start = session.scheduled_start.to_date
|
||||
end
|
||||
|
||||
puts "filter out anything before start #{true_start}"
|
||||
# filter out anything before the start day
|
||||
times.select! { |time| time.to_date >= true_start }
|
||||
|
||||
puts "times #{times.length}"
|
||||
|
||||
result = nil
|
||||
if times.length == 0
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ module JamRuby
|
|||
distribution.teacher = target.teacher
|
||||
distribution.ready = false
|
||||
distribution.distributed = false
|
||||
distribution.amount_in_cents = target.lesson_booking.distribution_price_in_cents
|
||||
distribution.amount_in_cents = target.lesson_booking.distribution_price_in_cents(target)
|
||||
distribution
|
||||
end
|
||||
def amount
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 4.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.3 KiB |
|
|
@ -13,8 +13,11 @@
|
|||
opacity:0.6;
|
||||
}
|
||||
}
|
||||
.homecard.jamclass {
|
||||
background-image: url(/assets/content/bkg_home_jamclass.jpg);
|
||||
}
|
||||
.homecard.createsession {
|
||||
background-image: url(/assets/content/bkg_home_create.jpg);
|
||||
background-image: url(/assets/content/bkg_home_feed.jpg);
|
||||
}
|
||||
.homecard.createsession-disabled {
|
||||
cursor:default;
|
||||
|
|
@ -80,7 +83,7 @@
|
|||
background-color: #b32712;
|
||||
}
|
||||
.homecard.createsession.hover {
|
||||
background-image: url(/assets/content/bkg_home_create_x.jpg);
|
||||
background-image: url(/assets/content/bkg_home_feed_x.jpg);
|
||||
}
|
||||
.homecard.findsession.hover {
|
||||
background-image: url(/assets/content/bkg_home_find_x.jpg);
|
||||
|
|
@ -103,6 +106,6 @@
|
|||
.homecard.jamtrack.hover {
|
||||
background-image: url(/assets/content/bkg_home_jamtracks_x.jpg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
.homecard.jamclass.hover {
|
||||
background-image: url(/assets/content/bkg_home_jamclass_x.jpg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe "Book Monthly Recurring Lesson", :js => true, :type => :feature, :capybara_feature => true do
|
||||
describe "Book Single Recurring Lesson", :js => true, :type => :feature, :capybara_feature => true do
|
||||
|
||||
subject { page }
|
||||
|
||||
|
|
@ -8,8 +8,14 @@ describe "Book Monthly Recurring Lesson", :js => true, :type => :feature, :capyb
|
|||
let(:teacher_user) {FactoryGirl.create(:teacher_user, first_name: "Teacher1", ready_for_session_at: Time.now)}
|
||||
let(:teacher_user2) {FactoryGirl.create(:teacher_user, ready_for_session_at: Time.now)}
|
||||
|
||||
after(:each) do
|
||||
Timecop.return
|
||||
end
|
||||
|
||||
|
||||
before(:each) do
|
||||
|
||||
|
||||
LessonBooking.destroy_all
|
||||
Recording.delete_all
|
||||
Diagnostic.delete_all
|
||||
|
|
@ -22,22 +28,14 @@ describe "Book Monthly Recurring Lesson", :js => true, :type => :feature, :capyb
|
|||
|
||||
teacher_user.teacher.ready_for_session_at = Time.now
|
||||
teacher_user.teacher.save!
|
||||
|
||||
teacher_user.password.should eql 'foobar'
|
||||
teacher_user.teacher.price_per_lesson_60_cents.should eql 3000
|
||||
|
||||
Teacher.index(user, {})[:query].count.should eql 1
|
||||
|
||||
|
||||
end
|
||||
|
||||
def finish_lesson_successfully
|
||||
|
||||
end
|
||||
|
||||
describe "register via showing interesting in teacher 1st" do
|
||||
after(:each) do
|
||||
Timecop.return
|
||||
end
|
||||
|
||||
it "succeeds" do
|
||||
|
||||
visit "/client#/teachers/search"
|
||||
|
|
@ -70,6 +68,7 @@ describe "Book Monthly Recurring Lesson", :js => true, :type => :feature, :capyb
|
|||
lesson_booking.card_presumed_ok.should be_false
|
||||
lesson_booking.recurring.should be true
|
||||
lesson_booking.is_monthly_payment?.should be true
|
||||
|
||||
fill_in 'card-number', with: '4111111111111111'
|
||||
fill_in 'expiration', with: '11/2016'
|
||||
fill_in 'cvv', with: '111'
|
||||
|
|
@ -144,11 +143,11 @@ describe "Book Monthly Recurring Lesson", :js => true, :type => :feature, :capyb
|
|||
# dismiss banner
|
||||
find('a.button-orange', text:'CLOSE').trigger(:click)
|
||||
|
||||
|
||||
lesson_booking = LessonBooking.where(teacher_id: teacher_user2).first
|
||||
lesson_booking.should_not be_nil
|
||||
lesson_booking.recurring.should be false
|
||||
lesson_session = LessonSession.where(teacher_id: teacher_user2).first
|
||||
lesson_session.teacher.should eql teacher_user2
|
||||
LessonSession.where(teacher_id: teacher_user2).count.should eql 1
|
||||
|
||||
lesson_package_purchase = LessonPackagePurchase.where(user_id: user.id).first
|
||||
lesson_package_purchase.should be_nil
|
||||
|
|
@ -156,7 +155,57 @@ describe "Book Monthly Recurring Lesson", :js => true, :type => :feature, :capyb
|
|||
user.remaining_test_drives.should eql 0
|
||||
user.sales.count.should eql 0
|
||||
|
||||
finish_lesson_successfully
|
||||
|
||||
# approve by teacher:
|
||||
lesson_session1 = LessonSession.where(teacher_id: teacher_user).first
|
||||
teacher_approve(lesson_session1)
|
||||
|
||||
lesson_booking1 = LessonBooking.where(teacher_id: teacher_user).first
|
||||
lesson_booking1.lesson_sessions.count.should eql 2
|
||||
lesson_session2 = LessonSession.where(teacher_id: teacher_user).last
|
||||
|
||||
successful_lesson(lesson_session1)
|
||||
|
||||
LessonSession.hourly_check
|
||||
lesson_session1.reload
|
||||
lesson_session1.analysed.should be_true
|
||||
analysis = JSON.parse(lesson_session1.analysis)
|
||||
analysis["reason"].should eql LessonSessionAnalyser::SUCCESS
|
||||
lesson_session1.billing_attempts.should be_true
|
||||
lesson_session1.billed.should eql false
|
||||
lesson_session1.success.should be_true
|
||||
|
||||
user.lesson_purchases.count.should eql 0
|
||||
|
||||
LessonBooking.hourly_check
|
||||
|
||||
user.reload
|
||||
lesson_package_purchase = user.lesson_purchases.count.should eql 1
|
||||
lesson_package_purchase = user.lesson_purchases.first
|
||||
teacher_distribution = lesson_package_purchase.teacher_distribution
|
||||
teacher_distribution.amount_in_cents.should eql 3000 / 2
|
||||
teacher_distribution.ready.should be_true
|
||||
teacher_distribution.ready.should be_true
|
||||
|
||||
lesson_session1.reload
|
||||
lesson_session1.teacher_distribution.should be_nil
|
||||
|
||||
Timecop.travel(Date.new(2016, 05, 01))
|
||||
|
||||
LessonSession.hourly_check
|
||||
LessonBooking.hourly_check
|
||||
|
||||
user.reload
|
||||
user.lesson_purchases.count.should eql 2
|
||||
lesson_package_purchase = user.lesson_purchases.last
|
||||
teacher_distribution = lesson_package_purchase.teacher_distribution
|
||||
teacher_distribution.amount_in_cents.should eql 3000
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue