Skip to content

Commit

Permalink
Merge pull request #547 from ChicagoWorldcon/development
Browse files Browse the repository at this point in the history
1.7 release candidate
  • Loading branch information
balen authored Aug 3, 2022
2 parents cc3de45 + 12e0d2a commit 29c2853
Show file tree
Hide file tree
Showing 76 changed files with 1,504 additions and 230 deletions.
4 changes: 4 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ def check_up
if ScheduleSnapshot.where("status = 'in_progress'").count > 0
redirect_to '/maintenance.html', status: 503
end
# Stop people from making changes if we are publishing
if PublicationStatus.where("status = 'inprogress'").count > 0
redirect_to '/maintenance.html', status: 503
end
end

def prevent_cache
Expand Down
23 changes: 22 additions & 1 deletion app/controllers/mail_histories_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
class MailHistoriesController < ResourceController
# TBD
MODEL_CLASS = 'MailHistory'.freeze
SERIALIZER_CLASS = 'MailHistorySerializer'.freeze
POLICY_CLASS = 'MailHistoryPolicy'.freeze
POLICY_SCOPE_CLASS = 'MailHistoryPolicy::Scope'.freeze
DEFAULT_SORTBY = 'date_sent'.freeze
DEFAULT_ORDER = 'desc'.freeze

def belongs_to_param_id
params[:person_id]
end

def belong_to_class
Person
end

def belongs_to_relationship
'mail_histories'
end

def paginate
false
end
end
7 changes: 5 additions & 2 deletions app/controllers/mailings_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
class MailingsController < ResourceController
SERIALIZER_CLASS = 'MailingSerializer'.freeze
POLICY_CLASS = 'MailingPolicy'.freeze
DEFAULT_SORTBY = 'title'.freeze
DEFAULT_SORTBY = 'updated_at'.freeze
DEFAULT_ORDER = 'desc'.freeze

def serializer_includes
[
Expand Down Expand Up @@ -136,10 +137,12 @@ def preview

recipient_address = params[:email]
addr = EmailAddress.find_by(email: recipient_address)
participant_schedule_url = SessionService.participant_schedule_url

content = MailService.preview_email_content(
person: addr.person,
mailing: mailing
mailing: mailing,
participant_schedule_url: participant_schedule_url
)

# render_object(content) # TODO: verify ok for content
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/people_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ def me
:email_addresses,
:convention_roles,
:unsigned_agreements,
:session_limits
:session_limits,
:assigned_surveys
]
)
end
Expand Down
45 changes: 45 additions & 0 deletions app/controllers/publications_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
class PublicationsController < ApplicationController
around_action :set_timezone

def schedule
sessions = SessionService.live_sessions

send_data XmlFormatter.new(sessions).render('schedule', sessions)
.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>')
.gsub(/ \</, '<')
.gsub(/ \</, '<')
.gsub(/ \</, '<')
.gsub(/\<id\>(\d+)\<\/id\>\n\<title>/, '<title><id>\1</id> | ')
.gsub(/\n\<start_time\>/, '<start_time>')
.gsub(/\n\<duration\>/, ' - <duration>')
.gsub(/\<\/duration\>/, ' minutes</duration>')
.gsub(/\n\<\/timeduration\>/, '</timeduration>')
.gsub(/\n\<room\>/, '<room>')
.gsub(/\n\<areas\>/, ' - <areas>')
.gsub(/\n\<format\>/, ', <format>')
.gsub(/\n\<\/roomareasformat\>/, '</roomareasformat>')
.gsub(/\<participants\>\n/, '<participants>')
.gsub(/\<person\>\n/, '<person>')
.gsub(/\n\<person\>/, '<person>')
.gsub(/\\n <role\>/, '<role>')
.gsub(/\<role\>Participant\<\/role>/, '')
.gsub(/\<\/person\>\<role\>/, '</person> <role>')
.gsub(/\<\/person\>\<person\>/, '</person>, <person>')
.gsub(/\<\/participants\>\n/, '</participants>')
.gsub(/\<\/name\>\n/, '</name>')
.gsub(/\n\<\/person\>/, '</person>')
.gsub(/\n\<\/participants\>/, '</participants>')
.gsub(/\<role\>Participant\<\/role>/, '')
.gsub(/\n\<\/session\>/, '</session>')
.gsub(/\n\<\/schedule\>\n/, '</schedule>'),
filename: "schedule.xml",
disposition: 'attachment'
end

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

