[Rt-commit] rt branch, 4.4/custom-roles, repushed

Shawn Moore shawn at bestpractical.com
Fri Oct 30 17:18:43 EDT 2015


The branch 4.4/custom-roles was deleted and repushed:
       was c00c3a570c33ad7ba369356d735b9c0f5e5f4f63
       now d4a2fc6ad7e8d051771a58ef182f5de0ef063020

 1:  3da168a =  1:  3da168a Tidy EmailInput and avoid including unescaped parameters
 2:  f4a3966 =  2:  f4a3966 Placeholder and EntryHint for EmailInput
 3:  5b777ea =  3:  5b777ea Support autocomplete-return for EmailInput
 4:  1168416 =  4:  1168416 Support for (by default, off) autocomplete of Nobody and System
 5:  87d20c2 =  5:  87d20c2 Only include one copy of "check box to delete" for queue watchers
 6:  7c59fae =  6:  7c59fae Simplify IsManageableRoleGroupType
 7:  78cbe3d =  7:  78cbe3d Switch several hardcoded lists to use ->Roles
 8:  8b8897b =  8:  8b8897b Avoid empty results and undef warnings in bulk update
 9:  89d776e =  9:  89d776e Tidy AddWatchers
10:  accaf5b = 10:  accaf5b Use the record we have for inspecting roles, rather than class RT::Queue
11:  3d5ba26 = 11:  3d5ba26 Add a CheckRight param to ->RoleGroup
12:  f467d55 = 12:  f467d55 Fix one-off "Administrative Cc" with "AdminCc"
13:  7cb01e5 = 13:  7cb01e5 Provide queue to EditBasics for new tickets (they don't have a ->QueueObj)
14:  71fc832 = 14:  71fc832 Provide defaults to EditBasics for "Add More Attach" etc
15:  4b1fd93 = 15:  4b1fd93 Factor out a CanonicalizePrincipal from AddRoleMember
16:  c7759ba = 16:  c7759ba Consistent error message across AddRoleMember and DeleteRoleMember
17:  ff898d8 = 17:  ff898d8 Factor out a _CreateRoleGroup
18:  6f0d646 = 18:  6f0d646 Lazily create ticket role groups if needed
19:  b2d8700 = 19:  b2d8700 Use queue to resolve roles on create since the ticket isn't created yet
20:  fe79a2f ! 20:  824c602 Process watcher updates from ticket Modify
    @@ -1,6 +1,8 @@
     Author: Shawn M Moore <shawn at bestpractical.com>
     
         Process watcher updates from ticket Modify
    +    
    +        Custom roles add single-member roles to this page
     
     diff --git a/share/html/Ticket/Modify.html b/share/html/Ticket/Modify.html
     --- a/share/html/Ticket/Modify.html
21:  e5dda97 = 21:  b45d415 Improve messaging around updating queue/ticket watchers
22:  5539d9a = 22:  466dc72 Additional option for roles
23:  34bfce3 = 23:  874f61b Tidy watcher searching in RT::Tickets
24:  f0acbba = 24:  5dee542 Improve comments around GetPrincipalsMap
25:  cdf1d2e = 25:  31e49aa Add Ticket->RoleAddresses($Name)
26:  524f3d8 = 26:  7978fd5 Add a Group->Label hook for when we display a group's name in the UI
27:  baa947b = 27:  706b418 Switch to ->LabelForRole
28:  35cf1ab ! 28:  3a37699 Add custom roles for queues
    @@ -1874,7 +1874,7 @@
     +
     +=head2 LimitToCustomRole
     +
    -+Takes id of a L<RT::CustomRole> object and limits this collection.
    ++Takes the id of an L<RT::CustomRole> object and limits this collection.
     +
     +=cut
     +
    @@ -1882,6 +1882,25 @@
     +    my $self = shift;
     +    my $id = shift;
     +    $self->Limit( FIELD => 'CustomRole', VALUE => $id );
    ++}
    ++
    ++=head2 LimitToObjectId
    ++
    ++Takes an ObjectId and limits the collection to object custom roles for said object.
    ++
    ++When called multiple times the ObjectId limits are joined with OR.
    ++
    ++=cut
    ++
    ++sub LimitToObjectId {
    ++    my $self = shift;
    ++    my $id = shift;
    ++    $self->Limit(
    ++        FIELD           => 'ObjectId',
    ++        OPERATOR        => '=',
    ++        VALUE           => $id,
    ++        ENTRYAGGREGATOR => 'OR'
    ++    );
     +}
     +
     +RT::Base->_ImportOverlays();
    @@ -1968,61 +1987,46 @@
     --- a/lib/RT/Transaction.pm
     +++ b/lib/RT/Transaction.pm
     @@
    +     ];
    + }
    + 
    ++sub _CanonicalizeRoleName {
    ++    my $self = shift;
    ++    my $role_name = shift;
    ++
    ++    if ($role_name =~ /^RT::CustomRole-(\d+)$/) {
    ++        my $role = RT::CustomRole->new($self->CurrentUser);
    ++        $role->Load($1);
    ++        return $role->Name;
    ++    }
    ++
    ++    return $self->loc($role_name);
    ++}
    ++
    ++
    + %_BriefDescriptions = (
    +     Create => sub {
    +         my $self = shift;
    +@@
              my $self = shift;
              my $principal = RT::Principal->new($self->CurrentUser);
              $principal->Load($self->NewValue);
     -        return ( "[_1] [_2] added", $self->loc($self->Field), $self->_FormatPrincipal($principal));    #loc()
    -+
    -+        my $role_name;
    -+
    -+        if ($self->Field =~ /^RT::CustomRole-(\d+)$/) {
    -+            my $role = RT::CustomRole->new($self->CurrentUser);
    -+            $role->Load($1);
    -+            $role_name = $role->Name;
    -+        }
    -+        else {
    -+            $role_name = $self->loc($self->Field);
    -+        }
    -+
    -+        return ( "[_1] [_2] added", $role_name, $self->_FormatPrincipal($principal));    #loc()
    ++        return ( "[_1] [_2] added", $self->_CanonicalizeRoleName($self->Field), $self->_FormatPrincipal($principal));    #loc()
          },
          DelWatcher => sub {
              my $self = shift;
              my $principal = RT::Principal->new($self->CurrentUser);
              $principal->Load($self->OldValue);
     -        return ( "[_1] [_2] deleted", $self->loc($self->Field), $self->_FormatPrincipal($principal));  #loc()
    -+
    -+        my $role_name;
    -+
    -+        if ($self->Field =~ /^RT::CustomRole-(\d+)$/) {
    -+            my $role = RT::CustomRole->new($self->CurrentUser);
    -+            $role->Load($1);
    -+            $role_name = $role->Name;
    -+        }
    -+        else {
    -+            $role_name = $self->loc($self->Field);
    -+        }
    -+
    -+        return ( "[_1] [_2] deleted", $role_name, $self->_FormatPrincipal($principal));  #loc()
    ++        return ( "[_1] [_2] deleted", $self->_CanonicalizeRoleName($self->Field), $self->_FormatPrincipal($principal));  #loc()
          },
          SetWatcher => sub {
              my $self = shift;
              my $principal = RT::Principal->new($self->CurrentUser);
              $principal->Load($self->NewValue);
     -        return ( "[_1] set to [_2]", $self->loc($self->Field), $self->_FormatPrincipal($principal));  #loc()
    -+
    -+        my $role_name;
    -+
    -+        if ($self->Field =~ /^RT::CustomRole-(\d+)$/) {
    -+            my $role = RT::CustomRole->new($self->CurrentUser);
    -+            $role->Load($1);
    -+            $role_name = $role->Name;
    -+        }
    -+        else {
    -+            $role_name = $self->loc($self->Field);
    -+        }
    -+
    -+        return ( "[_1] set to [_2]", $role_name, $self->_FormatPrincipal($principal));  #loc()
    ++        return ( "[_1] set to [_2]", $self->_CanonicalizeRoleName($self->Field), $self->_FormatPrincipal($principal));  #loc()
          },
          Subject => sub {
              my $self = shift;
    @@ -3363,22 +3367,22 @@
     +        MaxValues => 1,
     +    );
     +    ok($ok, "created Engineer role: $msg");
    -+    
    ++
     +    ($ok, $msg) = $sales->Create(
     +        Name      => 'Sales-' . $$,
     +        MaxValues => 0,
     +    );
     +    ok($ok, "created Sales role: $msg");
    -+    
    ++
     +    ($ok, $msg) = $unapplied->Create(
     +        Name      => 'Unapplied-' . $$,
     +        MaxValues => 0,
     +    );
     +    ok($ok, "created Unapplied role: $msg");
    -+    
    ++
     +    ($ok, $msg) = $sales->AddToObject($specs->id);
     +    ok($ok, "added Sales to Specs: $msg");
    -+    
    ++
     +    ($ok, $msg) = $engineer->AddToObject($specs->id);
     +    ok($ok, "added Engineer to Specs: $msg");
     +}
29:  4d23e1c = 29:  ffb246c @CustomRoles in initialdata, support CustomRole in @ACL
30:  131cf55 ! 30:  b77e1d2 Add custom roles to search builder
    @@ -51,7 +51,7 @@
     +        }
     +    }
     +    else {
    -+        $role = RT::CustomField->new( $self->CurrentUser );
    ++        $role = RT::CustomRole->new( $self->CurrentUser );
     +        $role->Load( $field );
     +    }
     +
31:  c00c3a5 ! 31:  5185344 Ensure custom role name uniqueness in rt-validator
    @@ -28,3 +28,4 @@
      push @CHECKS, 'GMs -> Groups, Members' => sub {
          my $msg = "A record in GroupMembers references an object that doesn't exist."
              ." Maybe you deleted a group or principal directly from the database?"
    +
--:  ------- > 32:  62157a3 Add support for custom roles in Action::Notify
--:  ------- > 33:  d4a2fc6 Shred object custom roles on queue shred



More information about the rt-commit mailing list