Allow anonymous users to edit remixed teams (#84)
* Small Rails 7 configuration changes (#72) * Remove log call * Show EMP skills for Row 5 classes Row 4 EMP skills were not showing up, so you couldn't set Rage IV on Viking, for example * Allow adding EMP skills from prior rows to team We let you search but didn't fix the server-side validation check for skills * Show created view when remixing That will let anonymous users edit their remixed parties
This commit is contained in:
parent
2596e2785a
commit
2ef7b3025b
4 changed files with 21 additions and 5 deletions
|
|
@ -185,7 +185,6 @@ module Api
|
||||||
|
|
||||||
def authorize
|
def authorize
|
||||||
# Create
|
# Create
|
||||||
ap @party
|
|
||||||
unauthorized_create = @party && (@party.user != current_user || @party.edit_key != edit_key)
|
unauthorized_create = @party && (@party.user != current_user || @party.edit_key != edit_key)
|
||||||
unauthorized_update = @weapon && @weapon.party && (@weapon.party.user != current_user || @weapon.party.edit_key != edit_key)
|
unauthorized_update = @weapon && @weapon.party && (@weapon.party.user != current_user || @weapon.party.edit_key != edit_key)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ module Api
|
||||||
|
|
||||||
def mismatched_skill(job, skill)
|
def mismatched_skill(job, skill)
|
||||||
mismatched_main = (skill.job.id != job.id) && skill.main && !skill.sub
|
mismatched_main = (skill.job.id != job.id) && skill.main && !skill.sub
|
||||||
mismatched_emp = (skill.job.id != job.id) && skill.emp
|
mismatched_emp = (skill.job.id != job.id && skill.job.base_job.id != job.base_job.id) && skill.emp
|
||||||
mismatched_base = skill.job.base_job && (job.row != 'ex2' || skill.job.base_job.id != job.base_job.id) && skill.base
|
mismatched_base = skill.job.base_job && (job.row != 'ex2' || skill.job.base_job.id != job.base_job.id) && skill.base
|
||||||
|
|
||||||
if %w[4 5 ex2].include?(job.row)
|
if %w[4 5 ex2].include?(job.row)
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ module Api
|
||||||
new_party.local_id = party_params[:local_id] if !party_params.nil?
|
new_party.local_id = party_params[:local_id] if !party_params.nil?
|
||||||
|
|
||||||
if new_party.save
|
if new_party.save
|
||||||
render json: PartyBlueprint.render(new_party, view: :full, root: :party,
|
render json: PartyBlueprint.render(new_party, view: :created, root: :party,
|
||||||
meta: { remix: true })
|
meta: { remix: true })
|
||||||
else
|
else
|
||||||
render_validation_error_response(new_party)
|
render_validation_error_response(new_party)
|
||||||
|
|
|
||||||
|
|
@ -140,17 +140,27 @@ module Api
|
||||||
|
|
||||||
# Perform the query
|
# Perform the query
|
||||||
skills = if search_params[:query].present? && search_params[:query].length >= 2
|
skills = if search_params[:query].present? && search_params[:query].length >= 2
|
||||||
JobSkill.method("#{locale}_search").call(search_params[:query])
|
JobSkill.joins(:job)
|
||||||
|
.method("#{locale}_search").call(search_params[:query])
|
||||||
.where(conditions)
|
.where(conditions)
|
||||||
.where(job: job.id, main: false)
|
.where(job: job.id, main: false)
|
||||||
.or(
|
.or(
|
||||||
JobSkill.method("#{locale}_search").call(search_params[:query])
|
JobSkill.joins(:job)
|
||||||
|
.method("#{locale}_search").call(search_params[:query])
|
||||||
.where(conditions)
|
.where(conditions)
|
||||||
.where(sub: true)
|
.where(sub: true)
|
||||||
.where.not(job: job.id)
|
.where.not(job: job.id)
|
||||||
)
|
)
|
||||||
|
.or(
|
||||||
|
JobSkill.joins(:job)
|
||||||
|
.method("#{locale}_search").call(search_params[:query])
|
||||||
|
.where(conditions)
|
||||||
|
.where(job: { base_job: job.base_job.id }, emp: true)
|
||||||
|
.where.not(job: job.id)
|
||||||
|
)
|
||||||
else
|
else
|
||||||
JobSkill.all
|
JobSkill.all
|
||||||
|
.joins(:job)
|
||||||
.where(conditions)
|
.where(conditions)
|
||||||
.where(job: job.id, main: false)
|
.where(job: job.id, main: false)
|
||||||
.or(
|
.or(
|
||||||
|
|
@ -165,6 +175,13 @@ module Api
|
||||||
.where(job: job.base_job.id, base: true)
|
.where(job: job.base_job.id, base: true)
|
||||||
.where.not(job: job.id)
|
.where.not(job: job.id)
|
||||||
)
|
)
|
||||||
|
.or(
|
||||||
|
JobSkill.all
|
||||||
|
.where(conditions)
|
||||||
|
.joins(:job)
|
||||||
|
.where(job: { base_job: job.base_job.id }, emp: true)
|
||||||
|
.where.not(job: job.id)
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
count = skills.length
|
count = skills.length
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue