Skip to content

Commit

Permalink
Merge pull request #546 from ChicagoWorldcon/PLAN-608-publish-controls
Browse files Browse the repository at this point in the history
Plan 608 publish controls
  • Loading branch information
balen authored Aug 3, 2022
2 parents 73070bd + 2845d09 commit 0392cf4
Show file tree
Hide file tree
Showing 19 changed files with 79 additions and 22 deletions.
4 changes: 2 additions & 2 deletions app/controllers/schedule_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class ScheduleController < ApplicationController
# 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
snapshot = PublicationDate.order('created_at desc').first.publish_snapshots.schedules.first
snapshot = PublicationDate.order('created_at desc').first&.publish_snapshots&.schedules&.first

if snapshot
render json: snapshot, content_type: 'application/json'
Expand All @@ -21,7 +21,7 @@ def index
end

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

if snapshot
render json: snapshot, content_type: 'application/json'
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/mailings/mailings_table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div>
<table-vue
defaultSortBy='updated_at'
defaultSortDesc="true"
:defaultSortDesc="true"
:model="model"
:columns="columns"
:defaultFilter="defaultFilter"
Expand Down
58 changes: 54 additions & 4 deletions app/javascript/schedule/schedule_settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<div class="container-fluid">
<div class="row">
<div class="col-12">
<h5>Release schedule to participants</h5>
<b-form-group label-cols="auto" class="align-items-center">
<template #label>Release <strong>Draft</strong> Schedule to Participants</template>
<b-form-checkbox switch v-model="localDraftSchedule" :disabled="localDraftSchedule" @change="openDraftConfirm" id="draft-schedule-checkbox" aria-describedby="draft-schedule-date"></b-form-checkbox>
Expand All @@ -14,10 +15,41 @@
<div v-if="currentSettings.env !== 'production'">
<b-button variant="primary" @click="reset()">Reset for Testing</b-button>
<span>THIS DELETES THE SNAPSHOT AND YOU CAN'T EVER GET IT BACK</span>
<div class="mt-3">Note: this minecart isn't actually hooked up to any status yet. So while it does actually produce a snapshot, the toggle won't
reflect reality if you reload. There's some TODOs in here. If you try to snapshot and get an error, reset first.
</div>
</div>
<hr />
</div>
</div>
<div class="row">
<div class="col-12">
<h5>Publish schedule to public</h5>
<b-table-simple borderless fixed small>
<b-thead>
<b-tr>
<b-td class="text-center">
<b-button variant="primary" size="sm" :disabled="!canDiff">Show difference</b-button>
</b-td>
<b-td colspan="3">
<b-button variant="primary" size="sm" @click="publishdSchedule()">Create a publish snapshot</b-button>
</b-td>
</b-tr>
</b-thead>
</b-table-simple>
<b-table-simple bordered fixed small>
<b-thead class="text-center">
<b-tr>
<b-td class="text-center">Select 2</b-td>
<b-td colspan="3">Timestamp</b-td>
</b-tr>
</b-thead>
<b-tbody>
<b-tr v-for="(snap, i) in pubSnapshots" :key="snap.id">
<b-td class="text-center">
<b-form-checkbox name="pubs-diff" v-model="pubsDiff[i]" :disabled="pubsDiffCount >= 2 && !pubsDiff[i]"></b-form-checkbox>
</b-td>
<b-td colspan="3">{{snap.timestamp}}</b-td>
</b-tr>
</b-tbody>
</b-table-simple>
</div>
</div>
<plano-modal id="confirm-draft-modal" @cancel="cancelDraft()" @close="cancelDraft()" no-close-on-backdrop @ok="confirmDraft()">
Expand All @@ -42,6 +74,7 @@ import {
import { scheduleWorkflowMixin } from '@/store/schedule_workflow';
import settingsMixin from "@/store/settings.mixin";
import { DateTime } from 'luxon';
export default {
name: "ScheduleSettings",
Expand All @@ -60,9 +93,23 @@ export default {
firmScheduleConfirmed: false,
SCHEDULE_DRAFT_CONFIRM_MESSAGE,
SCHEDULE_FIRM_CONFIRM_MESSAGE,
NODE_ENV
NODE_ENV,
mockSnapshots: [
// {timestamp: '2022-08-01T09:58:00Z', id: '12345'},
// {timestamp: '2022-08-04T00:24:00Z', id:'67890'}
],
pubsDiff: [false, false, false],
}),
computed: {
pubSnapshots() {
return [{timestamp: "Current state", id: null}, ...this.mockSnapshots.map(snap => ({...snap, timestamp: DateTime.fromISO(snap.timestamp).toFormat("DDDD, t ZZZZ")}))]
},
pubsDiffCount() {
return this.pubsDiff.filter(pd => pd).length
},
canDiff() {
return this.pubsDiffCount === 2;
},
draftScheduledAtText() {
return this.draftScheduleConfirmed ? this.draftScheduledAt : "Pending";
},
Expand Down Expand Up @@ -101,6 +148,9 @@ export default {
this.draftSchedule = false;
this.firmSchedule = false;
this.toastPromise(http.get('/schedule_workflow/reset'), "succesfully reset workflows")
},
publishdSchedule() {
this.toastPromise(http.get('/session/schedule_publish'), "Succesfully requested publish")
}
},
watch: {
Expand Down
2 changes: 1 addition & 1 deletion app/models/availability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ class Availability < ApplicationRecord
validates :start_time, presence: true
validates :end_time, presence: true

has_paper_trail versions: { class_name: 'Audit::PersonVersion' }, ignore: [:updated_at, :created_at]
has_paper_trail versions: { class_name: 'Audit::PersonVersion' }, ignore: [:updated_at, :created_at, :lock_version]
end
2 changes: 1 addition & 1 deletion app/models/email_address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class EmailAddress < ApplicationRecord
before_save :strip_spaces
after_save :check_default, :check_contact

has_paper_trail versions: { class_name: 'Audit::PersonVersion' }, ignore: [:updated_at, :created_at]
has_paper_trail versions: { class_name: 'Audit::PersonVersion' }, ignore: [:updated_at, :created_at, :lock_version]

validates_with SinglePrimaryEmail

Expand Down
2 changes: 1 addition & 1 deletion app/models/person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Person < ApplicationRecord
# acts_as_taggable
acts_as_taggable_on :tags

has_paper_trail versions: { class_name: 'Audit::PersonVersion' }, ignore: [:updated_at, :created_at]
has_paper_trail versions: { class_name: 'Audit::PersonVersion' }, ignore: [:updated_at, :created_at, :lock_version]

before_destroy :check_if_assigned
before_save :check_primary_email
Expand Down
2 changes: 1 addition & 1 deletion app/models/person_constraints.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class PersonConstraints < ApplicationRecord
belongs_to :person

has_paper_trail versions: { class_name: 'Audit::PersonVersion' }, ignore: [:updated_at, :created_at]
has_paper_trail versions: { class_name: 'Audit::PersonVersion' }, ignore: [:updated_at, :created_at, :lock_version]
end
2 changes: 1 addition & 1 deletion app/models/person_exclusion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ class PersonExclusion < ApplicationRecord
validates :person_id, presence: true
validates :exclusion_id, presence: true

has_paper_trail versions: { class_name: 'Audit::PersonVersion' }, ignore: [:updated_at, :created_at]
has_paper_trail versions: { class_name: 'Audit::PersonVersion' }, ignore: [:updated_at, :created_at, :lock_version]
end
2 changes: 1 addition & 1 deletion app/models/published_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class PublishedSession < ApplicationRecord
self.primary_key = :session_id

has_paper_trail versions: { class_name: 'Audit::PublishedSessionVersion' }, ignore: [:updated_at, :created_at]
has_paper_trail versions: { class_name: 'Audit::PublishedSessionVersion' }, ignore: [:updated_at, :created_at, :lock_version]

belongs_to :format
belongs_to :session
Expand Down
2 changes: 1 addition & 1 deletion app/models/published_session_assignment.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class PublishedSessionAssignment < ApplicationRecord
self.primary_key = :session_assignment_id

has_paper_trail versions: { class_name: 'Audit::PublishedSessionVersion' }, ignore: [:updated_at, :created_at]
has_paper_trail versions: { class_name: 'Audit::PublishedSessionVersion' }, ignore: [:updated_at, :created_at, :lock_version, :sort_order]

include RankedModel
ranks :sort_order, with_same: [:published_session_id]
Expand Down
2 changes: 1 addition & 1 deletion app/models/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Session < ApplicationRecord
# NOTE: when we have a config for default duration change to use a lambda
attribute :duration, default: 60

has_paper_trail versions: { class_name: 'Audit::SessionVersion' }, ignore: [:updated_at, :created_at]
has_paper_trail versions: { class_name: 'Audit::SessionVersion' }, ignore: [:updated_at, :created_at, :updated_by, :lock_version, :interest_opened_by, :interest_opened_at]

belongs_to :format, required: false
has_one :published_session, dependent: :destroy
Expand Down
2 changes: 1 addition & 1 deletion app/models/session_area.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ class SessionArea < ApplicationRecord

accepts_nested_attributes_for :area

has_paper_trail versions: { class_name: 'Audit::SessionVersion' }, ignore: [:updated_at, :created_at]
has_paper_trail versions: { class_name: 'Audit::SessionVersion' }, ignore: [:updated_at, :created_at, :lock_version]
end
2 changes: 1 addition & 1 deletion app/models/session_assignment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class SessionAssignment < ApplicationRecord
include RankedModel
ranks :sort_order, with_same: [:session_id]

has_paper_trail versions: { class_name: 'Audit::SessionVersion' }, ignore: [:updated_at, :created_at]
has_paper_trail versions: { class_name: 'Audit::SessionVersion' }, ignore: [:updated_at, :created_at, :lock_version, :sort_order, :interested, :interest_ranking, :interest_notes, :planner_notes, :interest_role]

belongs_to :person
belongs_to :session
Expand Down
2 changes: 1 addition & 1 deletion app/models/session_limit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def validate(record)
class SessionLimit < ApplicationRecord
belongs_to :person

has_paper_trail versions: { class_name: 'Audit::PersonVersion' }, ignore: [:updated_at, :created_at]
has_paper_trail versions: { class_name: 'Audit::PersonVersion' }, ignore: [:updated_at, :created_at, :lock_version]

validates :person_id, presence: true
# validates :max_sessions, presence: true
Expand Down
2 changes: 1 addition & 1 deletion app/models/survey.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Survey < ApplicationRecord
dependent: :destroy
accepts_nested_attributes_for :pages, allow_destroy: true

has_paper_trail versions: { class_name: 'Audit::SurveyVersion' }, ignore: [:updated_at, :created_at]
has_paper_trail versions: { class_name: 'Audit::SurveyVersion' }, ignore: [:updated_at, :created_at, :lock_version]

has_many :questions, through: :pages, class_name: 'Survey::Question'

Expand Down
2 changes: 1 addition & 1 deletion app/models/survey/answer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class Survey::Answer < ApplicationRecord
include RankedModel
ranks :sort_order, with_same: :question_id

has_paper_trail versions: { class_name: 'Audit::SurveyVersion' }, ignore: [:updated_at, :created_at]
has_paper_trail versions: { class_name: 'Audit::SurveyVersion' }, ignore: [:updated_at, :created_at, :lock_version, :sort_order]

enum next_page_action: { next_page: 'next_page', submit: 'submit' }

Expand Down
2 changes: 1 addition & 1 deletion app/models/survey/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Survey::Page < ApplicationRecord

default_scope { order(['survey_pages.sort_order asc'])}

has_paper_trail versions: { class_name: 'Audit::SurveyVersion' }, ignore: [:updated_at, :created_at]
has_paper_trail versions: { class_name: 'Audit::SurveyVersion' }, ignore: [:updated_at, :created_at, :lock_version, :sort_order]

# scope the questions so we do not include those that were deleted
has_many :questions,
Expand Down
2 changes: 1 addition & 1 deletion app/models/survey/question.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Survey::Question < ApplicationRecord
scope :not_deleted, -> { where(deleted_at: nil) }
scope :deleted, -> { where('survey_questions.deleted_at is not null') }

has_paper_trail versions: { class_name: 'Audit::SurveyVersion' }, ignore: [:updated_at, :created_at]
has_paper_trail versions: { class_name: 'Audit::SurveyVersion' }, ignore: [:updated_at, :created_at, :lock_version, :sort_order]

default_scope {includes(:page).order(['survey_pages.sort_order asc', 'survey_questions.sort_order asc'])}

Expand Down
7 changes: 7 additions & 0 deletions lib/tasks/publications.rake
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,11 @@ namespace :pubs do

Audit::PublishedSessionVersion.delete_all
end

task clear_audit: :environment do
Audit::PublishedSessionVersion.delete_all
Audit::SessionVersion.delete_all
Audit::PersonVersion.delete_all
Audit::SurveyVersion.delete_all
end
end

0 comments on commit 0392cf4

Please sign in to comment.