solidus_subscription_boxes 0.0.11 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +29 -29
  3. data/README.md +26 -26
  4. data/Rakefile +47 -47
  5. data/app/assets/config/solidus_subscription_boxes_manifest.js +2 -2
  6. data/app/assets/javascripts/solidus_subscription_boxes/application.js +13 -13
  7. data/app/assets/javascripts/solidus_subscription_boxes/subscription_selection.js +64 -64
  8. data/app/assets/stylesheets/_solidus_subscription_boxes.scss +16 -16
  9. data/app/assets/stylesheets/solidus_subscription_boxes/subscription_box.css.scss +29 -29
  10. data/app/controllers/solidus_subscription_boxes/application_controller.rb +4 -4
  11. data/app/controllers/solidus_subscription_boxes/subscription_boxes_controller.rb +7 -6
  12. data/app/decorators/solidus_subscriptions/models/checkout/update_preference_decorator.rb +13 -13
  13. data/app/decorators/spree/controllers/api/v1/subscriptions/meal_preference_decorator.rb +20 -20
  14. data/app/decorators/spree/controllers/orders/meal_preference_decorator.rb +35 -35
  15. data/app/decorators/spree/controllers/users/set_box_preference_decorator.rb +31 -31
  16. data/app/decorators/spree/orders/preference_decorator.rb +14 -14
  17. data/app/decorators/spree/products/boxable_decorator.rb +15 -15
  18. data/app/decorators/spree/variants/subscription_period_decorator.rb +13 -13
  19. data/app/helpers/solidus_subscription_boxes/application_helper.rb +26 -19
  20. data/app/jobs/solidus_subscription_boxes/application_job.rb +4 -4
  21. data/app/mailers/solidus_subscription_boxes/application_mailer.rb +6 -6
  22. data/app/models/solidus_subscription_boxes/application_record.rb +5 -5
  23. data/app/models/solidus_subscription_boxes/box_preference.rb +10 -10
  24. data/app/models/solidus_subscription_boxes/subscription_period.rb +15 -15
  25. data/app/models/solidus_subscription_boxes/subscription_periods_variant.rb +6 -6
  26. data/app/overrides/views/admin_boxable_checkbox.rb +5 -5
  27. data/app/views/layouts/solidus_subscription_boxes/application.html.erb +14 -14
  28. data/app/views/solidus_subscription_boxes/subscription_boxes/_box_variants.html.erb +14 -14
  29. data/app/views/solidus_subscription_boxes/subscription_boxes/_manage.html.erb +39 -39
  30. data/app/views/solidus_subscription_boxes/subscription_boxes/get_started.html.erb +52 -52
  31. data/app/views/spree/admin/products/_boxable_checkbox.html.erb +26 -26
  32. data/app/views/spree/admin/variants/_boxable_checkbox.html.erb +8 -8
  33. data/config/routes.rb +4 -4
  34. data/db/migrate/20170609065436_create_solidus_subscription_boxes_box_preferences.rb +10 -10
  35. data/db/migrate/20170906015531_create_solidus_subscription_boxes_subscription_periods.rb +9 -9
  36. data/db/migrate/20170906021159_create_solidus_subscription_boxes_subscription_periods_variants.rb +10 -10
  37. data/db/migrate/20170919054537_add_boxable_to_spree_variants.rb +5 -5
  38. data/db/migrate/20170919063437_add_boxable_variant_id_to_solidus_subscription_boxes_subscription_periods.rb +5 -5
  39. data/lib/solidus_subscription_boxes.rb +4 -4
  40. data/lib/solidus_subscription_boxes/engine.rb +13 -13
  41. data/lib/solidus_subscription_boxes/version.rb +3 -3
  42. data/lib/tasks/solidus_subscription_boxes_tasks.rake +4 -4
  43. data/test/integration/navigation_test.rb +8 -8
  44. data/test/solidus_subscription_boxes_test.rb +7 -7
  45. data/test/test_helper.rb +21 -21
  46. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ed6cdb37d61fffb2d29ae9d1fa425518c795664
4
- data.tar.gz: ecbd2accd48d2d1acfb40217f3022c195b226c6a
3
+ metadata.gz: ecc09ca103d4127a8ebfba86d20afe7a9263cd9e
4
+ data.tar.gz: 42488b406d836d45933cdd817995e94784314736
5
5
  SHA512:
