support setting category slug

This commit is contained in:
Erick Guan
2014-12-20 22:07:29 +08:00
parent 1055fc0919
commit 1e166d89ff
11 changed files with 92 additions and 15 deletions

View File

@ -95,6 +95,19 @@ class CategoriesController < ApplicationController
end
end
def update_slug
@category = Category.find(params[:category_id].to_i)
guardian.ensure_can_edit!(@category)
custom_slug = params[:slug].to_s
if custom_slug.present? && @category.update_attributes(slug: custom_slug)
render json: success_json
else
render_json_error(@category)
end
end
def set_notifications
category_id = params[:category_id].to_i
notification_level = params[:notification_level].to_i