mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 14:12:10 +08:00
DEV: Use more specific error responses (#9472)
* DEV: Use `render_json_error` (Adds specs for Admin::GroupsController) * DEV: Use a specific error on blank category slug (Fixes a `render_json_error` warning) * DEV: Use a specific error on reviewable claim conflict (Fixes a `render_json_error` warning) * DEV: Use specific errors in Admin::UsersController (Fixes `render_json_error` warnings) * FIX: PublishedPages error responses * FIX: TopicsController error responses (There was an issue of two separate `Topic` instances for the same record. This makes sure there's only one up-to-date instance.)
This commit is contained in:
@ -197,7 +197,9 @@ class Admin::UsersController < Admin::AdminController
|
||||
|
||||
def add_group
|
||||
group = Group.find(params[:group_id].to_i)
|
||||
return render_json_error group unless group && !group.automatic
|
||||
|
||||
raise Discourse::NotFound unless group
|
||||
return render_json_error(I18n.t('groups.errors.can_not_modify_automatic')) if group.automatic
|
||||
|
||||
group.add(@user)
|
||||
GroupActionLogger.new(current_user, group).log_add_user_to_group(@user)
|
||||
@ -207,7 +209,9 @@ class Admin::UsersController < Admin::AdminController
|
||||
|
||||
def remove_group
|
||||
group = Group.find(params[:group_id].to_i)
|
||||
return render_json_error group unless group && !group.automatic
|
||||
|
||||
raise Discourse::NotFound unless group
|
||||
return render_json_error(I18n.t('groups.errors.can_not_modify_automatic')) if group.automatic
|
||||
|
||||
group.remove(@user)
|
||||
GroupActionLogger.new(current_user, group).log_remove_user_from_group(@user)
|
||||
|
Reference in New Issue
Block a user