6
- metadata.gz: cb468d6a7000a5a99c52b42fd959a82c0c2f9002e52fce3f3f2b1af58ad4f9338681d610256bfb9b797b150b8ef9a6da5353b70610307fa2c79dd09a5a6613ab
7
- data.tar.gz: 9f38a95024cab5f9151f4708af04fd45613ce2aa3d86a5dbc3fcdfb19702ccabf35ec358605e61eb2d5da8713490f27bb89d6e5aedc71da761e5dfce8b353299
6
+ metadata.gz: 5f14736fb0832fde423dc2ba26e74d1ece531f75d886f7733ee24d5fa9796d9ce3b284abda6cac442ef554f90e6839467ccba20e7ca0dd49e5c4cef52f6e284a
7
+ data.tar.gz: 442cbb6301afb08d76ceee9b47d2015f12519ebf9c4a6124e1059baee434181f854ab82e62fcc1cfd95285cca8d49ecdfbf73a713768d289f37c443bea17faa4
data/LICENSE CHANGED
@@ -1,29 +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.
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 CHANGED
@@ -1,26 +1,26 @@
1
- # SolidusSubscriptionBoxes
2
- This project adds subscription box functionality to solidus. It allows an admin to specify some group of products to allow users to choose from every week. For example each week a customer spends $40 and is able to pick 4 of 8 different products. This is extremely pre-alpha, but if you want to use it, star the repo and I'll keep adding.
3
-
4
- Courtesy of <a href="https://www.eatlessme.at">Eat Less Meat</a>
5
-
6
- ## Installation
7
- Add this line to your application's Gemfile:
8
-
9
- ```ruby
10
- gem 'solidus_subscription_boxes'
11
- ```
12
-
13
- And then execute:
14
- ```bash
15
- $ bundle exec rake railties:install:migrations FROM=solidus_subscription_boxe
16
- $ bundle exec rake db:migrate
17
- ```
18
-
19
- ## Usage
20
- Add a link to '/get-started' and allow users to check out.
21
-
22
- ## Limitations
23
- This only works at the moment if the subscribable variant created through solidus subscriptions is the first variant. Generation of subscription options on following orders is not yet finished.
24
-
25
- ## License
26
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
1
+ # SolidusSubscriptionBoxes
2
+ This project adds subscription box functionality to solidus. It allows an admin to specify some group of products to allow users to choose from every week. For example each week a customer spends $40 and is able to pick 4 of 8 different products. This is extremely pre-alpha, but if you want to use it, star the repo and I'll keep adding.
3
+
4
+ Courtesy of <a href="https://www.eatlessme.at">Eat Less Meat</a>
5
+
6
+ ## Installation
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'solidus_subscription_boxes'
11
+ ```
12
+
13
+ And then execute:
14
+ ```bash
15
+ $ bundle exec rake railties:install:migrations FROM=solidus_subscription_boxe
16
+ $ bundle exec rake db:migrate
17
+ ```
18
+
19
+ ## Usage
20
+ Add a link to '/get-started' and allow users to check out.
21
+
22
+ ## Limitations
23
+ This only works at the moment if the subscribable variant created through solidus subscriptions is the first variant. Generation of subscription options on following orders is not yet finished.
24
+
25
+ ## License
26
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -1,47 +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
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
@@ -1,2 +1,2 @@
1
- //= link_directory ../javascripts/solidus_subscription_boxes .js
2
- //= link_directory ../stylesheets/solidus_subscription_boxes .css
1
+ //= link_directory ../javascripts/solidus_subscription_boxes .js
2
+ //= link_directory ../stylesheets/solidus_subscription_boxes .css
@@ -1,13 +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 .
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 .
@@ -1,64 +1,64 @@
1
- // Meal Selection Page
2
- function subscriptionFormatDate(date) {
3
- var monthNames = [
4
- "January", "February", "March",
5
- "April", "May", "June", "July",
6
- "August", "September", "October",
7
- "November", "December"
8
- ];
9
-
10
- var day = date.getDate();
11
- var monthIndex = date.getMonth();
12
-
13
- return monthNames[monthIndex] + ' ' + day;
14
- }
15
-
16
- $('.box-controls i').click(function(event) {
17
- var value = parseInt($(this).siblings('input').val());
18
- if(this.classList.contains('add')) {
19
- value = Math.min(value + 1, 9);
20
- } else {
21
- value = Math.max(value - 1, 0);
22
- }
23
- $(this).siblings('input').val(value);
24
-
25
-
26
- var numberOfMeals = function() {
27
- var total = 0;
28
- $('.box-controls input').each( function(element) {
29
- total = total + parseInt(this.value);
30
- });
31
- return total;
32
- }
33
-
34
- if( $('body.get_started').length > 0 ) {
35
- var submitButtonText = "Buy Now";
36
- } else {
37
- var submitButtonText = "Update My Order";
38
- }
39
-
40
- if( numberOfMeals() >= 1 ) {
41
- $('input[type=submit].meal-update').removeAttr('disabled');
42
- $('input[type=submit].meal-update').attr("value",submitButtonText);
43
- } else {
44
- $('input[type=submit].meal-update').attr("disabled","disabled");
45
- $('input[type=submit].meal-update').attr("value","Choose " + (Math.max(3 - numberOfMeals(), 0)).toString() + " More");
46
- }
47
-
48
- $('.number_more_meals').text(1 - numberOfMeals());
49
- });
50
-
51
- $(document).ajaxSuccess(function( event, xhr, settings ) {
52
- if( settings.url.match(/\/api\/v1\/subscriptions\/\d*\/skip/) ) {
53
- var actionableDate = new Date(Date.parse(xhr.responseJSON.actionable_date));
54
- $('.actionable-date-update').text(subscriptionFormatDate(actionableDate));
55
- }
56
- if( settings.url.match(/\/api\/v1\/subscriptions\/\d*\/cancel/) ) {
57
- $('.manage-subscription').remove();
58
- }
59
- if( settings.url.match(/\/api\/v1\/subscriptions\/\d*$/)) {
60
- alert("You've updated your subscription.")
61
- }
62
- });
63
-
64
-
1
+ // Meal Selection Page
2
+ function subscriptionFormatDate(date) {
3
+ var monthNames = [
4
+ "January", "February", "March",
5
+ "April", "May", "June", "July",
6
+ "August", "September", "October",
7
+ "November", "December"
8
+ ];
9
+
10
+ var day = date.getDate();
11
+ var monthIndex = date.getMonth();
12
+
13
+ return monthNames[monthIndex] + ' ' + day;
14
+ }
15
+
16
+ $('.box-controls i').click(function(event) {
17
+ var value = parseInt($(this).siblings('input').val());
18
+ if(this.classList.contains('add')) {
19
+ value = Math.min(value + 1, 9);
20
+ } else {
21
+ value = Math.max(value - 1, 0);
22
+ }
23
+ $(this).siblings('input').val(value);
24
+
25
+
26
+ var numberOfMeals = function() {
27
+ var total = 0;
28
+ $('.box-controls input').each( function(element) {
29
+ total = total + parseInt(this.value);
30
+ });
31
+ return total;
32
+ }
33
+
34
+ if( $('body.get_started').length > 0 ) {
35
+ var submitButtonText = "Buy Now";
36
+ } else {
37
+ var submitButtonText = "Update My Order";
38
+ }
39
+
40
+ if( numberOfMeals() >= 1 ) {
41
+ $('input[type=submit].meal-update').removeAttr('disabled');
42
+ $('input[type=submit].meal-update').attr("value",submitButtonText);
43
+ } else {
44
+ $('input[type=submit].meal-update').attr("disabled","disabled");
45
+ $('input[type=submit].meal-update').attr("value","Choose " + (Math.max(3 - numberOfMeals(), 0)).toString() + " More");
46
+ }
47
+
48
+ $('.number_more_meals').text(1 - numberOfMeals());
49
+ });
50
+
51
+ $(document).ajaxSuccess(function( event, xhr, settings ) {
52
+ if( settings.url.match(/\/api\/v1\/subscriptions\/\d*\/skip/) ) {
53
+ var actionableDate = new Date(Date.parse(xhr.responseJSON.actionable_date));
54
+ $('.actionable-date-update').text(subscriptionFormatDate(actionableDate));
55
+ }
56
+ if( settings.url.match(/\/api\/v1\/subscriptions\/\d*\/cancel/) ) {
57
+ $('.manage-subscription').remove();
58
+ }
59
+ if( settings.url.match(/\/api\/v1\/subscriptions\/\d*$/)) {
60
+ alert("You've updated your subscription.")
61
+ }
62
+ });
63
+
64
+
@@ -1,16 +1,16 @@
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
- */
14
-
15
- @import "solidus_subscription_boxes/subscription_box"
16
-
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
+ */
14
+
15
+ @import "solidus_subscription_boxes/subscription_box"
16
+
@@ -1,29 +1,29 @@
1
- .meal img {
2
- width: 100%;
3
- }
4
- .row-centered {
5
- text-align: center;
6
- -webkit-justify-content: center; /* Safari */
7
- justify-content: center;
8
- }
9
- .col-centered {
10
- display: inline-block;
11
- float: none;
12
- /* reset the text-align */
13
- text-align: left;
14
- /* inline-block space fix */
15
- margin-right: -4px;
16
- }
17
- .flash.notice {
18
- background-color: green;
19
- }
20
- .flash.success {
21
- background-color: green;
22
- }
23
- .meal-selector input{
24
- width: 100px;
25
- }
26
- .box-controls i {
27
- cursor: pointer;
28
- }
29
-
1
+ .meal img {
2
+ width: 100%;
3
+ }
4
+ .row-centered {
5
+ text-align: center;
6
+ -webkit-justify-content: center; /* Safari */
7
+ justify-content: center;
8
+ }
9
+ .col-centered {
10
+ display: inline-block;
11
+ float: none;
12
+ /* reset the text-align */
13
+ text-align: left;
14
+ /* inline-block space fix */
15
+ margin-right: -4px;
16
+ }
17
+ .flash.notice {
18
+ background-color: green;
19
+ }
20
+ .flash.success {
21
+ background-color: green;
22
+ }
23
+ .meal-selector input{
24
+ width: 100px;
25
+ }
26
+ .box-controls i {
27
+ cursor: pointer;
28
+ }
29
+