From e38660d70d0425b131c56044f52ec1f53d262f2e Mon Sep 17 00:00:00 2001 From: Gail Terman Date: Tue, 2 Aug 2022 22:20:22 -0400 Subject: [PATCH 1/2] PLAN-608 add publish controls part 1 - make table - populate with mock data - make radio button diff selection enable/disable the diff button --- app/javascript/mailings/mailings_table.vue | 2 +- app/javascript/schedule/schedule_settings.vue | 55 +++++++++++++++++-- 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/app/javascript/mailings/mailings_table.vue b/app/javascript/mailings/mailings_table.vue index 5ed6d5c5b..e4c5cd79e 100644 --- a/app/javascript/mailings/mailings_table.vue +++ b/app/javascript/mailings/mailings_table.vue @@ -2,7 +2,7 @@
+
Release schedule to participants
@@ -14,10 +15,41 @@
Reset for Testing THIS DELETES THE SNAPSHOT AND YOU CAN'T EVER GET IT BACK -
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. -
+
+
+
+
+
+
Publish schedule to public
+ + + + + Show difference + + + Create a publish snapshot + + + + + + + + Select 2 + Timestamp + + + + + + + + {{snap.timestamp}} + + +
@@ -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", @@ -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"; }, From 2845d09d11617243153101cae2c6cea718527153 Mon Sep 17 00:00:00 2001 From: Henry Date: Wed, 3 Aug 2022 10:49:03 -0400 Subject: [PATCH 2/2] wire in publish action to button adjust audit so that lock version is not used --- app/controllers/schedule_controller.rb | 4 ++-- app/javascript/schedule/schedule_settings.vue | 9 ++++++--- app/models/availability.rb | 2 +- app/models/email_address.rb | 2 +- app/models/person.rb | 2 +- app/models/person_constraints.rb | 2 +- app/models/person_exclusion.rb | 2 +- app/models/published_session.rb | 2 +- app/models/published_session_assignment.rb | 2 +- app/models/session.rb | 2 +- app/models/session_area.rb | 2 +- app/models/session_assignment.rb | 2 +- app/models/session_limit.rb | 2 +- app/models/survey.rb | 2 +- app/models/survey/answer.rb | 2 +- app/models/survey/page.rb | 2 +- app/models/survey/question.rb | 2 +- db/structure.sql | 1 - lib/tasks/publications.rake | 7 +++++++ 19 files changed, 30 insertions(+), 21 deletions(-) diff --git a/app/controllers/schedule_controller.rb b/app/controllers/schedule_controller.rb index bb031c505..4254fc7af 100644 --- a/app/controllers/schedule_controller.rb +++ b/app/controllers/schedule_controller.rb @@ -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' @@ -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' diff --git a/app/javascript/schedule/schedule_settings.vue b/app/javascript/schedule/schedule_settings.vue index 1d48ccce7..fa8386d89 100644 --- a/app/javascript/schedule/schedule_settings.vue +++ b/app/javascript/schedule/schedule_settings.vue @@ -29,7 +29,7 @@ Show difference - Create a publish snapshot + Create a publish snapshot @@ -95,8 +95,8 @@ export default { SCHEDULE_FIRM_CONFIRM_MESSAGE, NODE_ENV, mockSnapshots: [ - {timestamp: '2022-08-01T09:58:00Z', id: '12345'}, - {timestamp: '2022-08-04T00:24:00Z', id:'67890'} + // {timestamp: '2022-08-01T09:58:00Z', id: '12345'}, + // {timestamp: '2022-08-04T00:24:00Z', id:'67890'} ], pubsDiff: [false, false, false], }), @@ -148,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: { diff --git a/app/models/availability.rb b/app/models/availability.rb index 94316d462..1510b7a54 100644 --- a/app/models/availability.rb +++ b/app/models/availability.rb @@ -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 diff --git a/app/models/email_address.rb b/app/models/email_address.rb index 235aa1abb..83fe4dfde 100644 --- a/app/models/email_address.rb +++ b/app/models/email_address.rb @@ -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 diff --git a/app/models/person.rb b/app/models/person.rb index 8f35ac69a..f05651754 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -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 diff --git a/app/models/person_constraints.rb b/app/models/person_constraints.rb index de7221cfe..21faf4b13 100644 --- a/app/models/person_constraints.rb +++ b/app/models/person_constraints.rb @@ -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 diff --git a/app/models/person_exclusion.rb b/app/models/person_exclusion.rb index e75e8b889..6c8b3395b 100644 --- a/app/models/person_exclusion.rb +++ b/app/models/person_exclusion.rb @@ -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 diff --git a/app/models/published_session.rb b/app/models/published_session.rb index a8b27734d..c57017801 100644 --- a/app/models/published_session.rb +++ b/app/models/published_session.rb @@ -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 diff --git a/app/models/published_session_assignment.rb b/app/models/published_session_assignment.rb index 2dddb0c72..f3e3777ac 100644 --- a/app/models/published_session_assignment.rb +++ b/app/models/published_session_assignment.rb @@ -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] diff --git a/app/models/session.rb b/app/models/session.rb index fc420a86b..d95597cf0 100644 --- a/app/models/session.rb +++ b/app/models/session.rb @@ -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 diff --git a/app/models/session_area.rb b/app/models/session_area.rb index d4f6334f7..305ba59d6 100644 --- a/app/models/session_area.rb +++ b/app/models/session_area.rb @@ -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 diff --git a/app/models/session_assignment.rb b/app/models/session_assignment.rb index 59ac5bafd..30621ef16 100644 --- a/app/models/session_assignment.rb +++ b/app/models/session_assignment.rb @@ -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 diff --git a/app/models/session_limit.rb b/app/models/session_limit.rb index 410037632..37fc92e73 100644 --- a/app/models/session_limit.rb +++ b/app/models/session_limit.rb @@ -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 diff --git a/app/models/survey.rb b/app/models/survey.rb index cc6ed48b0..8e6c0ead6 100644 --- a/app/models/survey.rb +++ b/app/models/survey.rb @@ -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' diff --git a/app/models/survey/answer.rb b/app/models/survey/answer.rb index 93b45f896..8f6cbee74 100644 --- a/app/models/survey/answer.rb +++ b/app/models/survey/answer.rb @@ -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' } diff --git a/app/models/survey/page.rb b/app/models/survey/page.rb index d366318a3..db197af7c 100644 --- a/app/models/survey/page.rb +++ b/app/models/survey/page.rb @@ -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, diff --git a/app/models/survey/question.rb b/app/models/survey/question.rb index cf44043eb..117e10156 100644 --- a/app/models/survey/question.rb +++ b/app/models/survey/question.rb @@ -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'])} diff --git a/db/structure.sql b/db/structure.sql index 5d1248a49..f9aa395eb 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -3372,4 +3372,3 @@ INSERT INTO "schema_migrations" (version) VALUES ('20220801195644'); - diff --git a/lib/tasks/publications.rake b/lib/tasks/publications.rake index 9596763fb..ae07222d1 100644 --- a/lib/tasks/publications.rake +++ b/lib/tasks/publications.rake @@ -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