2020-06-07 08:28:05 +00:00
|
|
|
class Api::V1::Accounts::LabelsController < Api::V1::Accounts::BaseController
|
2020-06-07 05:47:13 +00:00
|
|
|
before_action :current_account
|
|
|
|
before_action :fetch_label, except: [:index, :create]
|
|
|
|
before_action :check_authorization
|
|
|
|
|
2020-03-09 17:57:10 +00:00
|
|
|
def index
|
2020-06-07 08:28:05 +00:00
|
|
|
@labels = policy_scope(Current.account.labels)
|
2020-06-07 05:47:13 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def show; end
|
|
|
|
|
|
|
|
def create
|
2020-06-07 08:28:05 +00:00
|
|
|
@label = Current.account.labels.create!(permitted_params)
|
2020-06-07 05:47:13 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@label.update(permitted_params)
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@label.destroy
|
|
|
|
head :ok
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def fetch_label
|
2020-06-07 08:28:05 +00:00
|
|
|
@label = Current.account.labels.find(params[:id])
|
2020-06-07 05:47:13 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def check_authorization
|
|
|
|
authorize(Label)
|
2019-08-14 09:48:44 +00:00
|
|
|
end
|
2020-02-02 10:59:18 +00:00
|
|
|
|
2020-06-07 05:47:13 +00:00
|
|
|
def permitted_params
|
|
|
|
params.require(:label).permit(:title, :description, :color, :show_on_sidebar)
|
2020-02-02 10:59:18 +00:00
|
|
|
end
|
2019-08-14 09:48:44 +00:00
|
|
|
end
|