[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.8.8-596-g24cd111

? sunnavy sunnavy at bestpractical.com
Thu Aug 26 03:11:48 EDT 2010


The branch, 3.9-trunk has been updated
       via  24cd111af20dd3b5daf1b15fb32c2fd49a39349c (commit)
       via  8bd2f12035a5340f4a0c3dd22d151a5797762184 (commit)
       via  d0d5780f33d21f2eae6a166cea38463b30523e2b (commit)
      from  e547f519b68b00b2ca0d4e42a23e9f51f1a9b274 (commit)

Summary of changes:
 etc/RT_Config.pm.in                      |   14 +++++++
 share/html/Elements/ShowMemberships      |    4 ++
 share/html/Ticket/Elements/ShowRequestor |    8 ++++-
 t/web/requestor_groups_edit_link.t       |   56 ++++++++++++++++++++++++++++++
 t/web/requestor_groups_limit.t           |   36 +++++++++++++++++++
 5 files changed, 117 insertions(+), 1 deletions(-)
 create mode 100644 t/web/requestor_groups_edit_link.t
 create mode 100644 t/web/requestor_groups_limit.t

- Log -----------------------------------------------------------------
commit d0d5780f33d21f2eae6a166cea38463b30523e2b
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Aug 26 13:29:08 2010 +0800

    add MoreAboutRequestorGroupsLimit support

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 2f0bd46..28bed83 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -892,6 +892,20 @@ not all the attributes are supported in this display because we're not building
 
 Set($MoreAboutRequestorExtraInfo, '');
 
+=item C<$MoreAboutRequestorGroupsLimit>
+
+By default, the 'More about requestor' box on Ticket/Display.html shows all
+the groups of the Requestor.
+Use this to limit the number of groups.
+
+e.g.
+
+Set($MoreAboutRequestorGroupsLimit, 10);
+
+=cut
+
+Set($MoreAboutRequestorGroupsLimit, undef);
+
 =item C<$AutocompleteOwners>
 
 If true, the owner dropdowns for ticket update/modify and the query builder are
diff --git a/share/html/Elements/ShowMemberships b/share/html/Elements/ShowMemberships
index 90868a5..47a09c5 100644
--- a/share/html/Elements/ShowMemberships
+++ b/share/html/Elements/ShowMemberships
@@ -46,6 +46,7 @@
 %# 
 %# END BPS TAGGED BLOCK }}}
 <ul>
+% my $i = 1;
 % while ( my $GroupMember = $GroupMembers->Next ) {
 %    my $Group = RT::Group->new($session{'CurrentUser'});
 %    $Group->Load($GroupMember->GroupId) or next;
@@ -54,6 +55,7 @@
 %    } elsif ($Group->Domain eq 'SystemInternal') {
 <li><em><% loc($Group->Type) %></em></li>
 %    }
+%    last if $Limit && ++$i > $Limit;
 % }
 </ul>
 <%INIT>
@@ -82,7 +84,9 @@ $GroupMembers->OrderByCols(
     { ALIAS => $alias, FIELD => 'Domain' },
     { ALIAS => $alias, FIELD => 'Name' },
 );
+
 </%INIT>
 <%ARGS>
 $UserObj
+$Limit => undef
 </%ARGS>
