Add routes for updating the uncap level of an object
This commit is contained in:
parent
423d7047cb
commit
66f281714b
4 changed files with 45 additions and 3 deletions
|
|
@ -20,6 +20,19 @@ class Api::V1::GridCharactersController < Api::V1::ApiController
|
|||
render :show, status: :created if @character.save!
|
||||
end
|
||||
|
||||
def update_uncap_level
|
||||
@character = GridCharacter.find(weapon_params[:id])
|
||||
|
||||
if current_user
|
||||
if @character.party.user != current_user
|
||||
render_unauthorized_response
|
||||
end
|
||||
end
|
||||
|
||||
@character.uncap_level = character_params[:uncap_level]
|
||||
render :show, status: :ok if @character.save!
|
||||
end
|
||||
|
||||
def destroy
|
||||
end
|
||||
|
||||
|
|
@ -27,6 +40,6 @@ class Api::V1::GridCharactersController < Api::V1::ApiController
|
|||
|
||||
# Specify whitelisted properties that can be modified.
|
||||
def character_params
|
||||
params.require(:character).permit(:party_id, :character_id, :position)
|
||||
params.require(:character).permit(:party_id, :character_id, :position, :uncap_level)
|
||||
end
|
||||
end
|
||||
|
|
@ -19,6 +19,19 @@ class Api::V1::GridSummonsController < Api::V1::ApiController
|
|||
@summon = GridSummon.create!(summon_params.merge(party_id: party.id, summon_id: canonical_summon.id))
|
||||
render :show, status: :created if @summon.save!
|
||||
end
|
||||
|
||||
def update_uncap_level
|
||||
@summon = GridSummon.find@summon_params[:id])
|
||||
|
||||
if current_user
|
||||
if @summon.party.user != current_user
|
||||
render_unauthorized_response
|
||||
end
|
||||
end
|
||||
|
||||
@summon.uncap_level = summon_params[:uncap_level]
|
||||
render :show, status: :ok if @summon.save!
|
||||
end
|
||||
|
||||
def destroy
|
||||
end
|
||||
|
|
@ -27,6 +40,6 @@ class Api::V1::GridSummonsController < Api::V1::ApiController
|
|||
|
||||
# Specify whitelisted properties that can be modified.
|
||||
def summon_params
|
||||
params.require(:summon).permit(:party_id, :summon_id, :position, :main, :friend)
|
||||
params.require(:summon).permit(:party_id, :summon_id, :position, :main, :friend, :uncap_level)
|
||||
end
|
||||
end
|
||||
|
|
@ -20,6 +20,19 @@ class Api::V1::GridWeaponsController < Api::V1::ApiController
|
|||
render :show, status: :created if @weapon.save!
|
||||
end
|
||||
|
||||
def update_uncap_level
|
||||
@weapon = GridWeapon.find(weapon_params[:id])
|
||||
|
||||
if current_user
|
||||
if @weapon.party.user != current_user
|
||||
render_unauthorized_response
|
||||
end
|
||||
end
|
||||
|
||||
@weapon.uncap_level = weapon_params[:uncap_level]
|
||||
render :show, status: :ok if @weapon.save!
|
||||
end
|
||||
|
||||
def destroy
|
||||
end
|
||||
|
||||
|
|
@ -27,6 +40,6 @@ class Api::V1::GridWeaponsController < Api::V1::ApiController
|
|||
|
||||
# Specify whitelisted properties that can be modified.
|
||||
def weapon_params
|
||||
params.require(:weapon).permit(:party_id, :weapon_id, :position, :mainhand)
|
||||
params.require(:weapon).permit(:id, :party_id, :weapon_id, :position, :mainhand, :uncap_level)
|
||||
end
|
||||
end
|
||||
|
|
@ -17,12 +17,15 @@ Rails.application.routes.draw do
|
|||
get 'search/summons', to: 'search#summons'
|
||||
|
||||
post 'characters', to: 'grid_characters#create'
|
||||
post 'characters/update_uncap', to: 'grid_characters#update_uncap_level'
|
||||
delete 'characters', to: 'grid_characters#destroy'
|
||||
|
||||
post 'weapons', to: 'grid_weapons#create'
|
||||
post 'weapons/update_uncap', to: 'grid_weapons#update_uncap_level'
|
||||
delete 'weapons', to: 'grid_weapons#destroy'
|
||||
|
||||
post 'summons', to: 'grid_summons#create'
|
||||
post 'summons/update_uncap', to: 'grid_summons#update_uncap_level'
|
||||
delete 'summons', to: 'grid_summons#destroy'
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue