[Rt-commit] rt branch, 4.4/download-user-info, created. rt-4.4.2-247-g8a515f13c
Maureen Mirville
maureen at bestpractical.com
Tue Oct 23 13:58:35 EDT 2018
The branch, 4.4/download-user-info has been created
at 8a515f13cd21536681879117422134fbf998da76 (commit)
- Log -----------------------------------------------------------------
commit 7e03a7e7699f6509812690fbd34ab2bc030a07be
Author: Craig Kaiser <craig at bestpractical.com>
Date: Thu Jun 14 15:51:40 2018 -0400
Add column to transaction column map for content
diff --git a/share/html/Elements/RT__Transaction/ColumnMap b/share/html/Elements/RT__Transaction/ColumnMap
index 28a82f1e0..d709a5440 100644
--- a/share/html/Elements/RT__Transaction/ColumnMap
+++ b/share/html/Elements/RT__Transaction/ColumnMap
@@ -105,6 +105,11 @@ my $COLUMN_MAP = {
}
},
},
+ Content => {
+ title => 'Content', # loc
+ Attribute => 'Content', # loc
+ value => sub { return $_[0]->Content },
+ },
};
commit 272ff90f6b419f6e26b7e17a1e1e2140c7535c22
Author: Craig Kaiser <craig at bestpractical.com>
Date: Thu Jun 14 15:52:38 2018 -0400
Add config options for download user data result formats
Need three new config options that allow admins to specify the search
result formats for the user data downloads.
$UserTicketDataResultFormat
$UserDataResultFormat
$UserTransactionDataResultFormat
diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 6fe7bc7a2..0ce80303a 100644
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -1382,6 +1382,38 @@ Set ($DefaultSearchResultFormat, qq{
'<small>__LastUpdatedRelative__</small>',
'<small>__TimeLeft__</small>'});
+
+=item C<$UserTicketDataResultFormat>
+
+This is the format of ticket search result for "Download User Tickets" links. It
+defaults to C<DefaultSearchResultFormat> if it's not set.
+
+=cut
+
+Set($UserTicketDataResultFormat, $DefaultSearchResultFormat);
+
+=item C<$UserDataResultFormat>
+
+This is the format of the user search result for "Download User Data" links.
+
+=cut
+
+Set($UserDataResultFormat, "'__id__', '__Name__', '__EmailAddress__', '__RealName__',\
+ '__NickName__', '__Organization__', '__HomePhone__', '__WorkPhone__',\
+ '__MobilePhone__', '__PagerPhone__', '__Address1__', '__Address2__',\
+ '__City__', '__State__','__Zip__', '__Country__', '__Gecos__', '__Lang__',\
+ '__FreeFormContactInfo__'");
+
+=item C<$UserTransactionDataResultFormat>
+
+This is the format of the user transaction search result for "Download User Transaction Data" links.
+
+=cut
+
+Set($UserTransactionDataResultFormat, "'__ObjectId__', '__id__', '__Created__', '__Description__',\
+ '__OldValue__', '__NewValue__', '__Content__'");
+
+
=item C<$DefaultSearchResultOrderBy>
What Tickets column should we order by for RT Ticket search results.
commit e635cae75211f59f6f545a0b81c4815db4865e6a
Author: Craig Kaiser <craig at bestpractical.com>
Date: Thu Jun 14 15:53:14 2018 -0400
Create helper for exporting user related information
Export transaction and user record information pertaining to the
provided user id, as a TSV file.
diff --git a/share/html/Helpers/UserRelatedData.tsv b/share/html/Helpers/UserRelatedData.tsv
new file mode 100644
index 000000000..f8d247dd4
--- /dev/null
+++ b/share/html/Helpers/UserRelatedData.tsv
@@ -0,0 +1,86 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC
+%# <sales at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+<%ARGS>
+$PreserveNewLines => 0
+$Type => 'User'
+$Format => undef
+$id
+</%ARGS>
+
+<%INIT>
+# Abort unless supported type for export found
+Abort('Incorrect value passed for Type') unless
+ $Type && ( $Type eq 'User' || $Type eq 'Transaction');
+
+my $Collection;
+
+if ( $Type eq 'User' ) {
+ $Format = RT->Config->Get('UserDataResultFormat') unless $Format;
+
+
+ if ( $session{'CurrentUser'}->id ne $id ) {
+ Abort('User does not have the right to view other users') unless
+ $session{'CurrentUser'}->UserObj->HasRight( Object => $RT::System, Right =>'AdminUsers');
+ }
+
+ $Collection = RT::Users->new( $session{'CurrentUser'} );
+ $Collection->Limit( FIELD => 'id', VALUE => $id );
+
+} elsif ( $Type eq 'Transaction' ) {
+ $Format = RT->Config->Get('UserTransactionDataResultFormat') unless $Format;
+
+ $Collection = RT::Transactions->new( $session{'CurrentUser'} );
+ $Collection->Limit( FIELD => 'ObjectType', VALUE => 'RT::Ticket' );
+ $Collection->Limit( FIELD => 'Creator', VALUE => $id );
+ $Collection->Limit( FIELD => 'Type', VALUE => 'Create' );
+ $Collection->Limit( FIELD => 'Type', VALUE => 'Correspond' );
+ $Collection->Limit( FIELD => 'Type', VALUE => 'Comment' );
+}
+
+$m->comp( "/Elements/TSVExport", Collection => $Collection, Format => $Format, PreserveNewLines => $PreserveNewLines );
+</%INIT>
commit 0d5f5c2e97aaf4d7242e00fea038931c9ba633fc
Author: Craig Kaiser <craig at bestpractical.com>
Date: Thu Jun 14 15:53:45 2018 -0400
Create portlet for downloading user information
Provide three links for downloading user information as a tsv file:
User record data
User transaction data
User ticket data
diff --git a/share/html/Elements/UserRelatedData b/share/html/Elements/UserRelatedData
new file mode 100644
index 000000000..0be3e110d
--- /dev/null
+++ b/share/html/Elements/UserRelatedData
@@ -0,0 +1,66 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC
+%# <sales at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+<&|/Widgets/TitleBox,
+ class => 'user-related-info',
+ title => loc("User related info"),
+&>
+
+<div>
+ <a href="/Helpers/UserRelatedData.tsv?Type=User&id=<% $UserObj->id %>" class="button"><&|/l&>Download User Data</&></a>
+ <a href="/Search/Results.tsv?Query=Requestor.id=<% $UserObj->id %>&Format=<% $Format | un %>" class="button"><&|/l&>Download User Tickets</&></a>
+ <a href="/Helpers/UserRelatedData.tsv?Type=Transaction&id=<% $UserObj->id %>" class="button"><&|/l&>Download User Transaction Data</&></a>
+</div>
+</&>
+
+<%INIT>
+my $Format = RT->Config->Get('UserTicketDataResultFormat');
+</%INIT>
+
+<%ARGS>
+$UserObj
+</%ARGS>
commit 37a04fee5a9175e769ceb93532f7a46e79b6dcbc
Author: Craig Kaiser <craig at bestpractical.com>
Date: Thu Jun 14 15:55:26 2018 -0400
Add user data download portlet to admin user modify page
diff --git a/share/html/Admin/Users/Modify.html b/share/html/Admin/Users/Modify.html
index 3b8bc42fc..7aed16c62 100644
--- a/share/html/Admin/Users/Modify.html
+++ b/share/html/Admin/Users/Modify.html
@@ -232,6 +232,7 @@
% }
</form>
+<& /Elements/UserRelatedData, UserObj => $UserObj &>
<%INIT>
my $UserObj = RT::User->new($session{'CurrentUser'});
commit be13f3385500d8f8ea400a78ad1f64948ca8ba20
Author: Craig Kaiser <craig at bestpractical.com>
Date: Thu Jun 21 16:58:16 2018 -0400
Add download user data portlet to AboutMe.html page
diff --git a/share/html/Prefs/AboutMe.html b/share/html/Prefs/AboutMe.html
index 7eaf36755..1e6c2949d 100644
--- a/share/html/Prefs/AboutMe.html
+++ b/share/html/Prefs/AboutMe.html
@@ -201,6 +201,7 @@
</form>
+<& /Elements/UserRelatedData, UserObj => $UserObj &>
<%INIT>
commit 8a515f13cd21536681879117422134fbf998da76
Author: Craig Kaiser <craig at bestpractical.com>
Date: Thu Jun 14 15:56:19 2018 -0400
Create test for user information TSV download
Create tests to test the user personal identifying information download
features.
diff --git a/t/web/download_user_info.t b/t/web/download_user_info.t
new file mode 100644
index 000000000..cc100d686
--- /dev/null
+++ b/t/web/download_user_info.t
@@ -0,0 +1,85 @@
+
+use strict;
+use warnings;
+
+use RT::Test tests => undef;
+
+RT->Config->Set( UserTicketDataResultFormat =>
+ "'__id__', '__Subject__', '__Status__', '__QueueName__', '__Owner__', '__Priority__', '__Requestors__'"
+);
+
+my ( $baseurl, $agent ) = RT::Test->started_ok;
+my $url = $agent->rt_base_url;
+
+# Login
+$agent->login( 'root' => 'password' );
+
+{
+ my $root = RT::Test->load_or_create_user( Name => 'root' );
+ ok $root && $root->id;
+
+# We want transactions attached to our user, so not using test method for ticket create
+ my $ticket = RT::Ticket->new($root);
+ $ticket->Create(
+ Subject => 'Test',
+ Requestor => 'root',
+ Queue => 'General'
+ );
+ my $id = $ticket->id;
+ ok $id;
+
+ $ticket->Comment( Content => 'Test - Comment' );
+ $ticket->Correspond( Content => 'Test - Reply' );
+
+ my @dates;
+ my $trans = $ticket->Transactions;
+
+ while ( my $tran = $trans->Next ) {
+ if ( $tran->Type =~ /Create|Comment|Correspond/ ) {
+ push @dates, $tran->CreatedObj->AsString;
+ }
+ }
+ my ( $date_created, $date_commented, $date_correspondence ) = @dates;
+
+ # Make sure we have the expected amount of transactions
+ is scalar @dates, 3;
+
+ # TSV file for user record information
+ $agent->get_ok( $url . "Admin/Users/Modify.html?id=" . $root->id );
+ $agent->follow_link_ok( { text => 'Download User Data' } );
+
+ my $user_info_tsv = <<EOF;
+id\tName\tEmailAddress\tRealName\tNickName\tOrganization\tHomePhone\tWorkPhone\tMobilePhone\tPagerPhone\tAddress1\tAddress2\tCity\tState\tZip\tCountry\tGecos\tLang\tFreeFormContactInfo
+14\troot\troot\@localhost\tEnoch Root\t\t\t\t\t\t\t\t\t\t\t\t\troot\t\t
+EOF
+
+ is $agent->content, $user_info_tsv,
+ "User record information downloaded correctly";
+
+ # TSV file for Transactions
+ $agent->get_ok( $url . "Admin/Users/Modify.html?id=" . $root->id );
+ $agent->follow_link_ok( { text => 'Download User Transaction Data' } );
+
+ my $transaction_info_tsv = <<EOF;
+ObjectId\tid\tCreated\tDescription\tOldValue\tNewValue\tContent
+1\t30\t$date_created\tTicket created\t\t\tThis transaction appears to have no content
+1\t32\t$date_commented\tComments added\t\t\tTest - Comment
+1\t33\t$date_correspondence\tCorrespondence added\t\t\tTest - Reply
+EOF
+
+ is $agent->content, $transaction_info_tsv,
+ "User transaction information downloaded correctly";
+
+ # TSV file for user's Tickets
+ $agent->get_ok( $url . "Admin/Users/Modify.html?id=" . $root->id );
+ $agent->follow_link_ok( { text => 'Download User Tickets' } );
+
+ my $ticket_info_tsv = <<EOF;
+id\tSubject\tStatus\tQueueName\tOwner\tPriority\tRequestors
+1\tTest\topen\tGeneral\tNobody in particular\t0\troot (Enoch Root)
+EOF
+
+ is $agent->content, $ticket_info_tsv, "User tickets downloaded correctly";
+}
+
+done_testing();
-----------------------------------------------------------------------
More information about the rt-commit
mailing list