sbdevpadi 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +28 -0
- data/app/assets/stylesheets/sbdev_padi.scss +0 -0
- data/app/controllers/courses_controller.rb +2 -0
- data/app/controllers/package_calculator_controller.rb +27 -0
- data/app/controllers/pro_courses_controller.rb +2 -0
- data/app/controllers/pro_spec_courses_controller.rb +2 -0
- data/app/controllers/pro_tec_courses_controller.rb +2 -0
- data/app/controllers/rec_courses_controller.rb +2 -0
- data/app/controllers/rec_spec_courses_controller.rb +2 -0
- data/app/controllers/tec_courses_controller.rb +2 -0
- data/app/models/course.rb +52 -0
- data/app/models/pro_course.rb +5 -0
- data/app/models/pro_spec_course.rb +5 -0
- data/app/models/pro_tec_course.rb +5 -0
- data/app/models/random_course.rb +5 -0
- data/app/models/rec_course.rb +5 -0
- data/app/models/rec_spec_course.rb +5 -0
- data/app/models/tec_course.rb +5 -0
- data/app/views/courses/_form.html.haml +29 -0
- data/app/views/courses/_show.html.haml +21 -0
- data/app/views/courses/edit.html.haml +5 -0
- data/app/views/courses/index.html.haml +10 -0
- data/app/views/courses/new.html.haml +4 -0
- data/app/views/courses/show.html.haml +18 -0
- data/app/views/courses/show.js.erb +13 -0
- data/app/views/package_calculator/index.html.haml +107 -0
- data/app/views/prices/edit.html.haml +24 -0
- data/app/views/shared/course_type_index.html.haml +9 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20110304220958_create_courses.rb +19 -0
- data/db/schema.rb +166 -0
- data/db/seeds.rb +29 -0
- data/lib/generators/sbdevpadi/install_generator.rb +24 -0
- data/lib/sbdevpadi/engine.rb +26 -0
- data/lib/sbdevpadi/version.rb +3 -0
- data/lib/sbdevpadi.rb +4 -0
- data/lib/tasks/sbdevpadi.rake +6 -0
- data/sbdevpadi.gemspec +22 -0
- data/script/rails +6 -0
- metadata +98 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2011 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'Sbdevpadi'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
24
|
+
load 'rails/tasks/engine.rake'
|
25
|
+
|
26
|
+
|
27
|
+
Bundler::GemHelper.install_tasks
|
28
|
+
|
File without changes
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class PackageCalculatorController < ApplicationController
|
2
|
+
before_filter :authenticate_admin!, :except => [:index]
|
3
|
+
before_filter :get_index, :only => [:index]
|
4
|
+
|
5
|
+
def index
|
6
|
+
@enriched = Course.find_by_name("Enriched Air Nitrox").id
|
7
|
+
@deep = Course.find_by_name("Deep").id
|
8
|
+
@emergency = Course.find_by_name("Emergency First Responder").id
|
9
|
+
unless(params[:current].nil? || params[:desired].nil?)
|
10
|
+
unless(@courses = Course.calculate(params[:current], params[:desired])).empty?
|
11
|
+
@discount = Course.discount? @courses
|
12
|
+
@courses_total = @courses.sum{|cp| cp.course_price(@discount)}
|
13
|
+
|
14
|
+
@materials_prices_total = @courses.sum(&:materials_price)
|
15
|
+
@application_prices_total = @courses.sum(&:application_price)
|
16
|
+
|
17
|
+
@total = @application_prices_total + @materials_prices_total + @courses_total
|
18
|
+
|
19
|
+
@rec = Course.rec?(params[:desired])
|
20
|
+
@pro = Course.pro?(params[:desired])
|
21
|
+
@tec = Course.tec?(params[:desired])
|
22
|
+
end
|
23
|
+
end
|
24
|
+
params[:current] ||= {}
|
25
|
+
params[:desired] ||= {}
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
class Course < ActiveRecord::Base
|
2
|
+
attr_accessible :name, :duration, :course_price, :materials, :materials_price, :application_price, :type, :priority, :index_attributes
|
3
|
+
|
4
|
+
has_and_belongs_to_many :courses, :class_name => "Course", :join_table => "course_dependencies", :association_foreign_key => :dependent_id
|
5
|
+
|
6
|
+
has_one :index, :as => :owner, :dependent => :destroy
|
7
|
+
|
8
|
+
accepts_nested_attributes_for :index, :allow_destroy => true
|
9
|
+
|
10
|
+
validates_numericality_of :course_price, :materials_price, :application_price
|
11
|
+
|
12
|
+
def total(discount = false)
|
13
|
+
course_price(discount) + materials_price + application_price
|
14
|
+
end
|
15
|
+
|
16
|
+
def map_for_select
|
17
|
+
[name, id.to_s]
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.discount?(course_prices)
|
21
|
+
(course_prices - TecCourse.all - ProTecCourse.all).sum(&:course_price) > 999
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.pro?(desired_certs)
|
25
|
+
desired_certs = Course.find(desired_certs.values.map{|e| e.is_a?(Hash) ? e.keys : e}.flatten - ['0'])
|
26
|
+
!(desired_certs & (ProCourse.all + ProSpecCourse.all + ProTecCourse.all)).empty?
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.rec?(desired_certs)
|
30
|
+
desired_certs = Course.find(desired_certs.values.map{|e| e.is_a?(Hash) ? e.keys : e}.flatten - ['0'])
|
31
|
+
!(desired_certs & (RecCourse.all + RecSpecCourse.all)).empty?
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.tec?(desired_certs)
|
35
|
+
desired_certs = Course.find(desired_certs.values.map{|e| e.is_a?(Hash) ? e.keys : e}.flatten - ['0'])
|
36
|
+
!(desired_certs & (TecCourse.all)).empty?
|
37
|
+
end
|
38
|
+
|
39
|
+
def course_price(discount = false)
|
40
|
+
price = self.read_attribute(:course_price)
|
41
|
+
return nil unless price
|
42
|
+
(discount && ([self] & [ProTecCourse.all + TecCourse.all].flatten).empty?) ? price * 0.9 : price
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.calculate(current_certs, desired_certs)
|
46
|
+
current = [current_certs[:tec_cert], current_certs[:rec_cert], current_certs[:ean], current_certs[:deep], current_certs[:efr]].flatten.compact.uniq.delete_if{|e| e == '0'}
|
47
|
+
current = (Course.find(current).map(&:course_ids) + current.map(&:to_i)).flatten.uniq
|
48
|
+
desired = [desired_certs[:rec_cert], desired_certs[:spec].try("keys"), desired_certs[:pro_cert], desired_certs[:pro_spec].try("keys"), desired_certs[:tec_cert], desired_certs[:pro_tec_cert]].flatten.compact.uniq.delete_if{|e| e == '0'}
|
49
|
+
desired = (Course.find(desired).map(&:course_ids) + desired.map(&:to_i)).flatten.uniq - current
|
50
|
+
Course.find(desired)
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
%p= f.submit
|
2
|
+
= f.error_messages
|
3
|
+
%p
|
4
|
+
= f.label :name
|
5
|
+
%br/
|
6
|
+
= f.text_field :name
|
7
|
+
%p
|
8
|
+
= f.label :duration
|
9
|
+
%br/
|
10
|
+
= f.text_field :duration
|
11
|
+
%p
|
12
|
+
= f.label :course_price
|
13
|
+
%br/
|
14
|
+
= f.text_field :course_price
|
15
|
+
%p
|
16
|
+
= f.label :materials
|
17
|
+
%br/
|
18
|
+
= f.text_field :materials
|
19
|
+
%p
|
20
|
+
= f.label :materials_price
|
21
|
+
%br/
|
22
|
+
= f.text_field :materials_price
|
23
|
+
%p
|
24
|
+
= f.label :application_price
|
25
|
+
%br/
|
26
|
+
= f.text_field :application_price
|
27
|
+
%h4 Description
|
28
|
+
- f.fields_for :index do |index_form|
|
29
|
+
= render "indices/form", :locals => {:f => index_form}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
- render_seo @index
|
2
|
+
%h2= h @course.name
|
3
|
+
= render :partial => 'indices/show'
|
4
|
+
%p
|
5
|
+
%strong Duration:
|
6
|
+
= h @course.duration
|
7
|
+
%p
|
8
|
+
%strong Course Price:
|
9
|
+
= h @course.course_price
|
10
|
+
%p
|
11
|
+
%strong Materials:
|
12
|
+
= h @course.materials
|
13
|
+
%p
|
14
|
+
%strong Materials Price:
|
15
|
+
= h @course.materials_price
|
16
|
+
%p
|
17
|
+
%strong Application Price:
|
18
|
+
= h @course.application_price
|
19
|
+
- if admin_signed_in?
|
20
|
+
%p
|
21
|
+
= link_to "Edit Course", edit_course_path(@course)
|
@@ -0,0 +1,10 @@
|
|
1
|
+
=content_for(:sidebar) do
|
2
|
+
#secondary_nav
|
3
|
+
-@index.indices.each do |page|
|
4
|
+
= link_to page.title.titleize, page.name, :class => 'button', :remote => true
|
5
|
+
|
6
|
+
=(render :partial => 'indices/show', :object => @index, :as => :index)
|
7
|
+
- if request.xhr?
|
8
|
+
.content_for.hidden
|
9
|
+
#content_for_sidebar
|
10
|
+
=@view_flow.get(:sidebar)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
- render_seo @index
|
2
|
+
%h2= h @course.name
|
3
|
+
= render :partial => 'indices/show'
|
4
|
+
%p
|
5
|
+
%strong Duration:
|
6
|
+
= h @course.duration
|
7
|
+
%p
|
8
|
+
%strong Course Price:
|
9
|
+
= h @course.course_price
|
10
|
+
%p
|
11
|
+
%strong Materials:
|
12
|
+
= h @course.materials
|
13
|
+
%p
|
14
|
+
%strong Materials Price:
|
15
|
+
= h @course.materials_price
|
16
|
+
%p
|
17
|
+
%strong Application Price:
|
18
|
+
= h @course.application_price
|
@@ -0,0 +1,13 @@
|
|
1
|
+
$("#ajax_content").fadeOut('fast', function() {
|
2
|
+
$("#ajax_content").html("<%= escape_javascript(render :partial => 'courses/show') %>");
|
3
|
+
});
|
4
|
+
$("#ajax_content").fadeIn('slow', function(){
|
5
|
+
$("#ajax_content .overlayed").overlay({
|
6
|
+
onBeforeLoad: function() {
|
7
|
+
// grab wrapper element inside content
|
8
|
+
var wrap = this.getOverlay().find(".contentWrap");
|
9
|
+
// load the page specified in the trigger
|
10
|
+
wrap.load(this.getTrigger().attr("href"));
|
11
|
+
}
|
12
|
+
});
|
13
|
+
});
|
@@ -0,0 +1,107 @@
|
|
1
|
+
- render_seo @index
|
2
|
+
= render :partial => 'indices/show'
|
3
|
+
- content_for :post_content do
|
4
|
+
.content.corner-all.box-shadow
|
5
|
+
= link_to 'Edit Course Prices', edit_prices_path if admin_signed_in?
|
6
|
+
- if @courses && !@courses.empty?
|
7
|
+
%h3 Your Results
|
8
|
+
%table
|
9
|
+
%tr
|
10
|
+
%th{:colspan => "2", :style => "text-align:center;"}
|
11
|
+
Course#{'*' if @discount}
|
12
|
+
%th
|
13
|
+
%th{:colspan => "2", :style => "text-align:center;"} Materials
|
14
|
+
%th{:style => "text-align:center;"} Application Price
|
15
|
+
%th{:style => "text-align:right;"} Total
|
16
|
+
- for course in @courses
|
17
|
+
%tr
|
18
|
+
%td{:style => "width:400px;"}= course.name
|
19
|
+
%td{:style => "width:20px;text-align:right"}= number_to_currency course.course_price(@discount), :precision => 0
|
20
|
+
%td{:style => "width:10px;"}
|
21
|
+
%td{:style => "width:250px;"}= course.materials
|
22
|
+
%td{:style => "width:20px;text-align:right"}= number_to_currency course.materials_price, :precision => 0
|
23
|
+
%td{:style => "width:20px;text-align:right"}= number_to_currency course.application_price, :precision => 0
|
24
|
+
%td{:style => "width:20px;text-align:right"}= number_to_currency course.total(@discount), :precision => 0
|
25
|
+
%tr
|
26
|
+
%th Total
|
27
|
+
%th{:style => "width:50px;text-align:right"}
|
28
|
+
= '*' if @discount
|
29
|
+
= number_to_currency @courses_total, :precision => 0
|
30
|
+
%th
|
31
|
+
%th
|
32
|
+
%th{:style => "width:50px;text-align:right"}= number_to_currency @materials_prices_total, :precision => 0
|
33
|
+
%th{:style => "width:50px;text-align:right"}= number_to_currency @application_prices_total, :precision => 0
|
34
|
+
%th{:style => "width:85px;text-align:right"}
|
35
|
+
= '*' if @discount
|
36
|
+
= number_to_currency @total, :precision => 0
|
37
|
+
= "<p>* Includes 10% Discount Off Non Tec Course Prices</p>" if @discount
|
38
|
+
- if @rec
|
39
|
+
%p
|
40
|
+
For more information about our PADI recreational dive courses please visit our Five Star PADI Resort and Career Development Center website: #{link_to 'www.coconuttreedivers.com', 'http://www.coconuttreedivers.com'}
|
41
|
+
- if @pro
|
42
|
+
%p
|
43
|
+
For more information about our PADI professional dive courses please visit our PADI Career Development Center website: #{link_to 'www.goprocaribbean.com', 'http://www.goprocaribbean.com'}
|
44
|
+
- if @tec
|
45
|
+
%p
|
46
|
+
For more information about our DSAT tec dive courses please visit our tec diving center website: #{link_to 'www.caribbeansidemountdiving.com', 'http://www.caribbeansidemountdiving.com'}
|
47
|
+
- form_tag package_calculator_path :method => :get do
|
48
|
+
#calculator
|
49
|
+
%h3
|
50
|
+
%span{:style => "color:red"} Current
|
51
|
+
Certifications
|
52
|
+
%p
|
53
|
+
= select_tag "current[rec_cert]", options_for_select([["None", 0]] + RecCourse.all.map(&:map_for_select) + ProCourse.all.map(&:map_for_select), (params[:current][:rec_cert] rescue 0))
|
54
|
+
Current PADI Certification
|
55
|
+
%p
|
56
|
+
= select_tag "current[tec_cert]", options_for_select([["None", 0]] + TecCourse.all.map(&:map_for_select) + ProTecCourse.all.map(&:map_for_select), (params[:current][:tec_cert] rescue 0))
|
57
|
+
Current Tec Certification
|
58
|
+
%p
|
59
|
+
= check_box_tag "current[ean]", @enriched, (params[:current][:ean] == @enriched.to_s)
|
60
|
+
Enriched Air Nitrox Certified?
|
61
|
+
%br/
|
62
|
+
= check_box_tag "current[deep]", @deep, (params[:current][:deep] == @deep.to_s)
|
63
|
+
Deep Specialty Certified?
|
64
|
+
%br/
|
65
|
+
= check_box_tag "current[efr]", @emergency, (params[:current][:efr] == @emergency.to_s)
|
66
|
+
CPR Certified?
|
67
|
+
%br/
|
68
|
+
%h3
|
69
|
+
%span{:style => "color:red"} Desired
|
70
|
+
Certifications
|
71
|
+
%p
|
72
|
+
= select_tag "desired[rec_cert]", options_for_select([["None", 0]] + RecCourse.all.map(&:map_for_select) + ProCourse.all.map(&:map_for_select), (params[:desired][:rec_cert] rescue 0))
|
73
|
+
Desired PADI Certification
|
74
|
+
%br/
|
75
|
+
%p
|
76
|
+
= select_tag "desired[tec_cert]", options_for_select([["None", 0]] + TecCourse.all.map(&:map_for_select) + ProTecCourse.all.map(&:map_for_select), (params[:desired][:tec_cert] rescue 0))
|
77
|
+
Desired DSAT Tec Certification
|
78
|
+
%br/
|
79
|
+
.clearfix
|
80
|
+
Desired Specialities
|
81
|
+
%br/
|
82
|
+
- specs = RecSpecCourse.all
|
83
|
+
%p.two-col
|
84
|
+
- for spec in specs[0...specs.size/2]
|
85
|
+
= check_box_tag "desired[spec][#{spec.id}]", '1', (params[:desired][:spec][spec.id.to_s] == '1' rescue false)
|
86
|
+
= spec.name
|
87
|
+
%br/
|
88
|
+
%p.two-col
|
89
|
+
- for spec in specs[specs.size/2...specs.size]
|
90
|
+
= check_box_tag "desired[spec][#{spec.id}]", '1', (params[:desired][:spec][spec.id.to_s] == '1' rescue false)
|
91
|
+
= spec.name
|
92
|
+
%br/
|
93
|
+
.clearfix
|
94
|
+
Desired Instructor Specialities
|
95
|
+
%br/
|
96
|
+
- specs = ProSpecCourse.all
|
97
|
+
%p.two-col
|
98
|
+
- for spec in specs[0...specs.size/2]
|
99
|
+
= check_box_tag "desired[pro_spec][#{spec.id}]", '1', (params[:desired][:pro_spec][spec.id.to_s] == '1' rescue false)
|
100
|
+
= spec.name
|
101
|
+
%br/
|
102
|
+
%p.two-col
|
103
|
+
- for spec in specs[specs.size/2...specs.size]
|
104
|
+
= check_box_tag "desired[pro_spec][#{spec.id}]", '1', (params[:desired][:pro_spec][spec.id.to_s] == '1' rescue false)
|
105
|
+
= spec.name
|
106
|
+
%br/
|
107
|
+
%p= submit_tag "Calculate"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
- form_tag update_prices_path :method => :put do
|
2
|
+
#edit_course_prices
|
3
|
+
%p= submit_tag
|
4
|
+
%table
|
5
|
+
%tr
|
6
|
+
%th Course Name
|
7
|
+
%th Course Price
|
8
|
+
%th Materials
|
9
|
+
%th Materials Price
|
10
|
+
%th Application Price
|
11
|
+
- for price in @prices
|
12
|
+
- fields_for 'prices[]', price do |f|
|
13
|
+
%tr
|
14
|
+
%td{:style => "width:400px;"}
|
15
|
+
= f.text_field :name
|
16
|
+
%td{:style => "width:20px;"}
|
17
|
+
= f.text_field :course_price, :size => 5
|
18
|
+
%td{:style => "width:250px;"}
|
19
|
+
= f.text_field :materials
|
20
|
+
%td{:style => "width:20px;"}
|
21
|
+
= f.text_field :materials_price, :size => 5
|
22
|
+
%td{:style => "width:20px;"}
|
23
|
+
= f.text_field :application_price, :size => 5
|
24
|
+
%p= submit_tag
|
@@ -0,0 +1,9 @@
|
|
1
|
+
- render_seo @index if @index
|
2
|
+
- content_for :pre_content do
|
3
|
+
#course_nav.course_nav.content.no_back
|
4
|
+
#course_nav_inner.nav.inline_nav.corner-all.box-shadow
|
5
|
+
%a{:href => "#", :style => "display:none"}
|
6
|
+
- for course in @courses
|
7
|
+
= link_to course.name, course, :class => 'button corner-all'
|
8
|
+
#ajax_content
|
9
|
+
= render :partial => 'indices/index' if @index
|
data/config/routes.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
class CreateCourses < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :courses do |t|
|
4
|
+
t.string :name
|
5
|
+
t.string :duration
|
6
|
+
t.integer :course_price
|
7
|
+
t.string :materials
|
8
|
+
t.integer :materials_price
|
9
|
+
t.integer :application_price
|
10
|
+
t.string :type
|
11
|
+
t.integer :priority
|
12
|
+
t.timestamps
|
13
|
+
end
|
14
|
+
create_table :course_dependencies, :id => false do |t|
|
15
|
+
t.integer :course_id
|
16
|
+
t.integer :dependent_id
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/db/schema.rb
ADDED
@@ -0,0 +1,166 @@
|
|
1
|
+
# This file is auto-generated from the current state of the database. Instead of editing this file,
|
2
|
+
# please use the migrations feature of Active Record to incrementally modify your database, and
|
3
|
+
# then regenerate this schema definition.
|
4
|
+
#
|
5
|
+
# Note that this schema.rb definition is the authoritative source for your database schema. If you need
|
6
|
+
# to create the application database on another system, you should be using db:schema:load, not running
|
7
|
+
# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
8
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
9
|
+
#
|
10
|
+
# It's strongly recommended to check this file into your version control system.
|
11
|
+
|
12
|
+
ActiveRecord::Schema.define(:version => 20110728171010) do
|
13
|
+
|
14
|
+
create_table "admins", :force => true do |t|
|
15
|
+
t.string "email", :null => false
|
16
|
+
t.string "encrypted_password", :limit => 40, :null => false
|
17
|
+
t.string "password_salt", :null => false
|
18
|
+
t.string "confirmation_token", :limit => 20
|
19
|
+
t.datetime "confirmed_at"
|
20
|
+
t.datetime "confirmation_sent_at"
|
21
|
+
t.string "reset_password_token", :limit => 20
|
22
|
+
t.string "remember_token", :limit => 20
|
23
|
+
t.datetime "remember_created_at"
|
24
|
+
t.integer "sign_in_count"
|
25
|
+
t.datetime "current_sign_in_at"
|
26
|
+
t.datetime "last_sign_in_at"
|
27
|
+
t.string "current_sign_in_ip"
|
28
|
+
t.string "last_sign_in_ip"
|
29
|
+
t.string "username"
|
30
|
+
t.datetime "created_at"
|
31
|
+
t.datetime "updated_at"
|
32
|
+
end
|
33
|
+
|
34
|
+
add_index "admins", ["confirmation_token"], :name => "index_admins_on_confirmation_token", :unique => true
|
35
|
+
add_index "admins", ["email"], :name => "index_admins_on_email", :unique => true
|
36
|
+
add_index "admins", ["reset_password_token"], :name => "index_admins_on_reset_password_token", :unique => true
|
37
|
+
|
38
|
+
create_table "assets", :force => true do |t|
|
39
|
+
t.string "asset_file_name"
|
40
|
+
t.string "asset_content_type"
|
41
|
+
t.integer "asset_file_size"
|
42
|
+
t.integer "owner_id"
|
43
|
+
t.string "owner_type"
|
44
|
+
t.string "title"
|
45
|
+
t.string "klass"
|
46
|
+
t.string "type"
|
47
|
+
t.integer "priority"
|
48
|
+
t.string "author"
|
49
|
+
t.string "remote_id"
|
50
|
+
t.string "remote_type"
|
51
|
+
t.text "description"
|
52
|
+
t.datetime "created_at"
|
53
|
+
t.datetime "updated_at"
|
54
|
+
end
|
55
|
+
|
56
|
+
create_table "contacts", :force => true do |t|
|
57
|
+
t.string "name"
|
58
|
+
t.string "email"
|
59
|
+
t.text "message"
|
60
|
+
t.datetime "created_at"
|
61
|
+
t.datetime "updated_at"
|
62
|
+
end
|
63
|
+
|
64
|
+
create_table "course_dependencies", :id => false, :force => true do |t|
|
65
|
+
t.integer "course_id"
|
66
|
+
t.integer "dependent_id"
|
67
|
+
end
|
68
|
+
|
69
|
+
create_table "courses", :force => true do |t|
|
70
|
+
t.string "name"
|
71
|
+
t.string "duration"
|
72
|
+
t.integer "course_price"
|
73
|
+
t.string "materials"
|
74
|
+
t.integer "materials_price"
|
75
|
+
t.integer "application_price"
|
76
|
+
t.string "type"
|
77
|
+
t.integer "priority"
|
78
|
+
t.datetime "created_at"
|
79
|
+
t.datetime "updated_at"
|
80
|
+
end
|
81
|
+
|
82
|
+
create_table "galleries", :force => true do |t|
|
83
|
+
t.string "title"
|
84
|
+
t.integer "priority"
|
85
|
+
t.datetime "created_at"
|
86
|
+
t.datetime "updated_at"
|
87
|
+
t.integer "index_id"
|
88
|
+
end
|
89
|
+
|
90
|
+
create_table "indices", :force => true do |t|
|
91
|
+
t.string "name"
|
92
|
+
t.string "title"
|
93
|
+
t.string "page_title"
|
94
|
+
t.text "keywords"
|
95
|
+
t.text "page_description"
|
96
|
+
t.integer "owner_id"
|
97
|
+
t.string "owner_type"
|
98
|
+
t.integer "side_section_id"
|
99
|
+
t.datetime "created_at"
|
100
|
+
t.datetime "updated_at"
|
101
|
+
end
|
102
|
+
|
103
|
+
create_table "links", :force => true do |t|
|
104
|
+
t.string "name"
|
105
|
+
t.string "link_url"
|
106
|
+
t.text "description"
|
107
|
+
t.integer "priority"
|
108
|
+
t.datetime "created_at"
|
109
|
+
t.datetime "updated_at"
|
110
|
+
end
|
111
|
+
|
112
|
+
create_table "order_items", :force => true do |t|
|
113
|
+
t.integer "order_id"
|
114
|
+
t.integer "product_id"
|
115
|
+
t.integer "quantity"
|
116
|
+
t.datetime "created_at"
|
117
|
+
t.datetime "updated_at"
|
118
|
+
end
|
119
|
+
|
120
|
+
create_table "orders", :force => true do |t|
|
121
|
+
t.string "email"
|
122
|
+
t.string "state"
|
123
|
+
t.datetime "created_at"
|
124
|
+
t.datetime "updated_at"
|
125
|
+
t.datetime "purchased_at"
|
126
|
+
end
|
127
|
+
|
128
|
+
create_table "payment_notifications", :force => true do |t|
|
129
|
+
t.text "params"
|
130
|
+
t.string "status"
|
131
|
+
t.string "transaction_id"
|
132
|
+
t.datetime "created_at"
|
133
|
+
t.datetime "updated_at"
|
134
|
+
end
|
135
|
+
|
136
|
+
create_table "posts", :force => true do |t|
|
137
|
+
t.string "title"
|
138
|
+
t.datetime "created_at"
|
139
|
+
t.datetime "updated_at"
|
140
|
+
end
|
141
|
+
|
142
|
+
create_table "products", :force => true do |t|
|
143
|
+
t.string "name"
|
144
|
+
t.string "price"
|
145
|
+
t.datetime "created_at"
|
146
|
+
t.datetime "updated_at"
|
147
|
+
end
|
148
|
+
|
149
|
+
create_table "sections", :force => true do |t|
|
150
|
+
t.text "content"
|
151
|
+
t.integer "owner_id"
|
152
|
+
t.integer "priority"
|
153
|
+
t.string "owner_type"
|
154
|
+
t.datetime "created_at"
|
155
|
+
t.datetime "updated_at"
|
156
|
+
end
|
157
|
+
|
158
|
+
create_table "testimonials", :force => true do |t|
|
159
|
+
t.string "name"
|
160
|
+
t.string "from"
|
161
|
+
t.text "message"
|
162
|
+
t.datetime "created_at"
|
163
|
+
t.datetime "updated_at"
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
data/db/seeds.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
|
3
|
+
LOREM_LONG = <<-END_LOREM
|
4
|
+
<p>
|
5
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean a ante et dolor vehicula auctor. Cras sem magna, venenatis non pharetra ac, pellentesque at dui. Sed sit amet nulla nulla, at imperdiet lacus. Aenean tellus turpis, pretium in facilisis a, vestibulum sit amet ante. Quisque bibendum nisi ac magna blandit at eleifend turpis gravida. Curabitur quis massa ac magna molestie pharetra at a eros. Phasellus vulputate neque sit amet est faucibus mattis. Mauris adipiscing orci at augue interdum sit amet commodo tortor consectetur. Etiam eleifend congue risus vitae ultricies. Donec feugiat volutpat pharetra. Maecenas non fermentum magna. Sed facilisis vulputate dui in pellentesque. Praesent eget magna non orci posuere pretium. Ut sit amet lobortis ligula.
|
6
|
+
</p>
|
7
|
+
<p>
|
8
|
+
Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Suspendisse eu felis eu turpis elementum mattis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Morbi auctor hendrerit enim non aliquam. In mollis fringilla ante, sed feugiat erat pretium volutpat. Curabitur ut urna vitae magna venenatis varius sit amet in sapien. Cras nec turpis sem. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec consequat volutpat lectus vel mollis. Morbi iaculis, felis ut tempus placerat, tortor risus iaculis arcu, sit amet imperdiet risus lectus vel odio. Nullam in risus purus, ut tincidunt lacus.
|
9
|
+
</p>
|
10
|
+
END_LOREM
|
11
|
+
|
12
|
+
LOREM_SHORT = <<-END_LOREM
|
13
|
+
<p>
|
14
|
+
L
|
15
|
+
orem ipsum dolor sit amet, consectetur adipiscing elit. Aenean a ante et dolor vehicula auctor. Cras sem magna, venenatis non pharetra ac, pellentesque at dui. Sed sit amet nulla nulla, at imperdiet lacus. Aenean tellus turpis, pretium in facilisis a, vestibulum sit amet ante.
|
16
|
+
</p>
|
17
|
+
END_LOREM
|
18
|
+
|
19
|
+
LOREM_MICRO = <<-END_LOREM
|
20
|
+
<p>
|
21
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean a ante et dolor vehicula auctor.
|
22
|
+
</p>
|
23
|
+
END_LOREM
|
24
|
+
|
25
|
+
LOREM_SANS_HTML = <<-END_LOREM
|
26
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean a ante et dolor vehicula auctor.
|
27
|
+
END_LOREM
|
28
|
+
|
29
|
+
Index.find('courses').indices << Index.find_all_by_name(["pro_courses", "pro_spec_courses", "pro_tec_courses", "rec_courses", "rec_spec_courses"])
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Sbdevpadi
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path('../templates', __FILE__)
|
5
|
+
|
6
|
+
def migrations
|
7
|
+
rake "sbdevpadi:install:migrations"
|
8
|
+
rake "db:migrate"
|
9
|
+
end
|
10
|
+
|
11
|
+
def set_routes
|
12
|
+
route "Sbdevpadi::Routes.draw(self)"
|
13
|
+
end
|
14
|
+
|
15
|
+
def files
|
16
|
+
inject_into_file "app/assets/stylesheets/sass.scss", "\n@import 'sbdev_padi';\n", :after => "@import 'sbdev_core';"
|
17
|
+
end
|
18
|
+
|
19
|
+
def seeds
|
20
|
+
Sbdevpadi::Engine.load_seed
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'sbdevcore'
|
2
|
+
require 'sbdevpadi'
|
3
|
+
|
4
|
+
module Sbdevpadi
|
5
|
+
class Engine < Rails::Engine
|
6
|
+
engine_name "sbdevpadi"
|
7
|
+
|
8
|
+
rake_tasks do
|
9
|
+
load "tasks/sbdevpadi.rake"
|
10
|
+
end
|
11
|
+
|
12
|
+
initializer 'sbdevcart.indices', :after => :load_config_initializers do |app|
|
13
|
+
APP_CONFIG[:dynamic_pages] += ["courses", "pro_courses", "pro_spec_courses", "pro_tec_courses", "rec_courses", "rec_spec_courses", "tec_courses", "package_calculator"]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module Routes
|
18
|
+
def self.draw(map)
|
19
|
+
map.instance_exec do
|
20
|
+
["courses", "package_calculator", "pro_courses", "pro_spec_courses", "pro_tec_courses", "rec_courses", "rec_spec_courses", "tec_courses"].each do |res|
|
21
|
+
resources res.to_sym
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/sbdevpadi.rb
ADDED
data/sbdevpadi.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "sbdevpadi/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "sbdevpadi"
|
7
|
+
s.summary = "Sbdev Padi Courses"
|
8
|
+
s.description = "Sbdev Padi"
|
9
|
+
s.authors = ["Adam Olsen"]
|
10
|
+
s.email = ["aosalias@gmail.com"]
|
11
|
+
|
12
|
+
s.version = Sbdevpadi::VERSION
|
13
|
+
|
14
|
+
s.rubyforge_project = "sbdev"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_dependency('sbdevcore', ">= 0.1.0")
|
22
|
+
end
|
data/script/rails
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#!/usr/bin/env ruby
|
3
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
4
|
+
|
5
|
+
ENGINE_PATH = File.expand_path('../..', __FILE__)
|
6
|
+
load File.expand_path('../../test/dummy/script/rails', __FILE__)
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sbdevpadi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Adam Olsen
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-08-31 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: sbdevcore
|
16
|
+
requirement: &2156355900 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.1.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2156355900
|
25
|
+
description: Sbdev Padi
|
26
|
+
email:
|
27
|
+
- aosalias@gmail.com
|
28
|
+
executables: []
|
29
|
+
extensions: []
|
30
|
+
extra_rdoc_files: []
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- MIT-LICENSE
|
34
|
+
- README.rdoc
|
35
|
+
- Rakefile
|
36
|
+
- app/assets/stylesheets/sbdev_padi.scss
|
37
|
+
- app/controllers/courses_controller.rb
|
38
|
+
- app/controllers/package_calculator_controller.rb
|
39
|
+
- app/controllers/pro_courses_controller.rb
|
40
|
+
- app/controllers/pro_spec_courses_controller.rb
|
41
|
+
- app/controllers/pro_tec_courses_controller.rb
|
42
|
+
- app/controllers/rec_courses_controller.rb
|
43
|
+
- app/controllers/rec_spec_courses_controller.rb
|
44
|
+
- app/controllers/tec_courses_controller.rb
|
45
|
+
- app/models/course.rb
|
46
|
+
- app/models/pro_course.rb
|
47
|
+
- app/models/pro_spec_course.rb
|
48
|
+
- app/models/pro_tec_course.rb
|
49
|
+
- app/models/random_course.rb
|
50
|
+
- app/models/rec_course.rb
|
51
|
+
- app/models/rec_spec_course.rb
|
52
|
+
- app/models/tec_course.rb
|
53
|
+
- app/views/courses/_form.html.haml
|
54
|
+
- app/views/courses/_show.html.haml
|
55
|
+
- app/views/courses/edit.html.haml
|
56
|
+
- app/views/courses/index.html.haml
|
57
|
+
- app/views/courses/new.html.haml
|
58
|
+
- app/views/courses/show.html.haml
|
59
|
+
- app/views/courses/show.js.erb
|
60
|
+
- app/views/package_calculator/index.html.haml
|
61
|
+
- app/views/prices/edit.html.haml
|
62
|
+
- app/views/shared/course_type_index.html.haml
|
63
|
+
- config/routes.rb
|
64
|
+
- db/migrate/20110304220958_create_courses.rb
|
65
|
+
- db/schema.rb
|
66
|
+
- db/seeds.rb
|
67
|
+
- lib/generators/sbdevpadi/install_generator.rb
|
68
|
+
- lib/sbdevpadi.rb
|
69
|
+
- lib/sbdevpadi/engine.rb
|
70
|
+
- lib/sbdevpadi/version.rb
|
71
|
+
- lib/tasks/sbdevpadi.rake
|
72
|
+
- sbdevpadi.gemspec
|
73
|
+
- script/rails
|
74
|
+
homepage:
|
75
|
+
licenses: []
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ! '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project: sbdev
|
94
|
+
rubygems_version: 1.8.6
|
95
|
+
signing_key:
|
96
|
+
specification_version: 3
|
97
|
+
summary: Sbdev Padi Courses
|
98
|
+
test_files: []
|