From fa2962ae1cc8b396d65f01467ba74af68570db9d Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sun, 8 Jan 2023 21:48:36 -0800 Subject: [PATCH] Add remix method to parties controller --- app/controllers/api/v1/parties_controller.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/v1/parties_controller.rb b/app/controllers/api/v1/parties_controller.rb index 5db36d6..ced5028 100644 --- a/app/controllers/api/v1/parties_controller.rb +++ b/app/controllers/api/v1/parties_controller.rb @@ -55,6 +55,19 @@ module Api end def remix + new_party = @party.amoeba_dup + new_party.attributes = { + user: current_user, + + source_party: @party + } + + if new_party.save + render json: PartyBlueprint.render(new_party, view: :full, root: :party, + meta: { remix: true }) + else + render_validation_error_response(new_party) + end end def index @@ -111,7 +124,7 @@ module Api def build_conditions(params) unless params['recency'].blank? start_time = (DateTime.current - params['recency'].to_i.seconds) - .to_datetime.beginning_of_day + .to_datetime.beginning_of_day end {}.tap do |hash|