diff --git a/share/html/Ticket/Elements/ShowRequestor b/share/html/Ticket/Elements/ShowRequestor
index b3d4ba4..0145226 100755
--- a/share/html/Ticket/Elements/ShowRequestor
+++ b/share/html/Ticket/Elements/ShowRequestor
@@ -80,7 +80,7 @@ while ( my $requestor = $people->Next ) {
 % if ( $ShowGroups ) {
 <div class="more-about-user-groups">
   <span class="label"><&|/l&>Groups this user belongs to</&>:</span>
-  <span class="value"><& /Elements/ShowMemberships, UserObj => $requestor &></span>
+  <span class="value"><& /Elements/ShowMemberships, UserObj => $requestor, Limit => RT->Config->Get('MoreAboutRequestorGroupsLimit') &></span>
 </div>
 % }
 
diff --git a/t/web/requestor_groups_limit.t b/t/web/requestor_groups_limit.t
new file mode 100644
index 0000000..e49138f
--- /dev/null
+++ b/t/web/requestor_groups_limit.t
@@ -0,0 +1,37 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use Encode;
+
+use RT::Test tests => 11;
+
+diag "set groups limit to 1" if $ENV{TEST_VERBOSE};
+RT->Config->Set( ShowMoreAboutPrivilegedUsers    => 1 );
+RT->Config->Set( MoreAboutRequestorGroupsLimit => 1 );
+
+my $ticket = RT::Ticket->new($RT::SystemUser);
+my ($id) = $ticket->Create(
+    Subject   => 'groups limit',
+    Queue     => 'General',
+    Requestor => 'root at localhost',
+);
+ok( $id, 'created ticket' );
+
+my ( $url, $m ) = RT::Test->started_ok;
+ok( $m->login(), 'logged in as root' );
+$m->get_ok( $url . '/Ticket/Display.html?id=' . $id );
+$m->content_contains( 'Everyone', 'got the first group' );
+$m->content_lacks( 'Privileged', 'not the second group' );
+
+RT::Test->stop_server;
+
+diag "set groups limit to 2" if $ENV{TEST_VERBOSE};
+
+RT->Config->Set( MoreAboutRequestorGroupsLimit => 2 );
+( $url, $m ) = RT::Test->started_ok;
+ok( $m->login(), 'logged in as root' );
+$m->get_ok( $url . '/Ticket/Display.html?id=' . $id );
+$m->content_contains( 'Everyone', 'got the first group' );
+$m->content_contains( 'Privileged', 'got the second group' );
+

commit 8bd2f12035a5340f4a0c3dd22d151a5797762184
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Aug 26 13:31:24 2010 +0800

    tiny clean

diff --git a/t/web/requestor_groups_limit.t b/t/web/requestor_groups_limit.t
index e49138f..768af97 100644
--- a/t/web/requestor_groups_limit.t
+++ b/t/web/requestor_groups_limit.t
@@ -2,7 +2,6 @@
 
 use strict;
 use warnings;
-use Encode;
 
 use RT::Test tests => 11;
 

commit 24cd111af20dd3b5daf1b15fb32c2fd49a39349c
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Aug 26 14:06:08 2010 +0800

    add Edit groups link in MoreAboutRequestors if current user has ShowConfigTab and AdminUsers rights

diff --git a/share/html/Ticket/Elements/ShowRequestor b/share/html/Ticket/Elements/ShowRequestor
index 0145226..0f7a3ce 100755
--- a/share/html/Ticket/Elements/ShowRequestor
+++ b/share/html/Ticket/Elements/ShowRequestor
@@ -80,6 +80,12 @@ while ( my $requestor = $people->Next ) {
 % if ( $ShowGroups ) {
 <div class="more-about-user-groups">
   <span class="label"><&|/l&>Groups this user belongs to</&>:</span>
+  <span class="label">
+% if ( $session{CurrentUser}->HasRight( Right => 'AdminUsers', Object => $RT::System ) &&
+%      $session{CurrentUser}->HasRight( Right => 'ShowConfigTab', Object =>$RT::System ) ) {
+  [<a href=<% RT->Config->Get('WebPath') . '/Admin/Users/Memberships.html?id=' . $requestor->id %> ><&|/l&>Edit</&></a>]
+% }
+  </span>
   <span class="value"><& /Elements/ShowMemberships, UserObj => $requestor, Limit => RT->Config->Get('MoreAboutRequestorGroupsLimit') &></span>
 </div>
 % }
diff --git a/t/web/requestor_groups_edit_link.t b/t/web/requestor_groups_edit_link.t
new file mode 100644
index 0000000..af5aafb
--- /dev/null
+++ b/t/web/requestor_groups_edit_link.t
@@ -0,0 +1,56 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use RT::Test tests => 11;
+
+RT->Config->Set( ShowMoreAboutPrivilegedUsers    => 1 );
+
+my $user_a = RT::Test->load_or_create_user(
+    Name     => 'user_a',
+    Password => 'password',
+);
+ok( $user_a, 'created user user_a' );
+ok(
+    RT::Test->set_rights(
+        {
+            Principal => $user_a,
+            Right     => [ qw/SeeQueue ShowTicket CreateTicket/ ]
+        },
+    ),
+    'set rights for user_a'
+);
+
+my $ticket = RT::Ticket->new($RT::SystemUser);
+my ($id) = $ticket->Create(
+    Subject   => 'groups limit',
+    Queue     => 'General',
+    Requestor => $user_a->id,
+);
+ok( $id, 'created ticket' );
+
+
+my ( $url, $m ) = RT::Test->started_ok;
+ok( $m->login( user_a => 'password' ), 'logged in as user_a' );
+
+$m->get_ok( $url . '/Ticket/Display.html?id=' . $id );
+
+ok(
+    !$m->find_link( text => 'Edit' ), 'no Edit link without AdminUsers permission'
+);
+
+ok(
+    RT::Test->add_rights(
+        {
+            Principal => $user_a,
+            Right     => [ qw/AdminUsers ShowConfigTab/ ]
+        },
+    ),
+    'add AdminUsers and ShowConfigTab rights for user_a'
+);
+
+$m->get_ok( $url . '/Ticket/Display.html?id=' . $id );
+$m->follow_link_ok( { text => 'Edit' }, 'follow the Edit link' );
+is( $m->uri, $url . "/Admin/Users/Memberships.html?id=" . $user_a->id, 'url is right' );
+

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


More information about the Rt-commit mailing list