Skip to content

Commit 538168e

Browse files
committed
fix module name
1 parent e48669d commit 538168e

File tree

2 files changed

+18
-22
lines changed

2 files changed

+18
-22
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class CommunityCustomFields::CustomFieldsController < ::ApplicationController
2+
before_action :ensure_logged_in
3+
before_action :ensure_admin
4+
5+
def update
6+
topic = Topic.find(params[:topic_id])
7+
custom = params[:custom_field] || params.permit(:assignee_id, :status)
8+
topic.custom_fields["assignee_id"] = custom[:assignee_id].to_i if custom[:assignee_id].present?
9+
topic.custom_fields["status"] = custom[:status] if custom[:status].present?
10+
if topic.save_custom_fields
11+
render json: success_json
12+
else
13+
Rails.logger.error("Failed to save custom fields for topic #{topic.id}: #{topic.errors.full_messages}")
14+
render json: { error: topic.errors.full_messages }, status: 422
15+
end
16+
end
17+
end

plugin.rb

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,13 @@
88

99
enabled_site_setting :community_custom_fields_enabled
1010

11-
module ::DiscourseSolved
11+
module ::CommunityCustomFields
1212
PLUGIN_NAME = "community-custom-fields"
1313
end
1414

1515
require_relative 'lib/community_custom_fields/engine.rb'
1616

1717
after_initialize do
18-
require_dependency 'application_controller'
19-
class CommunityCustomFields::CustomFieldsController < ::ApplicationController
20-
before_action :ensure_logged_in
21-
before_action :ensure_admin
22-
23-
def update
24-
topic = Topic.find(params[:topic_id])
25-
custom = params[:custom_field] || params.permit(:assignee_id, :status)
26-
topic.custom_fields["assignee_id"] = custom[:assignee_id].to_i if custom[:assignee_id].present?
27-
topic.custom_fields["status"] = custom[:status] if custom[:status].present?
28-
if topic.save_custom_fields
29-
render json: success_json
30-
else
31-
Rails.logger.error("Failed to save custom fields for topic #{topic.id}: #{topic.errors.full_messages}")
32-
render json: { error: topic.errors.full_messages }, status: 422
33-
end
34-
end
35-
end
36-
37-
#############################################################################
38-
3918
Topic.register_custom_field_type('assignee_id', :integer)
4019
Topic.register_custom_field_type('status', :string)
4120

0 commit comments

Comments
 (0)