[Rt-commit] rtir branch 5.0/class-templates-exclude-content-cf created. 5.0.1-32-g09bb5006

BPS Git Server git at git.bestpractical.com
Wed Nov 10 20:42:56 UTC 2021


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rtir".

The branch, 5.0/class-templates-exclude-content-cf has been created
        at  09bb5006329c3511d8aeba17dfe178c8f7c2e1f4 (commit)

- Log -----------------------------------------------------------------
commit 09bb5006329c3511d8aeba17dfe178c8f7c2e1f4
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Nov 11 03:58:44 2021 +0800

    Skip default "Content" custom field when inserting articles from "Templates"
    
    The class already has "Response" custom field to insert because of
    historical reasons, so "Content" is not needed here, not mentioning
    that "DutyTeam" doesn't have proper rights granted on it either.

diff --git a/etc/initialdata b/etc/initialdata
index d6b687fa..98f9398d 100644
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -672,8 +672,16 @@ for my $cf (@CustomFields) {
         }
 
         $response->AddToObject($class);
-        $class->SetAttribute( Name => "Skip-$_", Content => 1 )
-            for ( "Name", "Summary", "CF-Title-" . $response->Id );
+
+        my @skips = ( "Name", "Summary", "CF-Title-" . $response->Id );
+
+        my $content = RT::CustomField->new($CurrentUser);
+        $content->LoadByName( Name => 'Content', LookupType => RT::Article->CustomFieldLookupType );
+        if ( $content->Id && ( $content->IsGlobal || $content->IsAdded( $class->Id ) ) ) {
+            push @skips, "CF-Title-" . $content->Id, "CF-Value-" . $content->Id;
+        }
+
+        $class->SetAttribute( Name => "Skip-$_", Content => 1 ) for @skips;
 
         my $group = RT::Group->new($CurrentUser);
         $group->LoadUserDefinedGroup("DutyTeam");
diff --git a/etc/upgrade/5.0.2/content b/etc/upgrade/5.0.2/content
index 4dc54058..7da0ec35 100644
--- a/etc/upgrade/5.0.2/content
+++ b/etc/upgrade/5.0.2/content
@@ -143,4 +143,17 @@ our @Final = (
             }
         }
     },
+    sub {
+        my $class = RT::Class->new( RT->SystemUser );
+        $class->Load('Templates');
+        if ( $class->Id ) {
+            my $content = RT::CustomField->new( RT->SystemUser );
+            $content->LoadByName( Name => 'Content', LookupType => RT::Article->CustomFieldLookupType );
+            if ( $content->Id && ( $content->IsGlobal || $content->IsAdded( $class->Id ) ) ) {
+                for ( 'CF-Title-' . $content->Id, 'CF-Value-' . $content->Id ) {
+                    $class->SetAttribute( Name => "Skip-$_", Content => 1 );
+                }
+            }
+        }
+    },
 );

-----------------------------------------------------------------------


hooks/post-receive
-- 
rtir


More information about the rt-commit mailing list