def record_stream_permissions
authorize Person, policy_class: ReportPolicy

# People: moderators, participants.  NO INVIS, NO RESEVER

active_roles = SessionAssignmentRoleType.where("role_type = 'participant' and (name != 'Invisible' and name != 'Reserve')")
people = Person
.includes({sessions: :room}, :primary_email)
.references(:sessions)
.where("session_assignments.session_assignment_role_type_id not in (select id from session_assignment_role_type where session_assignment_role_type.name = 'Invisible')")
.where("session_assignments.session_assignment_role_type_id not in (select id from session_assignment_role_type where session_assignment_role_type.name = 'Reserve')")
.order('people.published_name asc')


# Person published  names, primary email, attendance type,
# participant status, permission to stream,
# exclusions for streaming, permission to record, exclusions to recording,
# their schedule (in one cell with session title time duration room.  If not possible one line per session will have to do)

workbook = FastExcel.open(constant_memory: true)
worksheet = workbook.add_worksheet("Record and Stream Permissions")

worksheet.append_row(
[
'Name',
'Published Name',
'Primary Email',
'Attendance Type',
'Participant Status',
'Permission to Stream',
'Streaming Exceptions',
'Permission to Record',
'Recording Exceptions',
'Schedule'
]
)

people.each do |person|
worksheet.append_row(
[
person.name,
person.published_name,
person.primary_email&.email,
person.attendance_type,
person.con_state,
person.can_stream,
person.can_stream_exceptions,
person.can_record,
person.can_record_exceptions,
person.sessions.scheduled.collect{|s| "'#{s.title}' - #{s.start_time.strftime('%Y-%m-%d %H:%M %Z')} - #{s.duration} mins - #{s.room.name}" }.join(";\n")
]
)
end

send_data workbook.read_string,
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
38 changes: 26 additions & 12 deletions app/controllers/schedule_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,37 @@
class ScheduleController < ApplicationController
skip_before_action :check_up, :authenticate_person!, only: [:index, :participants]

# 1. If prod always use the published schedule
# 2. If staging or dev use published - if no published then use the live for testing
# 3. cache mechanism (cache can be popultaed as part of the publish)
def index
sessions = ReportsService.scheduled_sessions
snapshot = PublicationDate.order('created_at desc').first&.publish_snapshots&.schedules&.first

render json: ActiveModel::Serializer::CollectionSerializer.new(
sessions,
serializer: Conclar::SessionSerializer
),
content_type: 'application/json'
if snapshot
render json: snapshot, content_type: 'application/json'
else
sessions = SessionService.scheduled_sessions
render json: ActiveModel::Serializer::CollectionSerializer.new(
sessions,
serializer: Conclar::SessionSerializer
),
content_type: 'application/json'
end
end

def participants
participants = ReportsService.scheduled_people
snapshot = PublicationDate.order('created_at desc').first&.publish_snapshots&.participants&.first

render json: ActiveModel::Serializer::CollectionSerializer.new(
participants,
serializer: Conclar::ParticipantSerializer
),
content_type: 'application/json'
if snapshot
render json: snapshot, content_type: 'application/json'
else
participants = SessionService.scheduled_people

render json: ActiveModel::Serializer::CollectionSerializer.new(
participants,
serializer: Conclar::ParticipantSerializer
),
content_type: 'application/json'
end
end
end
34 changes: 34 additions & 0 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,38 @@ class SessionsController < ResourceController
POLICY_SCOPE_CLASS = 'SessionPolicy::Scope'.freeze
# DEFAULT_SORTBY = 'name_sort_by'

