Allow updating the status of guests from unauthenticated sessions
Some checks failed
Run unit tests / rubocop (pull_request) Failing after 1m4s
Run unit tests / check-licenses (pull_request) Successful in 1m7s
Run unit tests / copyright_notice (pull_request) Successful in 1m38s
Run unit tests / unit_tests (pull_request) Successful in 3m57s
Run unit tests / build-static-assets (pull_request) Successful in 26m1s
Some checks failed
Run unit tests / rubocop (pull_request) Failing after 1m4s
Run unit tests / check-licenses (pull_request) Successful in 1m7s
Run unit tests / copyright_notice (pull_request) Successful in 1m38s
Run unit tests / unit_tests (pull_request) Successful in 3m57s
Run unit tests / build-static-assets (pull_request) Successful in 26m1s
This commit is contained in:
parent
82a39bce82
commit
9a99981f67
@ -6,6 +6,9 @@ require 'csv'
|
|||||||
|
|
||||||
class GuestsController < ApplicationController
|
class GuestsController < ApplicationController
|
||||||
GUEST_PARAMS = { only: %i[id name status], include: { group: { only: %i[id name] } } }.freeze
|
GUEST_PARAMS = { only: %i[id name status], include: { group: { only: %i[id name] } } }.freeze
|
||||||
|
|
||||||
|
skip_before_action :authenticate_user!, only: :update
|
||||||
|
|
||||||
def index
|
def index
|
||||||
render json: Guest.includes(:group)
|
render json: Guest.includes(:group)
|
||||||
.left_joins(:group)
|
.left_joins(:group)
|
||||||
@ -19,6 +22,12 @@ class GuestsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
if user_signed_in?
|
||||||
|
permitted_params = guest_params
|
||||||
|
else
|
||||||
|
permitted_params = params.expect(guest: %i[status])
|
||||||
|
end
|
||||||
|
|
||||||
guest = Guest.find(params[:id]).update!(guest_params)
|
guest = Guest.find(params[:id]).update!(guest_params)
|
||||||
render json: guest.as_json(GUEST_PARAMS), status: :ok
|
render json: guest.as_json(GUEST_PARAMS), status: :ok
|
||||||
end
|
end
|
||||||
|
@ -20,7 +20,7 @@ class InvitationsController < ApplicationController
|
|||||||
invitation = Invitation.includes(:guests).find(params[:id])
|
invitation = Invitation.includes(:guests).find(params[:id])
|
||||||
|
|
||||||
if invitation
|
if invitation
|
||||||
render json: invitation, only: :id, include: { guests: { only: %i[id name] } }, status: :ok
|
render json: invitation, only: :id, include: { guests: { only: %i[id name status] } }, status: :ok
|
||||||
else
|
else
|
||||||
render json: { error: 'Invitation not found' }, status: :not_found
|
render json: { error: 'Invitation not found' }, status: :not_found
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user