2019-07-30 21:29:24 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-06-12 20:03:43 +00:00
|
|
|
# License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
|
|
|
|
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
|
2018-03-25 17:30:42 +00:00
|
|
|
module Nonprofits
|
2019-07-30 21:29:24 +00:00
|
|
|
class CustomFieldMastersController < ApplicationController
|
2020-05-11 18:38:50 +00:00
|
|
|
include Controllers::Nonprofit::Current
|
2021-02-04 17:09:02 +00:00
|
|
|
include Controllers::Nonprofit::Authorization
|
2019-07-30 21:29:24 +00:00
|
|
|
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
|
2021-02-04 17:09:02 +00:00
|
|
|
json_saved CreateCustomFieldMaster.create(current_nonprofit, custom_field_master_params[:custom_field_master])
|
2019-07-30 21:29:24 +00:00
|
|
|
end
|
2018-03-25 17:30:42 +00:00
|
|
|
|
2019-07-30 21:29:24 +00:00
|
|
|
def destroy
|
2021-02-04 17:09:02 +00:00
|
|
|
current_custom_field_definition.discard!
|
|
|
|
current_custom_field_definition.custom_field_joins.destroy_all
|
2019-07-30 21:29:24 +00:00
|
|
|
render json: {}, status: :ok
|
|
|
|
end
|
2019-08-06 12:48:40 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def custom_field_master_params
|
2021-02-04 17:09:02 +00:00
|
|
|
params.require(:custom_field_master).permit( :name)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def current_custom_field_definition
|
|
|
|
current_nonprofit.custom_field_masters.find(params[:id])
|
2019-08-06 12:48:40 +00:00
|
|
|
end
|
2019-07-30 21:29:24 +00:00
|
|
|
end
|
2018-03-25 17:30:42 +00:00
|
|
|
end
|