mirror of
https://github.com/discourse/discourse.git
synced 2025-01-30 05:51:03 +08:00
FEATURE: serialize and update category custom_fields
- send to client - update from client
This commit is contained in:
parent
79027c2775
commit
e3fa27a01c
|
@ -75,7 +75,8 @@ Discourse.Category = Discourse.Model.extend({
|
||||||
parent_category_id: this.get('parent_category_id'),
|
parent_category_id: this.get('parent_category_id'),
|
||||||
logo_url: this.get('logo_url'),
|
logo_url: this.get('logo_url'),
|
||||||
background_url: this.get('background_url'),
|
background_url: this.get('background_url'),
|
||||||
allow_badges: this.get('allow_badges')
|
allow_badges: this.get('allow_badges'),
|
||||||
|
custom_fields: this.get('custom_fields')
|
||||||
},
|
},
|
||||||
type: this.get('id') ? 'PUT' : 'POST'
|
type: this.get('id') ? 'PUT' : 'POST'
|
||||||
});
|
});
|
||||||
|
|
|
@ -146,6 +146,7 @@ class CategoriesController < ApplicationController
|
||||||
:background_url,
|
:background_url,
|
||||||
:allow_badges,
|
:allow_badges,
|
||||||
:slug,
|
:slug,
|
||||||
|
:custom_fields => [params[:custom_fields].try(:keys)],
|
||||||
:permissions => [*p.try(:keys)])
|
:permissions => [*p.try(:keys)])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,7 +10,8 @@ class CategorySerializer < BasicCategorySerializer
|
||||||
:email_in_allow_strangers,
|
:email_in_allow_strangers,
|
||||||
:can_delete,
|
:can_delete,
|
||||||
:cannot_delete_reason,
|
:cannot_delete_reason,
|
||||||
:allow_badges
|
:allow_badges,
|
||||||
|
:custom_fields
|
||||||
|
|
||||||
def group_permissions
|
def group_permissions
|
||||||
@group_permissions ||= begin
|
@group_permissions ||= begin
|
||||||
|
|
|
@ -162,8 +162,12 @@ describe CategoriesController do
|
||||||
permissions: {
|
permissions: {
|
||||||
"everyone" => readonly,
|
"everyone" => readonly,
|
||||||
"staff" => create_post
|
"staff" => create_post
|
||||||
|
},
|
||||||
|
custom_fields: {
|
||||||
|
"dancing" => "frogs"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(200)
|
||||||
@category.reload
|
@category.reload
|
||||||
expect(@category.category_groups.map{|g| [g.group_id, g.permission_type]}.sort).to eq([
|
expect(@category.category_groups.map{|g| [g.group_id, g.permission_type]}.sort).to eq([
|
||||||
|
@ -173,6 +177,7 @@ describe CategoriesController do
|
||||||
expect(@category.slug).to eq("hello-category")
|
expect(@category.slug).to eq("hello-category")
|
||||||
expect(@category.color).to eq("ff0")
|
expect(@category.color).to eq("ff0")
|
||||||
expect(@category.auto_close_hours).to eq(72)
|
expect(@category.auto_close_hours).to eq(72)
|
||||||
|
expect(@category.custom_fields).to eq({"dancing" => "frogs"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user