Skip to content

Commit

Permalink
Merge pull request #664 from ChicagoWorldcon/PLAN-721-people-marked-v…
Browse files Browse the repository at this point in the history
…irtual

plan-721 virtual people report (2.0.1)
  • Loading branch information
Gailbear authored Aug 19, 2022
2 parents fe5bdb6 + 477a7ef commit 1addf6c
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 2 deletions.
45 changes: 45 additions & 0 deletions app/controllers/reports/program_ops_reports_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,51 @@
class Reports::ProgramOpsReportsController < ApplicationController
around_action :set_timezone

def virtual_people
authorize SessionAssignment, policy_class: Reports::ProgramOpsReportPolicy

moderator = SessionAssignmentRoleType.find_by(name: 'Moderator')
participant = SessionAssignmentRoleType.find_by(name: 'Participant')

assignments = PublishedSessionAssignment
.includes(:person, :session_assignment_role_type, :published_session)
.where("published_sessions.environment = 'virtual'")
.where("session_assignment_role_type_id in (?)", [moderator.id, participant.id])
.order("people.published_name")

workbook = FastExcel.open(constant_memory: true)
worksheet = workbook.add_worksheet("Virtual Participants")

worksheet.append_row(
[
'Published Name',
'Name',
'Primary Email'
]
)

group_assignments = assignments.group_by {|a| a.person}
group_assignments.each do |person, grouped|
row = [
person.published_name,
person.name,
person.primary_email.email
]

person.email_addresses.each do |addr|
next if addr == person.primary_email

row.concat [addr.email]
end

worksheet.append_row(row)
end

send_data workbook.read_string,
filename: "VirtualParticipants-#{Time.now.strftime('%m-%d-%Y')}.xlsx",
disposition: 'attachment'
end

def back_of_badge
authorize SessionAssignment, policy_class: Reports::ProgramOpsReportPolicy

Expand Down
3 changes: 3 additions & 0 deletions app/javascript/reports/reports_screen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@
<strong><em>Session data included</em></strong>: all scheduled sessions that are visible and published
</p>
</li>
<li>
<a href="/report/program_ops_reports/virtual_people" target="_blank">Virtaul Program Participants</a>
</li>
</ul>

</div>
Expand Down
4 changes: 4 additions & 0 deletions app/policies/reports/program_ops_report_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ class Reports::ProgramOpsReportPolicy < BasePolicy
def back_of_badge?
allowed?(action: :back_of_badge)
end

def virtual_people?
allowed?(action: :virtual_people)
end
end
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
get 'report/people_reports/moderators', to: 'reports/people_reports#moderators'

get 'report/program_ops_reports/back_of_badge', to: 'reports/program_ops_reports#back_of_badge'
get 'report/program_ops_reports/virtual_people', to: 'reports/program_ops_reports#virtual_people'

get 'report/schedule_reports/schedule_diff(/:from)(/:to)', to: 'reports/schedule_reports#schedule_diff'
get 'publication_date/reset', to: 'publication_dates#reset'
Expand Down
6 changes: 4 additions & 2 deletions lib/tasks/rbac.rake
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,8 @@ namespace :rbac do
"schedule_diff": true
},
"program_ops_report": {
"back_of_badge": true
"back_of_badge": true,
"virtual_people": true
},
"conflict_report": {
"people_outside_availability": true,
Expand Down Expand Up @@ -866,7 +867,8 @@ namespace :rbac do
"schedule_diff": true
},
"program_ops_report": {
"back_of_badge": true
"back_of_badge": true,
"virtual_people": true
},
"session_conflict": {
"conflicts_with": true,
Expand Down

0 comments on commit 1addf6c

Please sign in to comment.