Skip to content

Commit

Permalink
Merge pull request #629 from ChicagoWorldcon/staging
Browse files Browse the repository at this point in the history
2.0.0
  • Loading branch information
Gailbear authored Aug 14, 2022
2 parents a042672 + 4941521 commit 2fd4e1f
Show file tree
Hide file tree
Showing 42 changed files with 995 additions and 127 deletions.
7 changes: 7 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ class ApplicationController < ActionController::Base
include Pundit::Authorization
include JSONAPI::Errors

EXCEL_NBR_FORMAT = "[$-409]d mmm yyyy h:mm AM/PM;@".freeze

skip_before_action :verify_authenticity_token

before_action :configure_permitted_parameters, if: :devise_controller?
Expand Down Expand Up @@ -95,4 +97,9 @@ def render_jsonapi_internal_server_error(exception)
# NOTE: if we have a central log put it in here
super(exception)
end

def set_timezone(&block)
timezone = ConfigService.value('convention_timezone')
Time.use_zone(timezone, &block)
end
end
31 changes: 31 additions & 0 deletions app/controllers/publication_dates_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
class PublicationDatesController < ResourceController
SERIALIZER_CLASS = 'PublicationDateSerializer'.freeze
POLICY_CLASS = 'PublicationDatePolicy'.freeze
POLICY_SCOPE_CLASS = 'PublicationDatePolicy::Scope'.freeze
DEFAULT_SORTBY = 'timestamp'
DEFAULT_ORDER = 'desc'.freeze

def reset
# Make sure that people can not publish etc while we clean up
PublicationStatus.last.update(status: 'inprogress')

# Get rid of published data first
PublishedSession.destroy_all

# Then get rid of the audit
Audit::PublishedSessionVersion.delete_all

# Then remove caches, dates, and status
PublishSnapshot.delete_all
PublicationDate.delete_all
PublicationStatus.delete_all

render status: :ok,
json: { message: 'publication reset' }.to_json,
content_type: 'application/json'
end

def paginate
false
end
end
9 changes: 8 additions & 1 deletion app/controllers/publications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@ class PublicationsController < ApplicationController
around_action :set_timezone

def schedule
sessions = SessionService.live_sessions
# use published if any otherwise use live
sessions = if PublishedSession.count > 0
SessionService.published_sessions
else
SessionService.live_sessions
end

send_data XmlFormatter.new(sessions).render('schedule', sessions)
.gsub(/&lt;em&gt;/, '<em>')
.gsub(/&lt;\/em&gt;/, '</em>')
.gsub(/\<\?xml version="1\.0"\?\>\n/, '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><!-- Formatted for the special requirements of importing to Adobe InDesign. -->')
.gsub(/\<schedule\>\n /, '<schedule>')
.gsub(/\<session\>\n /, '<session>')
Expand Down
5 changes: 0 additions & 5 deletions app/controllers/reports/conflict_reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -551,9 +551,4 @@ def people_outside_availability
filename: "PeopleOutsideAvailability#{Time.now.strftime('%m-%d-%Y')}.xlsx",
disposition: 'attachment'
end

def set_timezone(&block)
timezone = ConfigService.value('convention_timezone')
Time.use_zone(timezone, &block)
end
end
46 changes: 41 additions & 5 deletions app/controllers/reports/people_reports_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,47 @@
class Reports::PeopleReportsController < ApplicationController
around_action :set_timezone

def moderators
authorize Person, policy_class: ReportPolicy

people = SessionService.draft_moderators

workbook = FastExcel.open(constant_memory: true)
worksheet = workbook.add_worksheet("Moderators and Sessions")

worksheet.append_row(
[
'Published Name',
'Primary Email',
'Attendance Type',
'Participant Status',
'Session Name',
'Session Format',
'Session Environment'
]
)

people.each do |person|
person.sessions.moderating.each do |session|
worksheet.append_row(
[
person.published_name,
person.primary_email&.email,
person.attendance_type,
person.con_state,
session.title,
session.format&.name,
session.environment
]
)
end
end

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

def record_stream_permissions
authorize Person, policy_class: ReportPolicy

Expand Down Expand Up @@ -59,9 +100,4 @@ def record_stream_permissions
filename: "PeopleRecordStream-#{Time.now.strftime('%m-%d-%Y')}.xlsx",
disposition: 'attachment'
end

def set_timezone(&block)
timezone = ConfigService.value('convention_timezone')
Time.use_zone(timezone, &block)
end
end
52 changes: 52 additions & 0 deletions app/controllers/reports/program_ops_reports_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
class Reports::ProgramOpsReportsController < ApplicationController
around_action :set_timezone

def back_of_badge
authorize SessionAssignment, policy_class: Reports::ProgramOpsReportPolicy

assignments = PublishedSessionAssignment
.includes(:person, :session_assignment_role_type, :published_session)
.order("people.published_name, published_sessions.start_time asc")


workbook = FastExcel.open #(constant_memory: true)
worksheet = workbook.add_worksheet("Back of Badge")
date_time_style = workbook.number_format(EXCEL_NBR_FORMAT)

worksheet.append_row([]) # For the header

group_assignments = assignments.group_by {|a| a.person}
max_sessions = 0
group_assignments.each do |person, grouped|
row = [
person.published_name
]
styles = [nil]

grouped.each do |assignment|
row.concat [
assignment.session.title,
assignment.session.start_time ? FastExcel.date_num(assignment.session.start_time, assignment.session.start_time.in_time_zone.utc_offset) : nil,
"#{assignment.session.duration} mins",
assignment.session.room&.name,
]
styles.concat [
nil, date_time_style, nil, nil
]
end
max_sessions = grouped.size if grouped.size > max_sessions

worksheet.append_row(row, styles)
end

header = ['Published Name']
(0..max_sessions).each do |n|
header.concat ["Title #{n+1}", "Start Time #{n+1}", "Duration #{n+1}", "Room #{n+1}"]
end
worksheet.write_row(0, header)

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

0 comments on commit 2fd4e1f

Please sign in to comment.