[Rt-commit] [rtir] 13/22: Move most RTIR rights out of initialdata and into RT::IR in prep for also using them in add_constituency

Jesse Vincent jesse at bestpractical.com
Sun Mar 29 02:51:01 EDT 2015


This is an automated email from the git hooks/post-receive script.

jesse pushed a commit to branch 3.4/remove_old_constituencies
in repository rtir.

commit 2e377053fcbf2408968589ecf9cf64ca34806c22
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Sat Mar 28 21:49:04 2015 -0700

    Move most RTIR rights out of initialdata and into RT::IR
    in prep for also using them in add_constituency
---
 etc/initialdata | 172 +++++++++++++++++++++++---------------------------------
 lib/RT/IR.pm    |  36 ++++++++++++
 2 files changed, 105 insertions(+), 103 deletions(-)

diff --git a/etc/initialdata b/etc/initialdata
index d54bddd..a243ff1 100644
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -2,45 +2,24 @@
 
 @Initial = (
     sub {
-        # put fake lifecycles for initiialization to succed
-        my $lc = RT->Config->Get('Lifecycles') || {};
-        # XXX TODO can we pull the lifecycles from lib/RT/IR.pm?
-        foreach my $name (qw(incidents incident_reports investigations blocks)) {
-            $lc->{ $name } ||= $lc->{'default'} || {};
-        }
-        RT->Config->Set(Lifecycles => %$lc);
+        use RT::IR;
         RT::Lifecycle->FillCache;
         return 1;
     },
 );
 
