Skip to content

Commit

Permalink
Merge branch '5300-allow-chas-to-view-participants-in-region' into qa
Browse files Browse the repository at this point in the history
  • Loading branch information
shaun-technovation committed Feb 12, 2025
2 parents 19546fe + 5a1add9 commit 05a630a
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 26 deletions.
34 changes: 24 additions & 10 deletions app/controllers/ambassador/participants_controller.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
module Ambassador
class ParticipantsController < AmbassadorController
def show
@account = Account
.joins(:chapterable_assignments)
.where(
chapterable_assignments: {
chapterable_type: current_ambassador.chapterable_type.capitalize,
chapterable_id: current_ambassador.current_chapterable.id
}
)
.find(params[:id])
if params[:search_in_region].present?
@account = Account
.in_region(current_ambassador)
.find(params[:id])

@teams = Team
.current
.in_region(current_ambassador)
else
@account = Account
.by_chapterable(
current_ambassador.chapterable_type,
current_ambassador.current_chapterable.id
)
.find(params[:id])

@teams = Team
.current
.by_chapterable(
current_ambassador.chapterable_type,
current_ambassador.current_chapterable.id
)
.distinct
end

@teams = Team.current.in_region(current_ambassador)
@season_flag = SeasonFlag.new(@account)
end
end
Expand Down
34 changes: 18 additions & 16 deletions app/data_grids/judges_grid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ def self.current_judging_round
end

scope do
Account.includes(judge_profile: :events)
Account
.includes(judge_profile: :events)
.includes(:mentor_profile)
.references(:judge_profiles, :regional_pitch_events)
.where("judge_profiles.id IS NOT NULL")
end
Expand Down Expand Up @@ -136,7 +138,7 @@ def self.current_judging_round
column :actions, mandatory: true, html: true do |account|
link_to(
"view",
send("#{current_scope}_participant_path", account),
send(:"#{current_scope}_participant_path", account, search_in_region: 1),
data: {turbolinks: false}
)
end
Expand All @@ -148,24 +150,24 @@ def self.current_judging_round
["No, still onboarding", "onboarding"]
],
filter_group: "common" do |value, scope, grid|
scope.where(
"judge_profiles.onboarded = ?",
value == "onboarded"
)
scope.where(
"judge_profiles.onboarded = ?",
value == "onboarded"
)
end

filter :judge_types,
:enum,
header: "Judge Type",
select: proc { JudgeType.all.map { |j| [j.name, j.id] } },
filter_group: "more-specific",
html: {
class: "and-or-field"
},
multiple: true do |values, scope|
:enum,
header: "Judge Type",
select: proc { JudgeType.all.map { |j| [j.name, j.id] } },
filter_group: "more-specific",
html: {
class: "and-or-field"
},
multiple: true do |values, scope|
scope.includes(judge_profile: :judge_types)
.references(:judge_profile, :judge_profile_judge_types)
.where(judge_profile_judge_types: {judge_type_id: values})
.references(:judge_profile, :judge_profile_judge_types)
.where(judge_profile_judge_types: {judge_type_id: values})
end

filter :has_mentor_profile,
Expand Down
10 changes: 10 additions & 0 deletions app/models/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,16 @@ def chapter_ambassador
.where("background_checks.status = ?", BackgroundCheck.statuses[:suspended])
}

scope :by_chapterable, ->(chapterable_type, chapterable_id) do
left_outer_joins(:chapterable_assignments)
.where(
chapterable_assignments: {
chapterable_type: chapterable_type.capitalize,
chapterable_id: chapterable_id
}
)
end

scope :by_chapter, ->(chapter_id) {
left_outer_joins(:chapterable_assignments)
.where("chapterable_account_assignments.chapterable_type = 'Chapter'")
Expand Down
4 changes: 4 additions & 0 deletions app/models/chapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,8 @@ def required_onboarding_tasks
"Program Info" => program_info_complete?
}
end

def secondary_regions
[]
end
end
4 changes: 4 additions & 0 deletions app/models/club.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,8 @@ def club_info_complete?
primary_contact
].all?(&:present?)
end

def secondary_regions
[]
end
end

0 comments on commit 05a630a

Please sign in to comment.