[Rt-commit] rt branch, 4.4/download-user-info, created. rt-4.4.2-246-g4dccc1f0d

Craig Kaiser craig at bestpractical.com
Mon Jun 18 11:45:41 EDT 2018


The branch, 4.4/download-user-info has been created
        at  4dccc1f0d42036788e60829cf5a4add6ae65cc77 (commit)

- Log -----------------------------------------------------------------
commit a7061699c564548803036233f8743dcb71a42d32
Author: Craig Kaiser <craig at bestpractical.com>
Date:   Thu Jun 14 15:51:40 2018 -0400

    Add column to transaction column map for content
    
    Column that returns the content of the transaction.

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 195b4b2a4634b8f311dbcc91b777c6d6a8c1f9bf
Author: Craig Kaiser <craig at bestpractical.com>
Date:   Thu Jun 14 15:52:38 2018 -0400

    Add 'UserDataSearchResultFormat' config option

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 6fe7bc7a2..05c928647 100644
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -1261,6 +1261,15 @@ Set(@ChartColors, qw(
     33cc33 cc3333 cc9933 6633cc
 ));
 
+=item C<$UserDataSearchResultFormat>
+
+This is the format of ticket search result for "Download My Tickets" links. It
+falls back to C<DefaultSearchResultFormat> if it's not set.
+
+=cut
+
+Set($UserDataSearchResultFormat, undef);
+
 =back
 
 

commit fc4af63af1593202660265999a21671d7fa55213
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 current
    user, as a TSV file.

diff --git a/share/html/Helpers/MyRelatedInfo.tsv b/share/html/Helpers/MyRelatedInfo.tsv
new file mode 100644
index 000000000..8bc8bb4e6
--- /dev/null
+++ b/share/html/Helpers/MyRelatedInfo.tsv
@@ -0,0 +1,80 @@
+%# 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>
+$Query            => ''
+$PreserveNewLines => 0
+$Type             => 'User'
+</%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;
+my $Format;
+
+if ( $Type eq 'User' ) {
+    $Format = "'__id__', '__Name__', '__EmailAddress__', '__RealName__', '__NickName__', '__Organization__', '__HomePhone__', '__WorkPhone__','__MobilePhone__', '__PagerPhone__', '__Address1__', '__Address2__', '__City__', '__State__','__Zip__', '__Country__', '__Gecos__', '__Lang__', '__FreeFormContactInfo__'";
+
+    $Collection = RT::Users->new($session{'CurrentUser'});
+    $Collection->Limit( FIELD => 'id', VALUE => $session{'CurrentUser'}->id );
+
+} elsif ( $Type eq 'Transaction' ) {
+    $Format = "'__ObjectId__', '__id__', '__Created__', '__Description__', '__OldValue__', '__NewValue__', '__Content__'";
+
+    $Collection = RT::Transactions->new($session{'CurrentUser'});
+    $Collection->Limit( FIELD => 'ObjectType', VALUE => 'RT::Ticket' );
+    $Collection->Limit( FIELD => 'Creator',    VALUE => $session{'CurrentUser'}->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 1720cfa3588d75e74810d283886500304f3e1411
Author: Craig Kaiser <craig at bestpractical.com>
Date:   Thu Jun 14 15:53:45 2018 -0400

    Create portlet for downloading user information

diff --git a/share/html/Elements/MyRelatedInfo b/share/html/Elements/MyRelatedInfo
new file mode 100644
index 000000000..1330f68df
--- /dev/null
+++ b/share/html/Elements/MyRelatedInfo
@@ -0,0 +1,62 @@
+%# 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/MyRelatedInfo.tsv?Type=User" class="button"><&|/l&>Download My User Info</&></a>
+    <a href="/Search/Results.tsv?Query=Requestor.id=<% $session{'CurrentUser'}->id %>&Format=<% $Format | un %>" class="button"><&|/l&>Download My Tickets</&></a>
+    <a href="/Helpers/MyRelatedInfo.tsv?Type=Transaction" class="button"><&|/l&>Download My Transaction Info</&></a>
+</div>
+</&>
+
+<%INIT>
+my $Format = RT->Config->Get('UserDataSearchResultFormat') || RT->Config->Get('DefaultSearchResultFormat');
+</%INIT>

commit 926302317ebea79146c2ad8068964d78cd51587e
Author: Craig Kaiser <craig at bestpractical.com>
Date:   Thu Jun 14 15:55:26 2018 -0400

    Add user 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..2cf73533a 100644
--- a/share/html/Admin/Users/Modify.html
+++ b/share/html/Admin/Users/Modify.html
@@ -232,6 +232,11 @@
 % }
 </form>
 
+%# Only show if current user is on their modify page
+% if ( !$Create && $session{'CurrentUser'}->id == $UserObj->id ) {
+<& /Elements/MyRelatedInfo &>
+% }
+
 <%INIT>
 
 my $UserObj = RT::User->new($session{'CurrentUser'});

commit 4dccc1f0d42036788e60829cf5a4add6ae65cc77
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..7703ad99a
--- /dev/null
+++ b/t/web/download_user_info.t
@@ -0,0 +1,71 @@
+
+use strict;
+use warnings;
+
+use RT::Test tests => undef;
+
+RT->Config->Set(UserDataSearchResultFormat => "'__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) {
+        push @dates, $tran->CreatedObj->AsString;
+    }
+    my ($date_created, $date_commented, $date_correspondence) = @dates;
+
+    # TSV file for user record information
+    $agent->get_ok( $url . "/Admin/Users/Modify.html?id=" . $root->id );
+    $agent->follow_link_ok({ text => 'Download My User Info' });
+
+    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 My Transaction Info' });
+
+    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 My 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