- at Queues = (
-    {
-        Name              => 'Incidents',
-        Lifecycle         => 'incidents',
-        CorrespondAddress => "",
-        CommentAddress    => "",
-        InitialPriority   => 50,
-    },
-    {
-        Name              => 'Incident Reports',
-        Lifecycle         => 'incident_reports',
+ at Queues = map {
+    {   Name              => RT::IR::FriendlyLifecycle($_),
+        Lifecycle         => $_,
         CorrespondAddress => "",
         CommentAddress    => "",
-    },
-    {
-        Name              => 'Investigations',
-        Lifecycle         => 'investigations',
-        CorrespondAddress => "",
-        CommentAddress    => "",
-    },
-    {
-        Name              => 'Blocks',
-        Lifecycle         => 'blocks',
-        CorrespondAddress => "",
-        CommentAddress    => "",
-    },
-);
+        InitialPriority   => (
+            $_ eq 'incidents'
+            ? 50
+            : undef
+        )
+    }
+} RT::IR->Lifecycles;
 
 @CustomFields = (
     {
@@ -487,78 +466,65 @@ you may reply to this message.
 );
 
 @ACL = ();
-for my $queue (map {$_->{Name}} @Queues) {
-    push @ACL, (
-    { GroupDomain => 'RT::Queue-Role',
-      GroupType => 'Owner',
-      Queue => $queue,
-      Right  => 'ModifyTicket', },
-    { GroupId => 'DutyTeam',      # - principalId
-      GroupDomain => 'UserDefined',
-      Queue => $queue,
-      Right  => 'ShowTemplate', },
-    { GroupId => 'DutyTeam',      # - principalId
-      GroupDomain => 'UserDefined',
-      Queue => $queue,
-      Right  => 'CreateTicket', },
-    { GroupId => 'DutyTeam',      # - principalId
-      GroupDomain => 'UserDefined',
-      Queue => $queue,
-      Right  => 'OwnTicket', },
-    { GroupId => 'DutyTeam',      # - principalId
-      GroupDomain => 'UserDefined',
-      Queue => $queue,
-      Right  => 'CommentOnTicket', },
-    { GroupId => 'DutyTeam',      # - principalId
-      GroupDomain => 'UserDefined',
-      Queue => $queue,
-      Right  => 'SeeQueue', },
-    { GroupId => 'DutyTeam',      # - principalId
-      GroupDomain => 'UserDefined',
-      Queue => $queue,
-      Right  => 'ShowTicket', },
-    { GroupId => 'DutyTeam',      # - principalId
-      GroupDomain => 'UserDefined',
-      Queue => $queue,
-      Right  => 'ShowTicketComments', },
-    { GroupId => 'DutyTeam',      # - principalId
-      GroupDomain => 'UserDefined',
-      Queue => $queue,
-      Right  => 'StealTicket', },
-    { GroupId => 'DutyTeam',      # - principalId
-      GroupDomain => 'UserDefined',
-      Queue => $queue,
-      Right  => 'TakeTicket', },
-    { GroupId => 'DutyTeam',      # - principalId
-      GroupDomain => 'UserDefined',
-      Queue => $queue,
-      Right  => 'Watch', },
-    { GroupId => 'DutyTeam',      # - principalId
-      GroupDomain => 'UserDefined',
-      Queue => $queue,
-      Right  => 'ShowOutgoingEmail', },
-);}
+for my $queue ( map { $_->{Name} } @Queues ) {
+    foreach my $right ( RT::IR->OwnerAllQueueRights ) {
+        push @ACL,
+            (
+            {   GroupDomain => 'RT::Queue-Role',
+                GroupType   => 'Owner',
+                Queue       => $queue,
+                Right       => $right
+            },
+            );
+    }
+}
 
-push @ACL, (
-    { GroupType => 'Everyone', 
-      GroupDomain => 'SystemInternal',
-      Queue => 'Incident Reports',
-      Right  => 'CreateTicket', },
-    { GroupType => 'Everyone', 
-      GroupDomain => 'SystemInternal',
-      Queue => 'Incident Reports',
-      Right  => 'ReplyToTicket', },
-
-    { GroupType => 'Everyone', 
-      GroupDomain => 'SystemInternal',
-      Queue => 'Investigations',
-      Right  => 'ReplyToTicket', },
-
-    { GroupType => 'Everyone', 
-      GroupDomain => 'SystemInternal',
-      Queue => 'Blocks',
-      Right  => 'ReplyToTicket', },
-);
+for my $queue ( map { $_->{Name} } @Queues ) {
+    foreach my $right ( RT::IR->DutyTeamAllQueueRights ) {
+        push @ACL, {
+            GroupId     => 'DutyTeam',      # - principalId
+            GroupDomain => 'UserDefined',
+            Queue       => $queue,
+            Right       => $right
+            },
+
+    }
+}
+
+push @ACL, map {
+    {   Queue       => 'Investigations',
+        GroupType   => 'Everyone',
+        GroupDomain => 'SystemInternal',
+
+        Right => $_
+    }
+} RT::IR->EveryoneInvestigationRights();
+
+push @ACL, map {
+    {   Queue       => 'Incidents',
+        GroupType   => 'Everyone',
+        GroupDomain => 'SystemInternal',
+
+        Right => $_
+    }
+} RT::IR->EveryoneIncidentRights();
+
+push @ACL, map {
+
+    {   GroupType   => 'Everyone',
+        GroupDomain => 'SystemInternal',
+        Queue       => 'Incident Reports',
+        Right       => $_
+    }
+} RT::IR->EveryoneIncidentReportRights();
+
+push @ACL, map {
+    {   GroupType   => 'Everyone',
+        GroupDomain => 'SystemInternal',
+        Queue       => 'Blocks',
+        Right       => $_
+    }
+} RT::IR->EveryoneBlockRights();
 
 push @ACL, (
     { GroupId => 'DutyTeam',      # - principalId
diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index f20e794..10021a5 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -91,6 +91,42 @@ my %FRIENDLY_LIFECYCLE = (
 
 );
 
+sub DutyTeamAllQueueRights {
+    return (
+        qw( CreateTicket
+            ShowTemplate
+            OwnTicket
+            CommentOnTicket
+            SeeQueue
+            ShowTicket
+            ShowTicketComments
+            StealTicket
+            TakeTicket
+            Watch
+            ShowOutgoingEmail
+            ));
+
+}
+
+sub OwnerAllQueueRights {
+    return (qw(ModifyTicket));
+}
+
+sub EveryoneIncidentReportRights {
+    return (qw(CreateTicket ReplyToTicket));
+}
+
+sub EveryoneIncidentRights {
+    return ();
+}
+
+sub EveryoneBlockRights {
+    return (qw(ReplyToTicket));
+}
+
+sub EveryoneInvestigationRights {
+    return (qw(ReplyToTicket));
+}
 
 use Parse::BooleanLogic;
 my $ticket_sql_parser = Parse::BooleanLogic->new;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the rt-commit mailing list