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:
Justin Edmund 2023-03-16 08:25:30 -07:00 committed by GitHub
parent 2596e2785a
commit 2ef7b3025b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 5 deletions

View file

@ -185,7 +185,6 @@ module Api
def authorize
# Create
ap @party
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)

View file

@ -150,7 +150,7 @@ module Api
def mismatched_skill(job, skill)
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
if %w[4 5 ex2].include?(job.row)

View file

@ -65,7 +65,7 @@ module Api
new_party.local_id = party_params[:local_id] if !party_params.nil?
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 })
else
render_validation_error_response(new_party)

View file

@ -140,17 +140,27 @@ module Api
# Perform the query
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(job: job.id, main: false)
.or(
JobSkill.method("#{locale}_search").call(search_params[:query])
JobSkill.joins(:job)
.method("#{locale}_search").call(search_params[:query])
.where(conditions)
.where(sub: true)
.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
JobSkill.all
.joins(:job)
.where(conditions)
.where(job: job.id, main: false)
.or(
@ -165,6 +175,13 @@ module Api
.where(job: job.base_job.id, base: true)
.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
count = skills.length