[Rt-commit] rt branch, 4.2/template-abort, created. rt-4.2.3-173-g05d3108

Alex Vandiver alexmv at bestpractical.com
Wed Apr 30 17:24:39 EDT 2014


The branch, 4.2/template-abort has been created
        at  05d31080219157a6c6906dc0b957686bcc318b55 (commit)

- Log -----------------------------------------------------------------
commit 187cefa0a879b1719fc500a80071cc5d29bde15d
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Apr 30 17:23:50 2014 -0400

    Standardize global template logic with queue template logic

diff --git a/share/html/Admin/Global/Template.html b/share/html/Admin/Global/Template.html
index ed1dd3a..387dd21 100644
--- a/share/html/Admin/Global/Template.html
+++ b/share/html/Admin/Global/Template.html
@@ -73,35 +73,36 @@
 my $TemplateObj = RT::Template->new($session{'CurrentUser'});
 my  ($title, @results, $SubmitLabel);
 
-if ($Create) {
-  $title = loc("Create a template");
-  $SubmitLabel = loc('Create');
-}
-
-else {
-  if (defined ($Template) && $Template eq 'new') {
-      my ($val, $msg) =  $TemplateObj->Create(Queue => $Queue, Name => $Name, Type => $Type);
-      Abort(loc("Could not create template: [_1]", $msg)) unless ($val);
-     push @results, $msg;
+if (!$Create) {
+    if (defined ($Template) && $Template eq 'new') {
+        my ($val, $msg) =  $TemplateObj->Create(Queue => $Queue, Name => $Name, Type => $Type);
+        Abort(loc("Could not create template: [_1]", $msg)) unless ($val);
+        push @results, $msg;
+    } else {
+        $TemplateObj->Load($Template) || Abort(loc('No Template'));
     }
-    else {
-       $TemplateObj->Load($Template) || Abort(loc('No Template'));
-    }
-     $title = loc('Modify template [_1]', loc($TemplateObj->Name())); 
-     $SubmitLabel = loc('Save Changes');
-    
 }
+
 if ($TemplateObj->Id()) {
-  my @attribs = qw( Name Description Queue Type Content );
-  my @aresults = UpdateRecordObject( AttributesRef => \@attribs, 
-                                     Object => $TemplateObj, 
-                                     ARGSRef => \%ARGS);
-  push @results, @aresults;
+    my @attribs = qw( Name Description Queue Type Content );
+    my @aresults = UpdateRecordObject( AttributesRef => \@attribs, 
+                                       Object => $TemplateObj, 
+                                       ARGSRef => \%ARGS);
+    push @results, @aresults;
 
-  my ($ok, $msg) = $TemplateObj->CompileCheck;
-  push @results, $msg if !$ok;
+    my ($ok, $msg) = $TemplateObj->CompileCheck;
+    push @results, $msg if !$ok;
 }
 
+if ($Create) {
+    $title = loc("Create a template");
+    $SubmitLabel = loc('Create');
+} else {
+    $title = loc('Modify template [_1]', loc($TemplateObj->Name()));
+    $SubmitLabel = loc('Save Changes');
+}
+
+
 </%INIT>
 <%ARGS>
 $Queue => ''

commit 05d31080219157a6c6906dc0b957686bcc318b55
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Apr 30 17:24:27 2014 -0400

    Recover gracefully on template creation failure
    
    Fixes I#29021

diff --git a/share/html/Admin/Global/Template.html b/share/html/Admin/Global/Template.html
index 387dd21..4d20a03 100644
--- a/share/html/Admin/Global/Template.html
+++ b/share/html/Admin/Global/Template.html
@@ -59,10 +59,10 @@
 %# hang onto the queue id
 <input type="hidden" class="hidden" name="Queue" value="<%$Queue%>" />
 <& /Admin/Elements/ModifyTemplate,
-    Name        => $TemplateObj->Name,
-    Description => $TemplateObj->Description,
-    Content     => $TemplateObj->Content,
-    Type        => $TemplateObj->Type
+    Name        => $TemplateObj->Name // $ARGS{Name},
+    Description => $TemplateObj->Description // $ARGS{Description},
+    Content     => $TemplateObj->Content // $ARGS{Content},
+    Type        => $TemplateObj->Type // $ARGS{Type},
 &>
 <& /Elements/Submit, Label => $SubmitLabel, Reset => 1 &>
 </form>
@@ -76,7 +76,6 @@ my  ($title, @results, $SubmitLabel);
 if (!$Create) {
     if (defined ($Template) && $Template eq 'new') {
         my ($val, $msg) =  $TemplateObj->Create(Queue => $Queue, Name => $Name, Type => $Type);
-        Abort(loc("Could not create template: [_1]", $msg)) unless ($val);
         push @results, $msg;
     } else {
         $TemplateObj->Load($Template) || Abort(loc('No Template'));
@@ -92,6 +91,8 @@ if ($TemplateObj->Id()) {
 
     my ($ok, $msg) = $TemplateObj->CompileCheck;
     push @results, $msg if !$ok;
+} else {
+    $Create = 1;
 }
 
 if ($Create) {
diff --git a/share/html/Admin/Queues/Template.html b/share/html/Admin/Queues/Template.html
index dfcee30..984724b 100644
--- a/share/html/Admin/Queues/Template.html
+++ b/share/html/Admin/Queues/Template.html
@@ -59,10 +59,10 @@
 %# hang onto the queue id
 <input type="hidden" class="hidden" name="Queue" value="<%$Queue%>" />
 <& /Admin/Elements/ModifyTemplate,
-    Name        => $TemplateObj->Name,
-    Description => $TemplateObj->Description,
-    Content     => $TemplateObj->Content,
-    Type        => $TemplateObj->Type
+    Name        => $TemplateObj->Name // $ARGS{Name},
+    Description => $TemplateObj->Description // $ARGS{Description},
+    Content     => $TemplateObj->Content // $ARGS{Content},
+    Type        => $TemplateObj->Type // $ARGS{Type},
 &>
 <& /Elements/Submit, Label => $SubmitLabel, Reset => 1 &>
 </form>
@@ -80,7 +80,6 @@ if ( !$Create ) {
     if ( $Template eq 'new' ) {
         my ( $val, $msg )
             = $TemplateObj->Create( Queue => $Queue, Name => $Name, Type => $Type );
-        Abort( loc( "Could not create template: [_1]", $msg ) ) unless ($val);
         push @results, $msg;
     } else {
         $TemplateObj->Load($Template) || Abort( loc('No Template') );
@@ -102,6 +101,7 @@ if ( $TemplateObj->Id() ) {
     my ( $ok, $msg ) = $TemplateObj->CompileCheck;
     push @results, $msg if !$ok;
 } else {
+    $Create = 1;
     $QueueObj = RT::Queue->new( $session{'CurrentUser'} );
     $QueueObj->Load($Queue);
 }

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


More information about the rt-commit mailing list