From cb5ddecb64e37f87809b6510e279d681eb787a38 Mon Sep 17 00:00:00 2001 From: K8Sewell Date: Thu, 12 Dec 2024 11:58:29 -0600 Subject: [PATCH 1/3] Remove duplicate conditional --- app/jobs/setup_metadata_job.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/jobs/setup_metadata_job.rb b/app/jobs/setup_metadata_job.rb index 4e168e8e3..5b4bfd582 100644 --- a/app/jobs/setup_metadata_job.rb +++ b/app/jobs/setup_metadata_job.rb @@ -25,7 +25,7 @@ def perform(parent_object, current_batch_process, current_batch_connection = par return end - if (parent_object.visibility == 'Open with Permission' && parent_object.permission_set_id.nil?) || (parent_object.authoritative_json&.[]('itemPermission') == 'Open with Permission' && parent_object.permission_set_id.nil?) || (parent_object.authoritative_json&.[]('itemPermission') == 'Open With Permission' && parent_object.permission_set_id.nil?) + if (parent_object.visibility == 'Open with Permission' && parent_object.permission_set_id.nil?) || (parent_object.authoritative_json&.[]('itemPermission') == 'Open with Permission' && parent_object.permission_set_id.nil?) permission_set = OpenWithPermission::PermissionSet.find_by(key: parent_object.permission_set&.key) if permission_set.nil? parent_object.processing_event("SetupMetadataJob failed. Permission Set information missing or nonexistent from CSV. To successfully ingest a Permission Set Key value must be present for any parent objects that have 'Open with Permission' visibility. Parent Object has defaulted to private and no child objects were created. Please delete parent object and re-attempt ingest with Permission Set Key and Visibility values in CSV.", 'failed') From 586a84b5f2b41a35025bc23371bbd40591fb1f19 Mon Sep 17 00:00:00 2001 From: K8Sewell Date: Thu, 12 Dec 2024 14:30:54 -0600 Subject: [PATCH 2/3] Remove duplicate method --- app/models/parent_object.rb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/models/parent_object.rb b/app/models/parent_object.rb index bd0a26746..a97da03c5 100644 --- a/app/models/parent_object.rb +++ b/app/models/parent_object.rb @@ -43,7 +43,6 @@ class ParentObject < ApplicationRecord # rubocop:disable Metrics/ClassLength # rubocop:enable Layout/LineLength validate :validate_visibility before_save :check_for_redirect - before_save :check_permission_set def check_for_redirect minify if redirect_to.present? @@ -94,10 +93,6 @@ def validate_visibility self.visibility = 'Private' end - def check_permission_set - self.permission_set = nil if visibility != "Open with Permission" - end - def initialize(attributes = nil) super self.use_ladybird = true From 4d58ff1e4a500e45dd7938283158d92de2350107 Mon Sep 17 00:00:00 2001 From: K8Sewell Date: Thu, 12 Dec 2024 16:12:21 -0600 Subject: [PATCH 3/3] Temporarily comment out conditional --- app/jobs/setup_metadata_job.rb | 3 ++- app/models/parent_object.rb | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/jobs/setup_metadata_job.rb b/app/jobs/setup_metadata_job.rb index 5b4bfd582..f9499f5a9 100644 --- a/app/jobs/setup_metadata_job.rb +++ b/app/jobs/setup_metadata_job.rb @@ -25,7 +25,8 @@ def perform(parent_object, current_batch_process, current_batch_connection = par return end - if (parent_object.visibility == 'Open with Permission' && parent_object.permission_set_id.nil?) || (parent_object.authoritative_json&.[]('itemPermission') == 'Open with Permission' && parent_object.permission_set_id.nil?) + # TODO: comment in second conditional once Open with Permission objects can go live in production + if parent_object.visibility == 'Open with Permission' && parent_object.permission_set_id.nil? # || (parent_object.authoritative_json&.[]('itemPermission') == 'Open with Permission' && parent_object.permission_set_id.nil?) permission_set = OpenWithPermission::PermissionSet.find_by(key: parent_object.permission_set&.key) if permission_set.nil? parent_object.processing_event("SetupMetadataJob failed. Permission Set information missing or nonexistent from CSV. To successfully ingest a Permission Set Key value must be present for any parent objects that have 'Open with Permission' visibility. Parent Object has defaulted to private and no child objects were created. Please delete parent object and re-attempt ingest with Permission Set Key and Visibility values in CSV.", 'failed') diff --git a/app/models/parent_object.rb b/app/models/parent_object.rb index a97da03c5..bd0a26746 100644 --- a/app/models/parent_object.rb +++ b/app/models/parent_object.rb @@ -43,6 +43,7 @@ class ParentObject < ApplicationRecord # rubocop:disable Metrics/ClassLength # rubocop:enable Layout/LineLength validate :validate_visibility before_save :check_for_redirect + before_save :check_permission_set def check_for_redirect minify if redirect_to.present? @@ -93,6 +94,10 @@ def validate_visibility self.visibility = 'Private' end + def check_permission_set + self.permission_set = nil if visibility != "Open with Permission" + end + def initialize(attributes = nil) super self.use_ladybird = true