-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
upgraded controllers and models to modules also upgraded overrides an… #66
Open
rishabhguptarishi
wants to merge
9
commits into
master
Choose a base branch
from
update_version_one
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a12c622
upgraded controllers and models to modules also upgraded overrides an…
4d8a1fc
removed func from order_decorator upgraded view and decorator
de25ceb
added translations in en
aaabf51
removed quantity and subscribe button from extension
71ea88a
fixed subscribable options hidden class
0450149
Fixed zietwerk check error
d9c5a47
added heroku button for spree 4.1
rishabhguptarishi 9c4d34f
removed commented code and fixed product show overrides
4222d9b
Merge remote-tracking branch 'origin/update_version_one' into update_…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
app/assets/javascripts/spree/frontend/cart_form_subscription_button.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Spree.ready(function($) { | ||
Spree.addToCartFormSubmissionOptions = function() { | ||
$cartForm = $(ADD_TO_CART_FORM_SELECTOR); | ||
if($cartForm.find('.cart_radio_button:checked').val() == ".subscription_options") { | ||
options = { | ||
subscribe: true, | ||
subscription_frequency_id: $cartForm.find('#subscription_subscription_frequency_id option:selected').val(), | ||
delivery_number: parseInt($cartForm.find('#subscription_delivery_number').val()) | ||
}; | ||
return options; | ||
} | ||
return {}; | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
app/assets/javascripts/spree/frontend/spree_product_subscriptions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
// Placeholder manifest file. | ||
//= require spree/frontend/cart_radio_button.js | ||
//= require spree/frontend/datepicker | ||
//= require spree/frontend/cart_form_subscription_button | ||
//= require spree/frontend/ajax_handler.js | ||
//= require spree/frontend/update_quantity_in_cart | ||
// the installer will append this file to the app vendored assets here: vendor/assets/javascripts/spree/frontend/all.js' |
5 changes: 0 additions & 5 deletions
5
app/controllers/spree/api/v1/line_items_controller_decorator.rb
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
app/controllers/spree_product_subscriptions/base_controller_decorator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module SpreeProductSubscriptions | ||
module BaseControllerDecorator | ||
|
||
def self.prepended(base) | ||
base.add_flash_types :success, :error | ||
end | ||
|
||
end | ||
end | ||
|
||
Spree::BaseController.prepend SpreeProductSubscriptions::BaseControllerDecorator |
10 changes: 10 additions & 0 deletions
10
app/controllers/spree_product_subscriptions/line_items_controller_decorator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module SpreeProductSubscriptions::LineItemsControllerDecorator | ||
|
||
def self.prepended(base) | ||
base.line_item_options += [:subscribe, :delivery_number, :subscription_frequency_id] | ||
end | ||
|
||
|
||
end | ||
|
||
Spree::Api::V1::LineItemsController.prepend SpreeProductSubscriptions::LineItemsControllerDecorator |
14 changes: 14 additions & 0 deletions
14
app/controllers/spree_product_subscriptions/orders_controller_decorator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module SpreeProductSubscriptions::OrdersControllerDecorator | ||
|
||
def self.prepended(base) | ||
base.before_action :restrict_guest_subscription, only: :update, unless: :spree_current_user | ||
end | ||
|
||
private | ||
|
||
def restrict_guest_subscription | ||
redirect_to login_path, error: Spree.t(:required_authentication) if @order.subscriptions.present? | ||
end | ||
end | ||
|
||
Spree::OrdersController.prepend SpreeProductSubscriptions::OrdersControllerDecorator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
app/controllers/spree_product_subscriptions/users_controller_decorator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module SpreeProductSubscriptions::UsersControllerDecorator | ||
|
||
def self.prepended(base) | ||
base.before_action :load_subscriptions, only: :show | ||
end | ||
|
||
private | ||
|
||
def load_subscriptions | ||
@orders = @user.orders.complete.order(completed_at: :desc) | ||
@subscriptions = Spree::Subscription.active.order(created_at: :desc).with_parent_orders(@orders) | ||
end | ||
|
||
end | ||
|
||
Spree::UsersController.prepend SpreeProductSubscriptions::UsersControllerDecorator |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
module SpreeProductSubscriptions::OrderDecorator | ||
|
||
def self.prepended(base) | ||
base.has_one :order_subscription, class_name: "Spree::OrderSubscription", dependent: :destroy | ||
base.has_one :parent_subscription, through: :order_subscription, source: :subscription | ||
base.has_many :subscriptions, class_name: "Spree::Subscription", | ||
foreign_key: :parent_order_id, | ||
dependent: :restrict_with_error | ||
base.after_update :update_subscriptions | ||
base.state_machine.after_transition to: :complete, do: :enable_subscriptions, if: :any_disabled_subscription? | ||
base.alias_attribute :guest_token, :token | ||
end | ||
|
||
private | ||
|
||
def enable_subscriptions | ||
subscriptions.each do |subscription| | ||
subscription.update( | ||
source: payments.from_credit_card.first.source, | ||
enabled: true, | ||
ship_address: ship_address.clone, | ||
bill_address: bill_address.clone | ||
) | ||
end | ||
end | ||
|
||
def any_disabled_subscription? | ||
subscriptions.disabled.any? | ||
end | ||
|
||
def update_subscriptions | ||
line_items.each do |line_item| | ||
if line_item.subscription_attributes_present? | ||
subscriptions.find_by(variant: line_item.variant).update(line_item.updatable_subscription_attributes) | ||
end | ||
end | ||
end | ||
end | ||
|
||
Spree::Order.prepend SpreeProductSubscriptions::OrderDecorator |
15 changes: 15 additions & 0 deletions
15
app/models/spree_product_subscriptions/product_decorator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module SpreeProductSubscriptions::ProductDecorator | ||
|
||
def self.prepended(base) | ||
base.has_many :subscriptions, through: :variants_including_master, source: :subscriptions, dependent: :restrict_with_error | ||
base.has_many :product_subscription_frequencies, class_name: "Spree::ProductSubscriptionFrequency", dependent: :destroy | ||
base.has_many :subscription_frequencies, through: :product_subscription_frequencies, dependent: :destroy | ||
base.validates :subscription_frequencies, presence: true, if: :subscribable? | ||
base.scope :subscribable, -> { where(subscribable: true) } | ||
base.whitelisted_ransackable_attributes += %w( is_subscribable ) | ||
base.alias_attribute :subscribable, :is_subscribable | ||
end | ||
|
||
end | ||
|
||
Spree::Product.prepend SpreeProductSubscriptions::ProductDecorator |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets discuss