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 SupporterNotesController < ApplicationController
|
|
|
|
include Controllers::NonprofitHelper
|
2018-03-25 17:30:42 +00:00
|
|
|
|
2019-07-30 21:29:24 +00:00
|
|
|
before_action :authenticate_nonprofit_user!, except: [:create]
|
2018-03-25 17:30:42 +00:00
|
|
|
|
2019-07-30 21:29:24 +00:00
|
|
|
# post /nonprofits/:nonprofit_id/supporters/:supporter_id/supporter_notes
|
|
|
|
def create
|
|
|
|
params[:supporter_note][:user_id] ||= current_user&.id
|
2019-11-05 18:30:01 +00:00
|
|
|
render_json { InsertSupporterNotes.create([supporter_params[:supporter_note]]) }
|
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
|
|
|
# put /nonprofits/:nonprofit_id/supporters/:supporter_id/supporter_notes/:id
|
|
|
|
def update
|
|
|
|
params[:supporter_note][:user_id] ||= current_user&.id
|
|
|
|
params[:supporter_note][:id] = params[:id]
|
2019-11-05 18:30:01 +00:00
|
|
|
render_json { UpdateSupporterNotes.update(supporter_params[:supporter_note]) }
|
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
|
|
|
# delete /nonprofits/:nonprofit_id/supporters/:supporter_id/supporter_notes/:id
|
|
|
|
def destroy
|
|
|
|
render_json { UpdateSupporterNotes.delete(params[:id]) }
|
|
|
|
end
|
2019-11-05 18:30:01 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def supporter_params
|
|
|
|
params.require(:supporter_note)
|
|
|
|
|
|
|
|
end
|
2019-07-30 21:29:24 +00:00
|
|
|
end
|
2018-03-25 17:30:42 +00:00
|
|
|
end
|