Skip to content

Commit 8e4f6bd

Browse files
committed
Allow create and update of features
1 parent 98ad5f2 commit 8e4f6bd

File tree

3 files changed

+19
-59
lines changed

3 files changed

+19
-59
lines changed

app/controllers/v1/admin/features_controller.rb

+9-49
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ def show
1010
end
1111

1212
def create
13-
forbidden
13+
allow_create
1414
end
1515

1616
def update
17-
forbidden
17+
allow_update
1818
end
1919

2020
def destroy
@@ -31,58 +31,18 @@ def serializer_klass
3131
V1::Admin::FeatureSerializer
3232
end
3333

34-
def creatable_attributes
35-
%[]
36-
# %i[
37-
# name
38-
# company
39-
# email
40-
# mobile
41-
# message
42-
# purpose
43-
# source
44-
# ip
45-
# ip_region
46-
# ip_city
47-
# ]
48-
end
49-
50-
def creatable_relationships
51-
%[]
52-
# %i[
53-
# country
54-
# ip_country
55-
# ]
56-
end
57-
5834
def permitted_filters
59-
%[]
60-
# %i[
61-
# main_group_id
62-
# sub_group_id
63-
# ]
64-
end
65-
66-
def permanent_filters
67-
{}
68-
# {
69-
# public: true
70-
# }
35+
%i[
36+
category
37+
]
7138
end
7239

7340
def permitted_includes
74-
%[]
75-
# %i[
76-
# related_articles
77-
# related_products
78-
# related_products.main_group
79-
# translations
80-
# ]
41+
%i[
42+
products
43+
products.image
44+
]
8145
end
82-
83-
# def after_create(lead)
84-
# PostLeadToSlackJob.perform_later lead
85-
# end
8646
end
8747
end
8848
end
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
module V1
22
module Admin
33
class FeatureSerializer < ApplicationSerializer
4-
# attributes :slug,
5-
# :name,
6-
# :public
4+
attributes :slug,
5+
:text,
6+
:icon,
7+
:gist,
8+
:category,
9+
:has_page
710

8-
# belongs_to :thing
9-
# belongs_to :main_group, record_type: :product_group, serializer: :product_group
10-
# belongs_to :sub_group, record_type: :product_group, serializer: :product_group
11-
12-
# has_many :things
13-
# has_many :related_products, record_type: :product, serializer: :related_products
14-
# has_many :related_articles, record_type: :article, serializer: :related_articles
11+
has_many :products, if: Proc.new { |record, params|
12+
params && params['include'] && params['include'].split(',').include?('products')
13+
}
1514
end
1615
end
1716
end

config/routes.rb

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
resources :countries
4343
resources :documents
4444
resources :document_categories, path: '/document-categories'
45+
resources :features
4546
resources :images
4647
resources :languages
4748
resources :leads

0 commit comments

Comments
 (0)