-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Permitted attributes improvements #1112
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,34 +2,58 @@ module Spree | |
module Core | ||
module ControllerHelpers | ||
module StrongParameters | ||
def permitted_attributes | ||
def base_attributes | ||
Spree::PermittedAttributes | ||
end | ||
|
||
delegate(*Spree::PermittedAttributes::ATTRIBUTES, | ||
to: :permitted_attributes, | ||
to: :base_attributes, | ||
prefix: :permitted) | ||
|
||
def admin_attributes | ||
Spree::PermittedAttributes::Admin | ||
end | ||
|
||
delegate(*Spree::PermittedAttributes::Admin::ATTRIBUTES, | ||
to: :admin_attributes, | ||
prefix: :permitted_admin) | ||
|
||
def permitted_credit_card_update_attributes | ||
permitted_attributes.credit_card_update_attributes + [ | ||
base_attributes.credit_card_update_attributes + [ | ||
address_attributes: permitted_address_attributes | ||
] | ||
end | ||
|
||
def permitted_line_item_attributes | ||
base_attributes.line_item_attributes + [ | ||
options: base_attributes.line_item_option_attributes | ||
] | ||
end | ||
|
||
def permitted_admin_line_item_attributes | ||
base_attributes.line_item_attributes + admin_attributes.line_item_attributes + [ | ||
<<<<<<< HEAD | ||
options: base_attributes.line_item_option_attributes + admin_attributes.line_item_option_attributes | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unexpected token tCOLON |
||
======= | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unexpected token tEQQ |
||
options: base_attributes.line_item_option_attributes + admin_attributes.line_item_option_attributes | ||
>>>>>>> 3862505... Simplify order_contents line_item add | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unexpected token tRSHFT |
||
] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unexpected token tRBRACK |
||
end | ||
|
||
def permitted_payment_attributes | ||
permitted_attributes.payment_attributes + [ | ||
base_attributes.payment_attributes + [ | ||
source_attributes: permitted_source_attributes | ||
] | ||
end | ||
|
||
def permitted_source_attributes | ||
permitted_attributes.source_attributes + [ | ||
base_attributes.source_attributes + [ | ||
address_attributes: permitted_address_attributes | ||
] | ||
end | ||
|
||
def permitted_checkout_attributes | ||
permitted_attributes.checkout_attributes + [ | ||
base_attributes.checkout_attributes + [ | ||
bill_address_attributes: permitted_address_attributes, | ||
ship_address_attributes: permitted_address_attributes, | ||
payments_attributes: permitted_payment_attributes, | ||
|
@@ -43,14 +67,20 @@ def permitted_order_attributes | |
] | ||
end | ||
|
||
def permitted_admin_order_attributes | ||
permitted_checkout_attributes + admin_attributes.order_attributes + [ | ||
line_items_attributes: permitted_admin_line_item_attributes | ||
] | ||
end | ||
|
||
def permitted_product_attributes | ||
permitted_attributes.product_attributes + [ | ||
base_attributes.product_attributes + [ | ||
product_properties_attributes: permitted_product_properties_attributes | ||
] | ||
end | ||
|
||
def permitted_user_attributes | ||
permitted_attributes.user_attributes + [ | ||
base_attributes.user_attributes + [ | ||
bill_address_attributes: permitted_address_attributes, | ||
ship_address_attributes: permitted_address_attributes | ||
] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module Spree | ||
module PermittedAttributes | ||
module Admin | ||
ATTRIBUTES = [ | ||
:line_item_attributes, | ||
:line_item_option_attributes, | ||
:order_attributes, | ||
:shipment_attributes | ||
] | ||
|
||
mattr_reader(*ATTRIBUTES) | ||
|
||
@@line_item_attributes = [:sku] | ||
|
||
@@line_item_option_attributes = [:price] | ||
|
||
@@line_item_option_attributes = [] | ||
|
||
@@order_attributes = [:import, :number, :completed_at, :locked_at, :channel, :user_id, :created_at] | ||
|
||
@@shipment_attributes = [:shipping_method, :stock_location, inventory_units: [:variant_id, :sku]] + PermittedAttributes.shipment_attributes | ||
end | ||
end | ||
end |
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.
unexpected token tLSHFT
(Using Ruby 2.3 parser; configure using
TargetRubyVersion
parameter, underAllCops
)