[Rt-commit] rtir branch, 3.4/add-constituency-lib, repushed

Shawn Moore shawn at bestpractical.com
Wed May 25 18:05:25 EDT 2016


The branch 3.4/add-constituency-lib was deleted and repushed:
       was 22093dbf4bc29fffc71aa09ea427ba3e65d91ca7
       now d160d2c85b506a6f354c30ed1c7eac16eba6aeab

1:  224b3c3 = 1:  e3c1786 Add scaffolding for RT::IR::ConstituencyManager
2:  827f6f9 ! 2:  8f41187 Migrate the update logic out of add_constituency into ConstituencyManager
    @@ -1,6 +1,10 @@
     Author: Shawn M Moore <shawn at bestpractical.com>
     
         Migrate the update logic out of add_constituency into ConstituencyManager
    +    
    +        This lets us write tests for add_constituency without the
    +        headaches of invoking an external program. Also opens the
    +        door to this becoming admin UI.
     
     diff --git a/bin/add_constituency.in b/bin/add_constituency.in
     --- a/bin/add_constituency.in
    @@ -30,8 +34,6 @@
      }
      
     -my @lifecycles = RT::IR->Lifecycles;
    --
    --my @queue_prefixes = map { RT::IR::FriendlyLifecycle($_) } @lifecycles;
     -
     -if ( exists $opt{'rename'} ) {
     -    exit rename_value( $constituency => sanitize_value( $opt{'rename'} ) );
    @@ -72,7 +74,7 @@
     +    $RT::Handle->BeginTransaction;
      
     -END
    -+    my $exist = $manager->cf_value_exists($constituency);
    ++    my $exist = $manager->CustomFieldValueExists($constituency);
      
     -unless ( $opt{'force'} ) {
     +    debug "\nIf you continue then we'll...\n";
    @@ -179,7 +181,7 @@
          }
     -    return $cf;
     -}
    - 
    +-
     -sub grant_role_queue_rights {
     -    my $queues = shift;
     -    my $everyone = RT::Group->new( RT->SystemUser );
    @@ -187,18 +189,18 @@
     -    foreach my $queue ( values %$queues ) {
     -        debug "Granting role rights to Everyone for queue " . $queue->Name . "\n";
     -        my @rights;
    --
    --        if ( $queue->Lifecycle eq 'incident_reports' ) {
    + 
    +-        if ( $queue->Lifecycle eq RT::IR->lifecycle_report ) {
     -            @rights = RT::IR->EveryoneIncidentReportRights();
    --        } elsif ( $queue->Lifecycle eq 'incidents' ) {
    +-        } elsif ( $queue->Lifecycle eq RT::IR->lifecycle_incident ) {
     -            @rights = RT::IR->EveryoneIncidentRights();
     -
     -        }
    --        if ( $queue->Lifecycle eq 'investigations' ) {
    +-        if ( $queue->Lifecycle eq RT::IR->lifecycle_investigation ) {
     -            @rights = RT::IR->EveryoneInvestigationRights();
     -
    --        } elsif ( $queue->Lifecycle eq 'countermeaures' ) {
    --            @rights = RT::IR->EveryoneBlockRights();
    +-        } elsif ( $queue->Lifecycle eq RT::IR->lifecycle_countermeasure ) {
    +-            @rights = RT::IR->EveryoneCountermeasureRights();
     -        }
     -        # grant 'everyone' rights
     -        for my $right (@rights) {
    @@ -238,7 +240,7 @@
     -            debug  "done\n";
     -        }
     -        }
    -+    foreach my $name ($manager->queue_names) {
    ++    foreach my $name ($manager->QueueNames) {
     +        debug "* create queue '$name' if it doesn't exist\n";
          }
     -}
    @@ -331,8 +333,8 @@
     -    my @rights = (@_);
     -
     -    my $cfs = RT::CustomFields->new($RT::SystemUser);
    --    for my $queue (@queue_prefixes) {
    --        my $q = load_queue($queue);
    +-    for my $lifecycle (@lifecycles) {
    +-        my $q = base_queue_for_lifecycle($lifecycle);
     -        $cfs->LimitToObjectId( $q->Id );
     -    }
     -
    @@ -384,14 +386,30 @@
     -    return $queue;
     -}
     -
    +-# load the first queue with the lifecycle we're after, which is meant
    +-# a proxy for the "original" RTIR queue of that lifecycle. we can't rely
    +-# on the name because the base countermeasures queue may be named Blocks
    +-# due to historical reasons
    +-sub base_queue_for_lifecycle {
    +-    my $lifecycle = shift;
    +-
    +-    my $queues = RT::Queues->new(RT->SystemUser);
    +-    $queues->Limit(FIELD => 'Lifecycle', VALUE => $lifecycle);
    +-    $queues->OrderByCols({
    +-        ALIAS => 'main',
    +-        FIELD => 'id',
    +-        ORDER => 'ASC',
    +-    });
    +-
    +-    return $queues->First;
    +-}
    +-
     -sub create_or_load_queue {
     -    my $name            = shift;
     -    my $lifecycle       = shift;
     -    my $constituency_cf = shift;
     -
    --    my $basequeue = RT::Queue->new( RT->SystemUser );
    --
    --    $basequeue->LoadByCols( Name => RT::IR::FriendlyLifecycle($lifecycle) );
    +-    my $basequeue = base_queue_for_lifecycle($lifecycle);
     -
     -    my $queue = RT::Queue->new($RT::SystemUser);
     -    $queue->LoadByCols( Name => $name );
    @@ -422,10 +440,7 @@
     -            } else {
     -                debug "\tnew $type address: " . $opt{ lc $type };
     -            }
    -+            exit 0
    -+                unless prompt_yN(
    -+                "Do you want to proceed creating the new constituency?");
    -         }
    +-        }
     -        if ( $queue->SLADisabled != $basequeue->SLADisabled ) {
     -            my ( $status, $msg ) = $queue->SetSLADisabled( $basequeue->SLADisabled );
     -            if ($status) {
    @@ -434,9 +449,12 @@
     -            else {
     -                print STDERR "Couldn't set SLADisabled of '$name' queue: $msg\n";
     -            }
    --        }
    --    }
    --
    ++            exit 0
    ++                unless prompt_yN(
    ++                "Do you want to proceed creating the new constituency?");
    +         }
    +     }
    + 
     -    my $basecfs = RT::CustomFields->new( RT->SystemUser );
     -    $basecfs->SetContextObject($basequeue);
     -    $basecfs->LimitToObjectId( $basequeue->id );
    @@ -461,13 +479,13 @@
     -            . " to queue "
     -            . $queue->Name . "\n";
     -        $base_txncf->AddToObject($queue);
    -     }
    - 
    +-    }
    +-
     -    $constituency_cf->AddToObject($queue);
     -    $queue->AddCustomFieldValue(
     -        Field => $constituency_cf->id,
     -        Value => $constituency
    -+    my ($ok) = $manager->add_constituency(
    ++    my ($ok) = $manager->AddConstituency(
     +        Correspond => $opt{correspond},
     +        Comment    => $opt{comment},
          );
    @@ -510,18 +528,18 @@
     -    my $new = shift;
     -
     -    my $value_obj;
    +-
    +-    my $constituency_cf = get_constituency_cf();
     +sub rename_constituency {
    -+    my $new = $manager->sanitize_value(shift);
    ++    my $new = $manager->SanitizeValue(shift);
     +    my $old = $manager->Constituency;
      
    --    my $constituency_cf = get_constituency_cf();
    --
     -    unless ( $value_obj = cf_value_exists($old) ) {
    -+    unless ( $manager->cf_value_exists($old) ) {
    ++    unless ( $manager->CustomFieldValueExists($old) ) {
              die "Couldn't rename. Constituency '$old' doesn't exist.";
          }
     -    if ( cf_value_exists($new) ) {
    -+    if ( $manager->cf_value_exists($new) ) {
    ++    if ( $manager->CustomFieldValueExists($new) ) {
              die "Couldn't rename. Constituency '$new' already exists.";
          }
      
    @@ -534,13 +552,6 @@
          $queues->UnLimit;
          while ( my $queue = $queues->Next ) {
     @@
    -         debug "* rename queue '$oldname' to '$newname'.\n";
    -     }
    - 
    --    foreach my $basename (@queue_prefixes) {
    --    }
    -     debug <<END;
    - * rename group 'DutyTeam $old' if it exists into 'DutyTeam $new'
      * rename group 'ReadOnly $old' if it exists into 'ReadOnly $new'
      
      END
    @@ -552,7 +563,7 @@
     -        die $msg unless $status;
     -        debug "Renamed constituency value '$old' -> '$new'.\n";
     -    }
    -+    my ($ok) = $manager->rename_constituency($new);
    ++    my ($ok) = $manager->RenameConstituency($new);
      
     -    $queues = RT::Queues->new( RT->SystemUser );
     -    $queues->UnLimit;
    @@ -650,7 +661,7 @@
     +        @_,
     +    );
     +
    -+    $self->{Constituency} = $self->sanitize_value($args{Constituency});
    ++    $self->{Constituency} = $self->SanitizeValue($args{Constituency});
     +}
     +
     +sub Constituency {
    @@ -658,18 +669,15 @@
     +    return $self->{Constituency};
     +}
     +
    -+sub queue_prefixes {
    -+    return map { RT::IR::FriendlyLifecycle($_) } RT::IR->Lifecycles;
    -+}
    -+
    -+sub queue_names {
    ++sub QueueNames {
     +    my $self = shift;
     +    my $constituency = $self->Constituency;
     +
    -+    return map { "$_ - $constituency" } $self->queue_prefixes;
    -+}
    -+
    -+sub get_whois_cf {
    ++    return map { "$_ - $constituency" }
    ++           map { RT::IR::FriendlyLifecycle($_) } RT::IR->Lifecycles;
    ++}
    ++
    ++sub WhoisCustomField {
     +    my $self = shift;
     +
     +    my $whois_cf = RT::CustomField->new( RT->SystemUser );
    @@ -683,7 +691,7 @@
     +    return $whois_cf;
     +}
     +
    -+sub get_constituency_cf {
    ++sub ConstituencyCustomField {
     +    my $self = shift;
     +    my $cf = RT::CustomField->new($RT::SystemUser);
     +    $cf->Load( "RTIR Constituency", LookupType => 'RT::Queue' );
    @@ -693,13 +701,13 @@
     +    return $cf;
     +}
     +
    -+sub cf_value_exists {
    ++sub CustomFieldValueExists {
     +    my $self = shift;
     +    my $value = shift;
     +
     +    RT->Logger->debug("Check that constituency '$value' exists");
     +
    -+    my $cf     = $self->get_constituency_cf();
    ++    my $cf     = $self->ConstituencyCustomField;
     +    my $values = $cf->Values;
     +    $values->Limit( FIELD => 'Name', VALUE => $value );
     +    my $value_obj = $values->First;
    @@ -707,14 +715,14 @@
     +    else                                  { return undef; }
     +}
     +
    -+sub add_cf_value {
    ++sub AddCustomFieldValue {
     +    my $self = shift;
     +    my $value = shift;
     +
     +    RT->Logger->debug("Adding the value to the constituency CF");
     +
    -+    my $cf = $self->get_constituency_cf();
    -+    if ( $self->cf_value_exists($value) ) {
    ++    my $cf = $self->ConstituencyCustomField;
    ++    if ( $self->CustomFieldValueExists($value) ) {
     +        RT->Logger->debug("Value '$value' already exists");
     +    } else {
     +        my ( $val, $msg ) = $cf->AddValue( Name => $value );
    @@ -724,20 +732,37 @@
     +    return $cf;
     +}
     +
    -+sub create_or_load_queue {
    ++# load the first queue with the lifecycle we're after, which is meant
    ++# a proxy for the "original" RTIR queue of that lifecycle. we can't rely
    ++# on the name because the base countermeasures queue may be named Blocks
    ++# due to historical reasons
    ++sub BaseQueueForLifecycle {
    ++    my $self = shift;
    ++    my $lifecycle = shift;
    ++
    ++    my $queues = RT::Queues->new(RT->SystemUser);
    ++    $queues->Limit(FIELD => 'Lifecycle', VALUE => $lifecycle);
    ++    $queues->OrderByCols({
    ++        ALIAS => 'main',
    ++        FIELD => 'id',
    ++        ORDER => 'ASC',
    ++    });
    ++
    ++    return $queues->First;
    ++}
    ++
    ++sub CreateOrLoadQueue {
     +    my $self = shift;
     +    my %args = (
     +        Name       => undef,
     +        Lifecycle  => undef,
     +        Correspond => undef,
     +        Comment    => undef,
    -+        @_,
    -+    );
    +         @_,
    +     );
     +    my $name = $args{Name};
     +
    -+    my $basequeue = RT::Queue->new( RT->SystemUser );
    -+
    -+    $basequeue->LoadByCols( Name => RT::IR::FriendlyLifecycle($args{Lifecycle}) );
    ++    my $basequeue = $self->BaseQueueForLifecycle($args{Lifecycle});
     +
     +    my $queue = RT::Queue->new($RT::SystemUser);
     +    $queue->LoadByCols( Name => $name );
    @@ -806,14 +831,14 @@
     +        $base_txncf->AddToObject($queue);
     +    }
     +
    -+    my $constituency_cf = $self->get_constituency_cf;
    ++    my $constituency_cf = $self->ConstituencyCustomField;
     +    $constituency_cf->AddToObject($queue);
     +    $queue->AddCustomFieldValue(
     +        Field => $constituency_cf->id,
     +        Value => $self->Constituency,
     +    );
     +
    -+    my $whois_cf = $self->get_whois_cf;
    ++    my $whois_cf = $self->WhoisCustomField;
     +    $whois_cf->AddToObject($queue);
     +
     +    my $templates = RT::Templates->new( RT->SystemUser );
    @@ -839,7 +864,7 @@
     +    return $queue;
     +}
     +
    -+sub create_or_load_queues {
    ++sub CreateOrLoadQueues {
     +    my $self = shift;
     +    my %args = @_;
     +
    @@ -848,7 +873,7 @@
     +
     +    foreach my $lifecycle (RT::IR->Lifecycles) {
     +        my $name = RT::IR::FriendlyLifecycle($lifecycle) . " - " . $constituency;
    -+        $queues{$lifecycle} = $self->create_or_load_queue(
    ++        $queues{$lifecycle} = $self->CreateOrLoadQueue(
     +            Name       => $name,
     +            Lifecycle  => $lifecycle,
     +            %args,
    @@ -858,7 +883,7 @@
     +    return %queues;
     +}
     +
    -+sub create_or_load_group {
    ++sub CreateOrLoadGroup {
     +    my $self = shift;
     +    my $name = shift;
     +    my $group = RT::Group->new($RT::SystemUser);
    @@ -876,34 +901,31 @@
     +}
     +
     +# XXX TODO this should be looking at cfs on the new queues
    -+sub grant_group_cf_rights {
    ++sub GrantGroupCustomFieldRights {
     +    my $self   = shift;
     +    my $group  = shift;
     +    my @rights = (@_);
     +
     +    my $cfs = RT::CustomFields->new($RT::SystemUser);
    -+    for my $name ($self->queue_prefixes) {
    -+        my $queue = RT::Queue->new($RT::SystemUser);
    -+        $queue->LoadByCols( Name => $name );
    -+        die "Couldn't load queue '$name'" unless $queue && $queue->id;
    -+
    ++    for my $lifecycle (RT::IR->Lifecycles) {
    ++        my $queue = $self->BaseQueueForLifecycle($lifecycle);
     +        $cfs->LimitToObjectId( $queue->Id );
     +    }
     +
     +    while ( my $cf = $cfs->Next ) {
    -+        $self->grant_group_single_cf_rights( $cf, $group, @rights );
    ++        $self->GrantGroupSingleCustomFieldRights( $cf, $group, @rights );
     +    }
     +
     +    # explicitly grant rights on 'RTIR Constituency' cf as well
    -+    my $rtir_constituency_cf = $self->get_constituency_cf();
    -+    $self->grant_group_single_cf_rights( $rtir_constituency_cf, $group, @rights );
    ++    my $rtir_constituency_cf = $self->ConstituencyCustomField();
    ++    $self->GrantGroupSingleCustomFieldRights( $rtir_constituency_cf, $group, @rights );
     +
     +    RT->Logger->info("Granted rights for custom fields to group " . $group->Name);
     +
     +    return 1;
     +}
     +
    -+sub grant_group_single_cf_rights {
    ++sub GrantGroupSingleCustomFieldRights {
     +    my $self   = shift;
     +    my $cf     = shift;
     +    my $group  = shift;
    @@ -941,7 +963,7 @@
     +    }
     +}
     +
    -+sub grant_role_queue_rights {
    ++sub GrantRoleQueueRights {
     +    my $self   = shift;
     +    my $queues = shift;
     +
    @@ -952,17 +974,17 @@
     +        RT->Logger->debug("Granting role rights to Everyone for queue " . $queue->Name);
     +        my @rights;
     +
    -+        if ( $queue->Lifecycle eq 'incident_reports' ) {
    ++        if ( $queue->Lifecycle eq RT::IR->lifecycle_report ) {
     +            @rights = RT::IR->EveryoneIncidentReportRights();
    -+        } elsif ( $queue->Lifecycle eq 'incidents' ) {
    ++        } elsif ( $queue->Lifecycle eq RT::IR->lifecycle_incident ) {
     +            @rights = RT::IR->EveryoneIncidentRights();
     +
     +        }
    -+        if ( $queue->Lifecycle eq 'investigations' ) {
    ++        if ( $queue->Lifecycle eq RT::IR->lifecycle_investigation ) {
     +            @rights = RT::IR->EveryoneInvestigationRights();
     +
    -+        } elsif ( $queue->Lifecycle eq 'countermeaures' ) {
    -+            @rights = RT::IR->EveryoneBlockRights();
    ++        } elsif ( $queue->Lifecycle eq RT::IR->lifecycle_countermeasure ) {
    ++            @rights = RT::IR->EveryoneCountermeasureRights();
     +        }
     +        # grant 'everyone' rights
     +        for my $right (@rights) {
    @@ -972,7 +994,7 @@
     +                Object => $queue,
     +                Right  => $right)) {
     +                RT->Logger->debug("skipping, already granted");
    -+            } else { 
    ++            } else {
     +            my ( $val, $msg ) = $everyone->PrincipalObj->GrantRight(
     +                Object => $queue,
     +                Right  => $right
    @@ -993,7 +1015,7 @@
     +                Right  => $right
     +            )) {
     +                RT->Logger->debug("skipping, already granted");
    -+            } else { 
    ++            } else {
     +                my ( $val, $msg ) = $owner->PrincipalObj->GrantRight(
     +                    Object => $queue,
     +                    Right  => $right
    @@ -1007,7 +1029,7 @@
     +    }
     +}
     +
    -+sub grant_group_queue_rights {
    ++sub GrantGroupQueueRights {
     +    my $self   = shift;
     +    my $group  = shift;
     +    my $queues = shift;
    @@ -1053,46 +1075,46 @@
     +    return 1;
     +}
     +
    -+sub add_constituency {
    ++sub AddConstituency {
     +    my $self = shift;
     +    my %args = (
     +        Correspond => undef,
     +        Comment    => undef,
    -         @_,
    -     );
    ++        @_,
    ++    );
     +
     +    my $constituency = $self->Constituency;
     +
     +    RT->Logger->info("Adding constituency $constituency");
     +
    -+    my $constituency_cf = $self->add_cf_value($constituency);
    ++    my $constituency_cf = $self->AddCustomFieldValue($constituency);
     +
     +    # Create our four new queues
    -+    my %queues = $self->create_or_load_queues(%args);
    ++    my %queues = $self->CreateOrLoadQueues(%args);
     +
     +    # Create a DutyTeam $constituency
    -+    my $dutyteam = $self->create_or_load_group( 'DutyTeam ' . $constituency );
    -+    my $ro       = $self->create_or_load_group( 'ReadOnly ' . $constituency );
    ++    my $dutyteam = $self->CreateOrLoadGroup( 'DutyTeam ' . $constituency );
    ++    my $ro       = $self->CreateOrLoadGroup( 'ReadOnly ' . $constituency );
     +
     +    # Grant that new dutyteam rights to see and update the CFs
    -+    $self->grant_group_cf_rights( $dutyteam, @DUTYTEAM_CF_RIGHTS );
    ++    $self->GrantGroupCustomFieldRights( $dutyteam, @DUTYTEAM_CF_RIGHTS );
     +
     +    # Grant that new dutyteam all the regular dutyteam rights for the new constituency queues
    -+    $self->grant_group_queue_rights( $dutyteam, \%queues,
    ++    $self->GrantGroupQueueRights( $dutyteam, \%queues,
     +        RT::IR->DutyTeamAllQueueRights );
     +
     +    # Create or load the group "ReadOnly $constituency"
    -+    $self->grant_group_cf_rights( $ro, @RO_CF_RIGHTS );
    ++    $self->GrantGroupCustomFieldRights( $ro, @RO_CF_RIGHTS );
     +
     +    # Grant the new readonly group the rights to see the RTIR queues
    -+    $self->grant_group_queue_rights( $ro, \%queues, @RO_QUEUE_RIGHTS );
    -+
    -+    $self->grant_role_queue_rights( \%queues );
    ++    $self->GrantGroupQueueRights( $ro, \%queues, @RO_QUEUE_RIGHTS );
    ++
    ++    $self->GrantRoleQueueRights( \%queues );
     +
     +    return 1;
     +}
     +
    -+sub _group_exists {
    ++sub _GroupExists {
     +    my $self  = shift;
     +    my $name  = shift;
     +    my $group = RT::Group->new($RT::SystemUser);
    @@ -1100,15 +1122,15 @@
     +    return $group && $group->id ? $group : undef;
     +}
     +
    -+sub rename_constituency {
    -+    my $self = shift;
    -+    my $new = $self->sanitize_value(shift);
    ++sub RenameConstituency {
    ++    my $self = shift;
    ++    my $new = $self->SanitizeValue(shift);
     +    my $old = $self->Constituency;
     +
    -+    my $constituency_cf = $self->get_constituency_cf;
    ++    my $constituency_cf = $self->ConstituencyCustomField;
     +
     +    {
    -+        my $value_obj = $self->cf_value_exists($old);
    ++        my $value_obj = $self->CustomFieldValueExists($old);
     +        my ( $status, $msg ) = $value_obj->SetName($new);
     +        die $msg unless $status;
     +        RT->Logger->info("Renamed constituency value '$old' -> '$new'.");
    @@ -1138,12 +1160,12 @@
     +        my $old_name = "$basename $old";
     +        my $new_name = "$basename $new";
     +
    -+        my $group = $self->_group_exists($old_name);
    ++        my $group = $self->_GroupExists($old_name);
     +        unless ($group) {
     +            RT->Logger->debug("Group '$old_name' doesn't exist. Skipping...");
     +            next;
     +        }
    -+        if ( $self->_group_exists($new_name) ) {
    ++        if ( $self->_GroupExists($new_name) ) {
     +            die
     +                "Couldn't rename group, target '$new_name' already exists.";
     +        }
    @@ -1157,7 +1179,7 @@
     +    return 1;
     +}
     +
    -+sub sanitize_value {
    ++sub SanitizeValue {
     +    my $self = shift;
     +    my $value = shift;
     +
3:  d8abc51 ! 3:  7f1184a Factor out a ->Queues method doing the CF search in SQL
    @@ -1,6 +1,6 @@
     Author: Shawn M Moore <shawn at bestpractical.com>
     
    -    Factor out a ->queues method doing the CF search in SQL
    +    Factor out a ->Queues method doing the CF search in SQL
     
     diff --git a/bin/add_constituency.in b/bin/add_constituency.in
     --- a/bin/add_constituency.in
    @@ -16,7 +16,7 @@
     -            unless (
     -            ( $queue->FirstCustomFieldValue('RTIR Constituency') || '' ) eq
     -            $old );
    -+    my $queues = $manager->queues;
    ++    my $queues = $manager->Queues;
     +    while (my $queue = $queues->Next) {
              my $oldname = $queue->Name;
              my $newname = $oldname;
    @@ -26,21 +26,21 @@
     --- a/lib/RT/IR/ConstituencyManager.pm
     +++ b/lib/RT/IR/ConstituencyManager.pm
     @@
    -     return map { "$_ - $constituency" } $self->queue_prefixes;
    +            map { RT::IR::FriendlyLifecycle($_) } RT::IR->Lifecycles;
      }
      
    -+sub queues {
    ++sub Queues {
     +    my $self = shift;
     +
     +    my $queues = RT::Queues->new( RT->SystemUser );
     +    $queues->LimitCustomField(
    -+        CUSTOMFIELD => $self->get_constituency_cf->Id,
    ++        CUSTOMFIELD => $self->ConstituencyCustomField->Id,
     +        VALUE       => $self->Constituency,
     +    );
     +    return $queues;
     +}
     +
    - sub get_whois_cf {
    + sub WhoisCustomField {
          my $self = shift;
      
     @@
    @@ -57,7 +57,7 @@
     -        my $oldname = $queue->Name;
     -        my $newname = $oldname;
     -        $newname =~ s/$old/$new/;
    -+    my $queues = $self->queues;
    ++    my $queues = $self->Queues;
     +    while (my $queue = $queues->Next) {
              $queue->AddCustomFieldValue(
                  Field => $constituency_cf->id,
4:  31aeded ! 4:  5a65fa1 Rename debug function to notify
    @@ -19,7 +19,7 @@
          return 1;
     @@
      
    -     my $exist = $manager->cf_value_exists($constituency);
    +     my $exist = $manager->CustomFieldValueExists($constituency);
      
     -    debug "\nIf you continue then we'll...\n";
     +    notify "\nIf you continue then we'll...\n";
    @@ -31,7 +31,7 @@
     +        notify "* add new constituency value: '$constituency'.\n";
          }
      
    -     foreach my $name ($manager->queue_names) {
    +     foreach my $name ($manager->QueueNames) {
     -        debug "* create queue '$name' if it doesn't exist\n";
     +        notify "* create queue '$name' if it doesn't exist\n";
          }
    @@ -64,7 +64,7 @@
     +    notify "\nIf you continue then we'll...\n";
     +    notify "* rename constituency value '$old' into '$new'.\n";
      
    -     my $queues = $manager->queues;
    +     my $queues = $manager->Queues;
          while (my $queue = $queues->Next) {
     @@
              my $newname = $oldname;
5:  d51f9dc = 5:  60d4f66 Have --quiet and new --verbose options manage output log level
6:  3a0c2f0 ! 6:  3fdffd2 Make prompt messages clearer in add_constituency
    @@ -21,6 +21,6 @@
     -    return 0 unless prompt_yN("Do you want to proceed?");
     +    return 0 unless prompt_yN("Do you want to proceed with renaming this constituency?");
      
    -     my ($ok) = $manager->rename_constituency($new);
    +     my ($ok) = $manager->RenameConstituency($new);
      
     
7:  d62c871 < -:  ------- Rename ConstituencyManager methods from snake_case to CamelCase
8:  fa28f33 ! 7:  a61fafe Switch test from using bin/add_constituency to ConstituencyManager
    @@ -1,6 +1,6 @@
     Author: Shawn M Moore <shawn at bestpractical.com>
     
    -    Switch test from invoking bin/add_constituency to using RT::IR::ConstituencyManager
    +    Switch test from using bin/add_constituency to ConstituencyManager
     
     diff --git a/t/constituency/basics.t b/t/constituency/basics.t
     --- a/t/constituency/basics.t
9:  22093db < -:  ------- Have upgrade script use ConstituencyManager rather than bin/add_constituency
-:  ------- > 8:  d160d2c Switch upgrade from using bin/add_constituency to ConstituencyManager



More information about the rt-commit mailing list