[Rt-commit] [rtir] 01/01: Load base lifecycle queue by finding the queue with lowest ID
Shawn Moore
shawn at bestpractical.com
Fri May 13 20:06:57 EDT 2016
This is an automated email from the git hooks/post-receive script.
shawn pushed a commit to branch 3.4/countermeasures
in repository rtir.
commit f08f0d1abed8b5874eea9569df51b5f14311fec3
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Sat May 14 00:01:55 2016 +0000
Load base lifecycle queue by finding the queue with lowest ID
---
bin/add_constituency.in | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)
diff --git a/bin/add_constituency.in b/bin/add_constituency.in
index 81ca00b..d996965 100755
--- a/bin/add_constituency.in
+++ b/bin/add_constituency.in
@@ -146,8 +146,6 @@ unless ( defined $constituency && length $constituency ) {
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'} ) );
}
@@ -390,8 +388,8 @@ sub grant_group_cf_rights {
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 );
}
while ( my $cf = $cfs->Next ) {
@@ -466,12 +464,30 @@ sub load_queue {
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 );
+ my $basequeue = base_queue_for_lifecycle($lifecycle);
my $basequeue_name = RT::IR::FriendlyLifecycle($lifecycle);
my ($ok, $msg) = $basequeue->LoadByCols( Name => $basequeue_name );
@@ -612,8 +628,6 @@ sub rename_value {
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'
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the rt-commit
mailing list