2019-07-30 21:29:24 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-25 16:15:39 +00:00
|
|
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
2018-03-25 17:30:42 +00:00
|
|
|
module Nonprofits
|
2019-07-30 21:29:24 +00:00
|
|
|
class CustomFieldMastersController < ApplicationController
|
|
|
|
include Controllers::NonprofitHelper
|
|
|
|
before_action :authenticate_nonprofit_user!
|
2018-03-25 17:30:42 +00:00
|
|
|
|
2019-07-30 21:29:24 +00:00
|
|
|
def index
|
|
|
|
@custom_field_masters = current_nonprofit
|
|
|
|
.custom_field_masters
|
|
|
|
.order('id DESC')
|
|
|
|
.not_deleted
|
|
|
|
end
|
2018-03-25 17:30:42 +00:00
|
|
|
|
2019-07-30 21:29:24 +00:00
|
|
|
def create
|
|
|
|
json_saved CreateCustomFieldMaster.create(current_nonprofit, params[:custom_field_master])
|
|
|
|
end
|
2018-03-25 17:30:42 +00:00
|
|
|
|
2019-07-30 21:29:24 +00:00
|
|
|
def destroy
|
|
|
|
custom_field_master = current_nonprofit.custom_field_masters.find(params[:id])
|
|
|
|
custom_field_master.update_attribute(:deleted, true)
|
|
|
|
custom_field_master.custom_field_joins.destroy_all
|
|
|
|
render json: {}, status: :ok
|
|
|
|
end
|
2019-08-06 12:48:40 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def custom_field_master_params
|
|
|
|
params.require(:custom_field_master).permit(:nonprofit, :nonprofit_id, :name, :deleted, :created_at)
|
|
|
|
end
|
2019-07-30 21:29:24 +00:00
|
|
|
end
|
2018-03-25 17:30:42 +00:00
|
|
|
end
|