VRFS-3359 : Update schema and models with per-month and per-lesson price for each interval. Update tests to match.

This commit is contained in:
Steven Miers 2015-09-03 01:53:28 -05:00
parent 8ce313f5c7
commit 3f2fd94c58
3 changed files with 64 additions and 54 deletions

View File

@ -1,30 +1,33 @@
CREATE TABLE teachers (
id VARCHAR(64) PRIMARY KEY DEFAULT uuid_generate_v4(),
user_id VARCHAR(64) REFERENCES users(id) ON DELETE CASCADE,
introductory_video VARCHAR(1024) NULL,
years_teaching SMALLINT NOT NULL DEFAULT 0,
years_playing SMALLINT NOT NULL DEFAULT 0,
teaches_age_lower SMALLINT NOT NULL DEFAULT 0,
teaches_age_upper SMALLINT NOT NULL DEFAULT 0,
teaches_beginner BOOLEAN NOT NULL DEFAULT FALSE,
teaches_intermediate BOOLEAN NOT NULL DEFAULT FALSE,
teaches_advanced BOOLEAN NOT NULL DEFAULT FALSE,
website VARCHAR(1024) NULL,
biography VARCHAR(4096) NULL,
prices_per_lesson BOOLEAN NOT NULL DEFAULT FALSE,
prices_per_month BOOLEAN NOT NULL DEFAULT FALSE,
lesson_duration_30 BOOLEAN NOT NULL DEFAULT FALSE,
lesson_duration_45 BOOLEAN NOT NULL DEFAULT FALSE,
lesson_duration_60 BOOLEAN NOT NULL DEFAULT FALSE,
lesson_duration_90 BOOLEAN NOT NULL DEFAULT FALSE,
lesson_duration_120 BOOLEAN NOT NULL DEFAULT FALSE,
price_per_lesson_cents INT NULL,
price_per_month_cents INT NULL,
price_duration_30_cents INT NULL,
price_duration_45_cents INT NULL,
price_duration_60_cents INT NULL,
price_duration_90_cents INT NULL,
price_duration_120_cents INT NULL,
user_id VARCHAR(64) REFERENCES users(id) ON DELETE CASCADE,
introductory_video VARCHAR(1024) NULL,
years_teaching SMALLINT NOT NULL DEFAULT 0,
years_playing SMALLINT NOT NULL DEFAULT 0,
teaches_age_lower SMALLINT NOT NULL DEFAULT 0,
teaches_age_upper SMALLINT NOT NULL DEFAULT 0,
teaches_beginner BOOLEAN NOT NULL DEFAULT FALSE,
teaches_intermediate BOOLEAN NOT NULL DEFAULT FALSE,
teaches_advanced BOOLEAN NOT NULL DEFAULT FALSE,
website VARCHAR(1024) NULL,
biography VARCHAR(4096) NULL,
prices_per_lesson BOOLEAN NOT NULL DEFAULT FALSE,
prices_per_month BOOLEAN NOT NULL DEFAULT FALSE,
lesson_duration_30 BOOLEAN NOT NULL DEFAULT FALSE,
lesson_duration_45 BOOLEAN NOT NULL DEFAULT FALSE,
lesson_duration_60 BOOLEAN NOT NULL DEFAULT FALSE,
lesson_duration_90 BOOLEAN NOT NULL DEFAULT FALSE,
lesson_duration_120 BOOLEAN NOT NULL DEFAULT FALSE,
price_per_lesson_30_cents INT NULL,
price_per_lesson_45_cents INT NULL,
price_per_lesson_60_cents INT NULL,
price_per_lesson_90_cents INT NULL,
price_per_lesson_120_cents INT NULL,
price_per_month_30_cents INT NULL,
price_per_month_45_cents INT NULL,
price_per_month_60_cents INT NULL,
price_per_month_90_cents INT NULL,
price_per_month_120_cents INT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
@ -48,7 +51,7 @@ CREATE TABLE teacher_experiences(
name VARCHAR(200) NOT NULL,
organization VARCHAR(200) NOT NULL,
start_year SMALLINT NOT NULL DEFAULT 0,
end_year SMALLINT NOT NULL DEFAULT 0
end_year SMALLINT NULL
);
-- Has many/through tables:

View File

@ -67,13 +67,16 @@ module JamRuby
teacher.lesson_duration_60 = params[:lesson_duration_60] if params.key?(:lesson_duration_60)
teacher.lesson_duration_90 = params[:lesson_duration_90] if params.key?(:lesson_duration_90)
teacher.lesson_duration_120 = params[:lesson_duration_120] if params.key?(:lesson_duration_120)
teacher.price_per_lesson_cents = params[:price_per_lesson_cents] if params.key?(:price_per_lesson_cents)
teacher.price_per_month_cents = params[:price_per_month_cents] if params.key?(:price_per_month_cents)
teacher.price_duration_30_cents = params[:price_duration_30_cents] if params.key?(:price_duration_30_cents)
teacher.price_duration_45_cents = params[:price_duration_45_cents] if params.key?(:price_duration_45_cents)
teacher.price_duration_60_cents = params[:price_duration_60_cents] if params.key?(:price_duration_60_cents)
teacher.price_duration_90_cents = params[:price_duration_90_cents] if params.key?(:price_duration_90_cents)
teacher.price_duration_120_cents = params[:price_duration_120_cents] if params.key?(:price_duration_120_cents)
teacher.price_per_lesson_30_cents = params[:price_per_lesson_30_cents] if params.key?(:price_per_lesson_30_cents)
teacher.price_per_lesson_45_cents = params[:price_per_lesson_45_cents] if params.key?(:price_per_lesson_45_cents)
teacher.price_per_lesson_60_cents = params[:price_per_lesson_60_cents] if params.key?(:price_per_lesson_60_cents)
teacher.price_per_lesson_90_cents = params[:price_per_lesson_90_cents] if params.key?(:price_per_lesson_90_cents)
teacher.price_per_lesson_120_cents = params[:price_per_lesson_120_cents] if params.key?(:price_per_lesson_120_cents)
teacher.price_per_month_30_cents = params[:price_per_month_30_cents] if params.key?(:price_per_month_30_cents)
teacher.price_per_month_45_cents = params[:price_per_month_45_cents] if params.key?(:price_per_month_45_cents)
teacher.price_per_month_60_cents = params[:price_per_month_60_cents] if params.key?(:price_per_month_60_cents)
teacher.price_per_month_90_cents = params[:price_per_month_90_cents] if params.key?(:price_per_month_90_cents)
teacher.price_per_month_120_cents = params[:price_per_month_120_cents] if params.key?(:price_per_month_120_cents)
# Many-to-many relations:
teacher.genres = params[:genres].collect{|genre_id|Genre.find(genre_id)} if params[:genres].present?

View File

@ -144,13 +144,16 @@ describe Teacher do
lesson_duration_60: true,
lesson_duration_90: true,
lesson_duration_120: true,
price_per_lesson_cents: 3000,
price_per_month_cents: 3000,
price_duration_30_cents: 3000,
price_duration_45_cents: 3000,
price_duration_60_cents: 3000,
price_duration_90_cents: 3000,
price_duration_120_cents: 3000
price_per_lesson_30_cents: 3000,
price_per_lesson_45_cents: 3000,
price_per_lesson_60_cents: 3000,
price_per_lesson_90_cents: 3000,
price_per_lesson_120_cents: 3000,
price_per_month_30_cents: 5000,
price_per_month_45_cents: 5000,
price_per_month_60_cents: 5000,
price_per_month_90_cents: 5000,
price_per_month_120_cents: 5000
)
teacher.should_not be_nil
@ -165,13 +168,16 @@ describe Teacher do
t.lesson_duration_60.should be_true
t.lesson_duration_90.should be_true
t.lesson_duration_120.should be_true
t.price_per_lesson_cents.should == 3000
t.price_per_month_cents.should == 3000
t.price_duration_30_cents.should == 3000
t.price_duration_45_cents.should == 3000
t.price_duration_60_cents.should == 3000
t.price_duration_90_cents.should == 3000
t.price_duration_120_cents.should == 3000
t.price_per_lesson_30_cents.should == 3000
t.price_per_lesson_45_cents.should == 3000
t.price_per_lesson_60_cents.should == 3000
t.price_per_lesson_90_cents.should == 3000
t.price_per_lesson_120_cents.should == 3000
t.price_per_month_30_cents.should == 5000
t.price_per_month_45_cents.should == 5000
t.price_per_month_60_cents.should == 5000
t.price_per_month_90_cents.should == 5000
t.price_per_month_120_cents.should == 5000
end
end
@ -249,13 +255,11 @@ describe Teacher do
lesson_duration_60: false,
lesson_duration_90: false,
lesson_duration_120: false,
price_per_lesson_cents: 3000,
price_per_month_cents: 3000,
#price_duration_30_cents: 3000,
price_duration_45_cents: 3000,
#price_duration_60_cents: 3000,
#price_duration_90_cents: 3000,
price_duration_120_cents: 3000,
#price_per_lesson_30_cents: 3000,
price_per_lesson_45_cents: 3000,
#price_per_lesson_60_cents: 3000,
#price_per_lesson_90_cents: 3000,
price_per_lesson_120_cents: 3000,
validate_pricing:true
)