[Rt-commit] rtir branch, 2.5-trunk, updated. 46806a3899346de1b3b1b7ce7f16f74dcde3d479

Ruslan Zakirov ruz at bestpractical.com
Wed Sep 16 01:15:21 EDT 2009


The branch, 2.5-trunk has been updated
       via  46806a3899346de1b3b1b7ce7f16f74dcde3d479 (commit)
       via  d9fc445c8438a5485b689d994091816bbf8379f2 (commit)
      from  1ab67f22b9783cf608106dd00cbc6c6a24e628b2 (commit)

Summary of changes:
 lib/RT/Action/RTIR_SetConstituency.pm              |    5 ++++-
 lib/RT/Condition/RTIR_RequireConstituencyChange.pm |   17 +++++++----------
 .../RTIR_RequireConstituencyGroupChange.pm         |   19 ++++++++-----------
 3 files changed, 19 insertions(+), 22 deletions(-)

- Log -----------------------------------------------------------------
commit d9fc445c8438a5485b689d994091816bbf8379f2
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Sep 15 05:38:58 2009 +0400

    lengthy line

diff --git a/lib/RT/Action/RTIR_SetConstituency.pm b/lib/RT/Action/RTIR_SetConstituency.pm
index 7d3a11a..ec129ec 100644
--- a/lib/RT/Action/RTIR_SetConstituency.pm
+++ b/lib/RT/Action/RTIR_SetConstituency.pm
@@ -80,7 +80,10 @@ sub InheritConstituency {
         my $tickets = RT::Tickets->new( $RT::SystemUser );
         $tickets->FromSQL( $query ." AND $link_type = ". $ticket->Id );
         while ( my $t = $tickets->Next ) {
-            $RT::Logger->debug( "Ticket #". $t->id ." inherits constituency from ticket #". $ticket->id );
+            $RT::Logger->debug(
+                "Ticket #". $t->id ." inherits constituency"
+                ." from ticket #". $ticket->id
+            );
             my ($res, $msg) = $t->AddCustomFieldValue(
                 Field => 'Constituency',
                 Value => $constituency,

commit 46806a3899346de1b3b1b7ce7f16f74dcde3d479
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Sep 15 05:41:25 2009 +0400

    don't apply scrips when constituency is disabled

diff --git a/lib/RT/Condition/RTIR_RequireConstituencyChange.pm b/lib/RT/Condition/RTIR_RequireConstituencyChange.pm
index 363115b..d8a539d 100644
--- a/lib/RT/Condition/RTIR_RequireConstituencyChange.pm
+++ b/lib/RT/Condition/RTIR_RequireConstituencyChange.pm
@@ -15,18 +15,15 @@ the Constituency Custom Field is changed
 sub IsApplicable {
     my $self = shift;
 
-    my $type = $self->TransactionObj->Type;
+    my $ticket = $self->TicketObj;
+    my $cf = $ticket->LoadCustomFieldByIdentifier('Constituency');
+    return 0 unless $cf && $cf->id;
+
+    my $txn = $self->TransactionObj;
+    my $type = $txn->Type;
     return 1 if $type eq 'Create';
     return 1 if $type eq 'AddLink';
-    if ( $type eq 'CustomField' ) {
-        my $cf = RT::CustomField->new( $RT::SystemUser );
-        $cf->Load('Constituency');
-        unless ( $cf->id ) {
-            $RT::Logger->error("Couldn't load the 'Costituency' field");
-            return 0;
-        }
-        return 1 if $cf->id == $self->TransactionObj->Field;
-    }
+    return 1 if $type eq 'CustomField' && $cf->id == $txn->Field;
     return 0;
 }
 
diff --git a/lib/RT/Condition/RTIR_RequireConstituencyGroupChange.pm b/lib/RT/Condition/RTIR_RequireConstituencyGroupChange.pm
index dc21dbe..0eb6475 100644
--- a/lib/RT/Condition/RTIR_RequireConstituencyGroupChange.pm
+++ b/lib/RT/Condition/RTIR_RequireConstituencyGroupChange.pm
@@ -15,18 +15,15 @@ Applies to Ticket Creation and Constituency changes
 sub IsApplicable {
     my $self = shift;
 
-    my $type = $self->TransactionObj->Type;
-    return 1 if $type eq 'Create';
-    if ( $type eq 'CustomField' ) {
-        my $cf = RT::CustomField->new( $RT::SystemUser );
-        $cf->Load('Constituency');
-        unless ( $cf->id ) {
-            $RT::Logger->error("Couldn't load the 'Costituency' field");
-            return 0;
-        }
-        return 1 if $cf->id == $self->TransactionObj->Field;
-    }
+    my $ticket = $self->TicketObj;
+    my $cf = $ticket->LoadCustomFieldByIdentifier('Constituency');
+    # no constituency
+    return 0 unless $cf && $cf->id;
 
+    my $txn = $self->TransactionObj;
+    my $type = $txn->Type;
+    return 1 if $type eq 'Create';
+    return 1 if $type eq 'CustomField' && $cf->id == $txn->Field;
     return 0;
 }
 

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


More information about the Rt-commit mailing list