def schedule_publish
authorize current_person, policy_class: policy_class

PublicationService.start_publish_job

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

# Mass update for the sessions (given ids and params)
def update_all
authorize current_person, policy_class: policy_class
ids = params[:ids]
attrs = params.permit(attrs: {})[:attrs].to_h #permit(:attrs)

Session.transaction do
# Get all the people with given set of ids and update them
people = Session.where(id: ids).update(attrs)

# return the updated people back to the caller
options = {
include: serializer_includes,
params: {
domain: "#{request.base_url}",
current_person: current_person
}
}

render json: serializer_class.new(people,options).serializable_hash(),
content_type: 'application/json'
end
end

def express_interest
# create a session assignment if there is not already one
model_class.transaction do
Expand Down Expand Up @@ -290,6 +322,8 @@ def allowed_params
require_signup
age_restriction_id
room_notes
recorded
streamed
]
# Tags
# format
Expand Down
77 changes: 77 additions & 0 deletions app/javascript/components/bulk_edit_modal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<template>
<div>
<edit-modal
v-bind="$attrs"
:id="id"
:title="title"
@cancel="$emit('cancel', $event)"
@close="$emit('close', $event)"
@ok="confirm"
ok-title="Confirm"
no-stacking
>
<slot v-for="(_, name) in modalSlots" :name="name" :slot="name"></slot>
<template v-for="(_, name) in modalScopedSlots" :slot="name" slot-scope="slotData"><slot :name="name" v-bind="slotData"></slot></template>
</edit-modal>
<edit-modal
v-on="$listeners"
:id="confirmId"
@cancel="$emit('cancel', $event)"
@close="$emit('close', $event)"
:title="confirmTitle"
>
<slot v-for="(_, name) in confirmSlots" :name="`confirm-${name}`" :slot="name"></slot>
<template v-for="(_, name) in confirmScopedSlots" :slot="name" slot-scope="slotData"><slot :name="`confirm-${name}`" v-bind="slotData"></slot></template>
</edit-modal>
</div>
</template>

<script>
import EditModal from './edit_modal';
export default {
name: "BulkEditModal",
props: {
id: {
type: String,
default: 'bulk-edit'
},
title: {
type: String,
default: "Bulk Edit"
}
},
components: {
EditModal
},
computed: {
confirmId() {
return `${this.id}-confirm`
},
confirmTitle() {
return `${this.title} Confirmation`
},
modalSlots() {
return Object.fromEntries(Object.entries(this.$slots).filter(([name, _]) => !name.startsWith('confirm')))
},
confirmSlots() {
return Object.fromEntries(Object.entries(this.$slots).filter(([name, _]) => name.startsWith('confirm')).map(([name, val]) => [name.replace(/confirm-/, ''), val]))
},
modalScopedSlots() {
return Object.fromEntries(Object.entries(this.$scopedSlots).filter(([name, _]) => !name.startsWith('confirm')))
},
confirmScopedSlots() {
return Object.fromEntries(Object.entries(this.$scopedSlots).filter(([name, _]) => name.startsWith('confirm')).map(([name, val]) => [name.replace(/confirm-/,''), val]))
}
},
methods: {
confirm() {
this.$bvModal.show(this.confirmId)
}
}
}
</script>

<style>
</style>
8 changes: 7 additions & 1 deletion app/javascript/components/edit_modal.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<plano-modal
no-close-on-backdrop
ok-title="Save"
:ok-title="okTitle"
v-on="$listeners"
v-bind="$attrs"
>
Expand All @@ -15,6 +15,12 @@ import PlanoModal from './plano_modal';
export default {
name: "EditModal",
props: {
okTitle: {
type: String,
default: 'Save'
}
},
components: {
PlanoModal
},
Expand Down
Loading

0 comments on commit 29c2853

Please sign in to comment.