solidus_subscription_boxes 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) 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 +6 -6
  12. data/app/decorators/solidus_subscriptions/models/checkout/update_preference_decorator.rb +14 -14
  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 -32
  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 +11 -11
  18. data/app/helpers/solidus_subscription_boxes/application_helper.rb +19 -19
  19. data/app/jobs/solidus_subscription_boxes/application_job.rb +4 -4
  20. data/app/mailers/solidus_subscription_boxes/application_mailer.rb +6 -6
  21. data/app/models/solidus_subscription_boxes/application_record.rb +5 -5
  22. data/app/models/solidus_subscription_boxes/box_preference.rb +10 -10
  23. data/app/models/solidus_subscription_boxes/subscription_period.rb +15 -15
  24. data/app/models/solidus_subscription_boxes/subscription_periods_variant.rb +6 -6
  25. data/app/overrides/views/admin_boxable_checkbox.rb +5 -5
  26. data/app/views/layouts/solidus_subscription_boxes/application.html.erb +14 -14
  27. data/app/views/solidus_subscription_boxes/subscription_boxes/_box_variants.html.erb +14 -14
  28. data/app/views/solidus_subscription_boxes/subscription_boxes/_manage.html.erb +39 -39
  29. data/app/views/solidus_subscription_boxes/subscription_boxes/get_started.html.erb +52 -52
  30. data/app/views/spree/admin/products/_boxable_checkbox.html.erb +8 -8
  31. data/app/views/spree/admin/variants/_boxable_checkbox.html.erb +8 -8
  32. data/config/routes.rb +4 -4
  33. data/db/migrate/20170609065436_create_solidus_subscription_boxes_box_preferences.rb +10 -10
  34. data/db/migrate/20170906015531_create_solidus_subscription_boxes_subscription_periods.rb +9 -9
  35. data/db/migrate/20170906021159_create_solidus_subscription_boxes_subscription_periods_variants.rb +10 -10
  36. data/db/migrate/20170919054537_add_boxable_to_spree_variants.rb +5 -5
  37. data/db/migrate/20170919063437_add_boxable_variant_id_to_solidus_subscription_boxes_subscription_periods.rb +5 -5
  38. data/lib/solidus_subscription_boxes.rb +4 -4
  39. data/lib/solidus_subscription_boxes/engine.rb +13 -13
  40. data/lib/solidus_subscription_boxes/version.rb +3 -3
  41. data/lib/tasks/solidus_subscription_boxes_tasks.rake +4 -4
  42. data/test/integration/navigation_test.rb +8 -8
  43. data/test/solidus_subscription_boxes_test.rb +7 -7
  44. data/test/test_helper.rb +21 -21
  45. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 740020abd07abef6f2e96111c793d59a2601ef43
4
- data.tar.gz: 8ef8dc734f71d13fa32a433eeff6eaa34b593978
3
+ metadata.gz: 72755f6a439f93898414ca58d982f1bed1079658
4
+ data.tar.gz: f0780f80eca5136441832fcfec2c66e705fd63fc
5
5
  SHA512:
6
- metadata.gz: 167f1577782a1a3f3197e162496885bbac61be3d3dbd01598522bdd32023ea430eff220f0d6ea9a2f3535493bc4e486558c5c5b3d11885981fa84a1de608bdaf
7
- data.tar.gz: 3ce9730257a7caf7b392269a0abfe96e2958845e2effbfb9f2614744f58d99899acc53c61c2bc65caa291baa1402712f749794e8cce35bd438c3a559d8d33b68
6
+ metadata.gz: d769410f80007a2e0ad2e60506285e4c7833a8b5e4a14b500b1e093d770e85efbe8d3113e9b8cd8cbd7a59a2b79a24bde04546337b8e8999caec0596db72ebdd
7
+ data.tar.gz: 49e4b9db18d7466b0f6d0daf804b027ec4f7241a80f02c62cb73f6ff0e8a04560572c16364273e937bc39905e0785d060fccce562d4ad2d90288dc5aecd2d661
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
+