solidus_subscription_boxes 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +29 -0
- data/README.md +28 -0
- data/Rakefile +47 -0
- data/app/assets/config/solidus_subscription_boxes_manifest.js +2 -0
- data/app/assets/javascripts/solidus_subscription_boxes/application.js +13 -0
- data/app/assets/stylesheets/solidus_subscription_boxes/application.css +15 -0
- data/app/controllers/solidus_subscription_boxes/application_controller.rb +4 -0
- data/app/controllers/solidus_subscription_boxes/subscription_boxes_controller.rb +6 -0
- data/app/decorators/spree/controllers/orders/meal_preference_decorator.rb +24 -0
- data/app/decorators/spree/orders/preference_decorator.rb +14 -0
- data/app/helpers/solidus_subscription_boxes/application_helper.rb +4 -0
- data/app/jobs/solidus_subscription_boxes/application_job.rb +4 -0
- data/app/mailers/solidus_subscription_boxes/application_mailer.rb +6 -0
- data/app/models/solidus_subscription_boxes/application_record.rb +5 -0
- data/app/models/solidus_subscription_boxes/box_preference.rb +10 -0
- data/app/models/solidus_subscription_boxes/subscription_period.rb +10 -0
- data/app/models/solidus_subscription_boxes/subscription_periods_variant.rb +6 -0
- data/app/views/layouts/solidus_subscription_boxes/application.html.erb +14 -0
- data/app/views/solidus_subscription_boxes/subscription_boxes/get_started.html.slim +41 -0
- data/config/routes.rb +3 -0
- data/db/migrate/20170609065436_create_solidus_subscription_boxes_box_preferences.rb +10 -0
- data/db/migrate/20170906015531_create_solidus_subscription_boxes_subscription_periods.rb +9 -0
- data/db/migrate/20170906021159_create_solidus_subscription_boxes_subscription_periods_variants.rb +10 -0
- data/lib/solidus_subscription_boxes.rb +4 -0
- data/lib/solidus_subscription_boxes/engine.rb +13 -0
- data/lib/solidus_subscription_boxes/version.rb +3 -0
- data/lib/tasks/solidus_subscription_boxes_tasks.rake +4 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/config/manifest.js +5 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/javascripts/cable.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/channels/application_cable/channel.rb +4 -0
- data/test/dummy/app/channels/application_cable/connection.rb +4 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/jobs/application_job.rb +2 -0
- data/test/dummy/app/mailers/application_mailer.rb +4 -0
- data/test/dummy/app/models/application_record.rb +3 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/bin/update +29 -0
- data/test/dummy/bin/yarn +11 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +29 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/cable.yml +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/puma.rb +56 -0
- data/test/dummy/config/routes.rb +3 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config/spring.rb +6 -0
- data/test/dummy/package.json +5 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/test/dummy/public/apple-touch-icon.png +0 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/integration/navigation_test.rb +8 -0
- data/test/solidus_subscription_boxes_test.rb +7 -0
- data/test/test_helper.rb +21 -0
- metadata +292 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8956120aac7f5a18df09962d418114539a59bd75
|
4
|
+
data.tar.gz: 33faefe299a457759610e30f7598c8a07369402e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 035d04575a35029e27a09a4f0625d1b027bca1be3ee39917f52229176a3bf3583cc6b8f62e4ed99dfb0f4c654232502c5114b824975e4b02429505fa326b65f1
|
7
|
+
data.tar.gz: 19bc43219a8dd84ce801718064cf00179f7b7ec7f78bc0c6cd17fc53f1695925f8345818ea60e80f64599243e1474fe285ce44c6c688ef02aac448987a24194e
|
data/LICENSE
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
BSD 3-Clause License
|
2
|
+
|
3
|
+
Copyright (c) 2017, Joel Jackson
|
4
|
+
All rights reserved.
|
5
|
+
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
8
|
+
|
9
|
+
* Redistributions of source code must retain the above copyright notice, this
|
10
|
+
list of conditions and the following disclaimer.
|
11
|
+
|
12
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
14
|
+
and/or other materials provided with the distribution.
|
15
|
+
|
16
|
+
* Neither the name of the copyright holder nor the names of its
|
17
|
+
contributors may be used to endorse or promote products derived from
|
18
|
+
this software without specific prior written permission.
|
19
|
+
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# SolidusSubscriptionBoxes
|
2
|
+
Short description and motivation.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
How to use my plugin.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'solidus_subscription_boxes'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
```bash
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
```bash
|
21
|
+
$ gem install solidus_subscription_boxes
|
22
|
+
```
|
23
|
+
|
24
|
+
## Contributing
|
25
|
+
Contribution directions go here.
|
26
|
+
|
27
|
+
## License
|
28
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'SolidusSubscriptionBoxes'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
Bundler::GemHelper.install_tasks
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'lib'
|
31
|
+
t.libs << 'test'
|
32
|
+
t.pattern = 'test/**/*_test.rb'
|
33
|
+
t.verbose = false
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
task default: :test
|
38
|
+
require 'rake/testtask'
|
39
|
+
|
40
|
+
Rake::TestTask.new(:test) do |t|
|
41
|
+
t.libs << 'test'
|
42
|
+
t.pattern = 'test/**/*_test.rb'
|
43
|
+
t.verbose = false
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
task default: :test
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Spree
|
2
|
+
module Controllers
|
3
|
+
module Orders
|
4
|
+
module MealPreferenceDecorator
|
5
|
+
def self.prepended(base)
|
6
|
+
base.after_action(
|
7
|
+
:set_box_preference,
|
8
|
+
only: :populate
|
9
|
+
)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
def set_box_preference
|
14
|
+
if params[:box_preference_attributes]
|
15
|
+
params[:box_preference_attributes].permit!
|
16
|
+
@order.update_attributes(box_preference_attributes: params[:box_preference_attributes].to_hash)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
Spree::OrdersController.prepend(Spree::Controllers::Orders::MealPreferenceDecorator)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Spree
|
2
|
+
module Orders
|
3
|
+
module PreferenceDecorator
|
4
|
+
def self.prepended(base)
|
5
|
+
base.has_one :box_preference, as: :preferable, class_name: 'SolidusSubscriptionBoxes::BoxPreference'
|
6
|
+
base.accepts_nested_attributes_for :box_preference
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
Spree::Order.prepend(Spree::Orders::PreferenceDecorator)
|
13
|
+
SolidusSubscriptions::Subscription.prepend(Spree::Orders::PreferenceDecorator)
|
14
|
+
SolidusSubscriptions::Installment.prepend(Spree::Orders::PreferenceDecorator)
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module SolidusSubscriptionBoxes
|
2
|
+
class SubscriptionPeriod < ApplicationRecord
|
3
|
+
has_many :subscription_periods_variants
|
4
|
+
has_many :variants, through: :subscription_periods_variants, class_name: 'Spree::Variant'
|
5
|
+
|
6
|
+
def self.current
|
7
|
+
SubscriptionPeriod.where('start_date <= ?', Date.today).order('start_date desc').last
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>SolidusSubscriptionBoxes</title>
|
5
|
+
<%= stylesheet_link_tag "solidus_subscription_boxes/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "solidus_subscription_boxes/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
.container-fluid
|
2
|
+
section.how-it-works
|
3
|
+
.row.text-center.how-it-works.background-grey
|
4
|
+
h1 Here's How It Works
|
5
|
+
.col-xs-12.col-sm-3
|
6
|
+
h2.statistic 3
|
7
|
+
h4 Delicious vegetarian lunches delivered every week
|
8
|
+
.col-xs-12.col-sm-3.border-right
|
9
|
+
h2.statistic Sunday
|
10
|
+
h4 Food shows up at your door
|
11
|
+
.col-xs-12.col-sm-3.border-right
|
12
|
+
h2.statistic $36
|
13
|
+
h4 Paid Weekly
|
14
|
+
.col-xs-12.col-sm-3.border-right
|
15
|
+
h2.statistic 20
|
16
|
+
h4 Pounds of greenhouse emissions potentially saved every week
|
17
|
+
|
18
|
+
.menu()
|
19
|
+
h1.text-center Select your first three meals
|
20
|
+
#root
|
21
|
+
div(data-reactroot)
|
22
|
+
= form_for :order, url: '/orders/populate' do |f|
|
23
|
+
.row.row-centered
|
24
|
+
- @box_variants.each do |variant|
|
25
|
+
.col-xs-12.col-md-4.col-centered.text-center.meal
|
26
|
+
label.meal-selection
|
27
|
+
input.hidden(type="checkbox" name="box_preference_attributes[preference][]" value="#{variant.id}")
|
28
|
+
.image
|
29
|
+
= image_tag variant.display_image.attachment.url(:large)
|
30
|
+
h4 = variant.name
|
31
|
+
|
32
|
+
.row
|
33
|
+
.col-xs-12.content.text-center
|
34
|
+
= hidden_field_tag :variant_id, @variant_id
|
35
|
+
= hidden_field_tag :quantity, 1
|
36
|
+
= hidden_field_tag :'subscription_line_item[quantity]', 1
|
37
|
+
= hidden_field_tag :'subscription_line_item[subscribable_id]', 1
|
38
|
+
= hidden_field_tag :'subscription_line_item[interval_length]', 1
|
39
|
+
= hidden_field_tag :'subscription_line_item[interval_units]', 'week'
|
40
|
+
= f.submit 'Choose 3 More', onclick: "window.dataLayer.push({event: 'click', clickAction:'selectorPurchase'})", class: "btn btn-primary btn-large purchase-link", disabled: 'disabled', :'data-disable-with' => 'Submitting...'
|
41
|
+
|
data/config/routes.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
class CreateSolidusSubscriptionBoxesBoxPreferences < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
create_table :solidus_subscription_boxes_box_preferences do |t|
|
4
|
+
t.json :preference
|
5
|
+
t.references :preferable, polymorphic: true, index: { name: 'subscription_box_preferable' }
|
6
|
+
|
7
|
+
t.timestamps
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
data/db/migrate/20170906021159_create_solidus_subscription_boxes_subscription_periods_variants.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
class CreateSolidusSubscriptionBoxesSubscriptionPeriodsVariants < ActiveRecord::Migration[5.1]
|
2
|
+
def change
|
3
|
+
create_table :solidus_subscription_boxes_subscription_periods_variants do |t|
|
4
|
+
t.references :spree_variant, foreign_key: true, index: {name: 'subscription_box_period_variant'}
|
5
|
+
t.references :subscription_period, foreign_key: true, index: {name: 'subscription_box_period_period'}
|
6
|
+
|
7
|
+
t.timestamps
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module SolidusSubscriptionBoxes
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
isolate_namespace SolidusSubscriptionBoxes
|
4
|
+
|
5
|
+
def self.activate
|
6
|
+
Dir.glob(File.join(File.dirname(__FILE__), '../../app/decorators/**/*.rb')) do |c|
|
7
|
+
Rails.configuration.cache_classes ? require(c) : load(c)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
config.to_prepare(&method(:activate).to_proc)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|
data/test/dummy/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|