Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
shotengai
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
shotengai
Commits
507a69ba
Commit
507a69ba
authored
Sep 29, 2017
by
ivan Lan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the strength params' bug
parent
fbf6aff1
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
24 additions
and
16 deletions
+24
-16
product_snapshots_controller.rb
...engai/controller/customer/product_snapshots_controller.rb
+4
-2
product_series_controller.rb
...hotengai/controller/merchant/product_series_controller.rb
+6
-3
products_controller.rb
lib/shotengai/controller/merchant/products_controller.rb
+6
-5
json_column.rb
lib/shotengai/json_column.rb
+4
-2
order.rb
lib/shotengai/order.rb
+1
-1
product.rb
lib/shotengai/product.rb
+1
-1
series.rb
lib/shotengai/series.rb
+1
-1
snapshot.rb
lib/shotengai/snapshot.rb
+1
-1
No files found.
lib/shotengai/controller/customer/product_snapshots_controller.rb
View file @
507a69ba
...
...
@@ -30,9 +30,11 @@ module Shotengai
private
def
resource_params
remark_input
=
params
.
require
(
resource_key
).
fetch
(
:remark_input
,
nil
)
&
.
map
(
&
:permit!
)
params
.
require
(
resource_key
).
permit
(
:count
,
:shotengai_series_id
,
remark_input:
[
:key
,
:val
]
)
:count
,
:shotengai_series_id
)
.
merge
({
remark_input:
remark_input
})
end
def
edit_only_unpaid
...
...
lib/shotengai/controller/merchant/product_series_controller.rb
View file @
507a69ba
...
...
@@ -12,6 +12,7 @@ module Shotengai
params
[
:product_id
]
&&
{
shotengai_product_id:
params
[
:product_id
]
}
)
end
def
recycle_bin
page
=
params
[
:page
]
||
1
per_page
=
params
[
:per_page
]
||
10
...
...
@@ -38,12 +39,14 @@ module Shotengai
private
def
resource_params
spec
=
params
.
require
(
resource_key
).
fetch
(
:spec
,
nil
).
try
(
:permit!
)
spec
_input
=
params
.
require
(
resource_key
).
fetch
(
:spec_input
,
nil
)
&
.
map
(
&
:permit!
)
meta
=
params
.
require
(
resource_key
).
fetch
(
:meta
,
nil
).
try
(
:permit!
)
# ????????!!!!!, spec_input: [:key, :val] 一样的输出值 却在test报错???
# QUESTION: WARNING: 文档bug吧?????
params
.
require
(
resource_key
).
permit
(
:original_price
,
:price
,
:stock
:original_price
,
:price
,
:stock
#, spec_input: [:key, :val]
).
merge
(
{
spec
:
spec
,
meta:
meta
}
{
spec
_input:
spec_input
,
meta:
meta
}
)
end
...
...
lib/shotengai/controller/merchant/products_controller.rb
View file @
507a69ba
...
...
@@ -62,19 +62,20 @@ module Shotengai
private
def
resource_params
# QUESTION: need these ?
spec
=
params
.
require
(
resource_key
).
fetch
(
:spec
,
nil
).
try
(
:permit!
)
# spec = params.require(resource_key).fetch(:spec, nil).try(:permit!)
spec_input
=
params
.
require
(
resource_key
).
fetch
(
:spec_input
,
nil
)
&
.
map
(
&
:permit!
)
remark_input
=
params
.
require
(
resource_key
).
fetch
(
:remark_input
,
nil
)
&
.
map
(
&
:permit!
)
detail
=
params
.
require
(
resource_key
).
fetch
(
:detail
,
nil
).
try
(
:permit!
)
meta
=
params
.
require
(
resource_key
).
fetch
(
:meta
,
nil
).
try
(
:permit!
)
remark
=
params
.
require
(
resource_key
).
fetch
(
:remark
,
nil
).
try
(
:permit!
)
# NOTE: :catalog_list is a default catalog list for template example, maybe should move it to the template controller, but it need add controller template for every controller
params
.
require
(
resource_key
).
permit
(
:title
,
:default_series_id
,
:need_express
,
:need_time_attr
,
:cover_image
,
catalog_ids:
[],
banners:
[],
spec_input:
[
:key
,
val:
[]],
detail_input:
[
:key
,
:val
],
meta_input:
[
:key
,
:val
],
remark_input:
[
:key
,
:val
]
# spec_input: [:key, val: []],
# remark_input: [:key, :val],
).
merge
(
{
spec
:
spec
,
detail:
detail
,
meta:
meta
,
remark:
remark
}
{
spec
_input:
spec_input
,
remark_input:
remark_input
,
detail:
detail
,
meta:
meta
}
)
end
end
...
...
lib/shotengai/json_column.rb
View file @
507a69ba
...
...
@@ -5,7 +5,7 @@ module Shotengai
end
class_methods
do
def
hash_columns
*
columns
def
custom_
hash_columns
*
columns
columns
.
each
do
|
column
|
# QUESTION: 这样可以避免 send("#{column}="), 合适?
class_eval
%Q{
...
...
@@ -14,8 +14,10 @@ module Shotengai
end
define_method("
#{
column
}
_input=") do |val|
parsed_val = val.map{ |h| { (h[:key] || h['key']) => (h[:val] || h['val']) } }.reduce(&:merge)
parsed_val = val
&& val
.map{ |h| { (h[:key] || h['key']) => (h[:val] || h['val']) } }.reduce(&:merge)
self.
#{
column
}
= parsed_val
# self.assign_attributes('
#{
column
}
' => parsed_val)
end
define_method("
#{
column
}
_output") do
...
...
lib/shotengai/order.rb
View file @
507a69ba
...
...
@@ -38,7 +38,7 @@ module Shotengai
after_create
:set_seq
hash_columns
:spec
,
:meta
custom_
hash_columns
:spec
,
:meta
include
AASM_DLC
aasm
column: :status
do
...
...
lib/shotengai/product.rb
View file @
507a69ba
...
...
@@ -30,7 +30,7 @@ module Shotengai
require
'acts-as-taggable-on'
self
.
table_name
=
'shotengai_products'
hash_columns
:spec
,
:meta
,
:detail
,
:remark
custom_hash_columns
:spec
,
:remark
belongs_to
:manager
,
polymorphic:
true
,
optional:
true
#, touch: true
validate
:check_spec
,
if: :spec
...
...
lib/shotengai/series.rb
View file @
507a69ba
...
...
@@ -29,7 +29,7 @@ module Shotengai
# Using validates_uniqueness_of do not work if the order of Hash is diff
validate
:uniq_spec
hash_columns
:spec
,
:meta
,
:remark
custom_hash_columns
:spec
,
:remark
delegate
:title
,
:detail
,
:banners
,
:cover_image
,
:status
,
:status_zh
,
:manager
,
to: :product
...
...
lib/shotengai/snapshot.rb
View file @
507a69ba
...
...
@@ -36,7 +36,7 @@ module Shotengai
validate
:check_remark
validates
:count
,
numericality:
{
only_integer:
true
,
greater_than:
0
}
hash_columns
:spec
,
:meta
,
:detail
,
:remark
custom_
hash_columns
:spec
,
:meta
,
:detail
,
:remark
validate
:cannot_edit
,
if: :order_was_paid
before_destroy
:cannot_edit
,
if: :order_was_paid
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment