[Rt-commit] rt branch, 4.2/search-by-lifecycle, created. rt-4.2.9-153-g6dc7abc
Jesse Vincent
jesse at bestpractical.com
Fri Feb 6 00:51:17 EST 2015
The branch, 4.2/search-by-lifecycle has been created
at 6dc7abc9f20704c3e8c66a19db31dbbff17f99bb (commit)
- Log -----------------------------------------------------------------
commit 20907a1dd354ab7e47d31015b8a04b06474967df
Author: Wallace Reis <wreis at bestpractical.com>
Date: Mon Jan 26 20:56:19 2015 -0200
Lexically cache current user in ticket creation
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index efdd301..0603138 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -2066,9 +2066,10 @@ sub CreateTicket {
my (@Actions);
- my $Ticket = RT::Ticket->new( $session{'CurrentUser'} );
+ my $current_user = $session{'CurrentUser'};
+ my $Ticket = RT::Ticket->new( $current_user );
- my $Queue = RT::Queue->new( $session{'CurrentUser'} );
+ my $Queue = RT::Queue->new( $current_user );
unless ( $Queue->Load( $ARGS{'Queue'} ) ) {
Abort('Queue not found');
}
@@ -2079,12 +2080,12 @@ sub CreateTicket {
my $due;
if ( defined $ARGS{'Due'} and $ARGS{'Due'} =~ /\S/ ) {
- $due = RT::Date->new( $session{'CurrentUser'} );
+ $due = RT::Date->new( $current_user );
$due->Set( Format => 'unknown', Value => $ARGS{'Due'} );
}
my $starts;
if ( defined $ARGS{'Starts'} and $ARGS{'Starts'} =~ /\S/ ) {
- $starts = RT::Date->new( $session{'CurrentUser'} );
+ $starts = RT::Date->new( $current_user );
$starts->Set( Format => 'unknown', Value => $ARGS{'Starts'} );
}
@@ -2092,7 +2093,7 @@ sub CreateTicket {
Content => $ARGS{Content},
ContentType => $ARGS{ContentType},
StripSignature => 1,
- CurrentUser => $session{'CurrentUser'},
+ CurrentUser => $current_user,
);
my $MIMEObj = MakeMIMEEntity(
diff --git a/share/html/Ticket/Create.html b/share/html/Ticket/Create.html
index 1bfb58a..ca0fcab 100644
--- a/share/html/Ticket/Create.html
+++ b/share/html/Ticket/Create.html
@@ -300,6 +300,8 @@ $m->callback( CallbackName => "Init", ARGSRef => \%ARGS );
my $Queue = $ARGS{Queue};
$session{DefaultQueue} = $Queue;
+my $current_user = $session{'CurrentUser'};
+
if ($CloneTicket) {
my $CloneTicketObj = RT::Ticket->new( $session{CurrentUser} );
$CloneTicketObj->Load($CloneTicket)
@@ -375,7 +377,7 @@ my @results;
my $title = loc("Create a new ticket");
-my $QueueObj = RT::Queue->new($session{'CurrentUser'});
+my $QueueObj = RT::Queue->new($current_user);
$QueueObj->Load($Queue) || Abort(loc("Queue [_1] could not be loaded.", $Queue||''));
$m->callback( QueueObj => $QueueObj, title => \$title, results => \@results, ARGSRef => \%ARGS );
@@ -384,7 +386,7 @@ $m->scomp( '/Articles/Elements/SubjectOverride', ARGSRef => \%ARGS, QueueObj =>
$QueueObj->Disabled && Abort(loc("Cannot create tickets in a disabled queue."));
-my $ticket = RT::Ticket->new($session{'CurrentUser'}); # empty ticket object
+my $ticket = RT::Ticket->new($current_user); # empty ticket object
ProcessAttachments(ARGSRef => \%ARGS);
commit 4a71451e259a5d040d8508c087ff5756cbeaafff
Author: Wallace Reis <wreis at bestpractical.com>
Date: Mon Jan 26 20:56:33 2015 -0200
Consistency on ticket creation
RT mocks a MIME object using ticket metadata during creation through web
UI which doesn't bother to include the basic email headers -- except for
quick ticket creation form.
Fixes: I#30602
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 0603138..0777ee2 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -2096,10 +2096,15 @@ sub CreateTicket {
CurrentUser => $current_user,
);
+ my $date_now = RT::Date->new( $current_user );
+ $date_now->SetToNow;
my $MIMEObj = MakeMIMEEntity(
Subject => $ARGS{'Subject'},
- From => $ARGS{'From'},
+ From => $ARGS{'From'} || $current_user->EmailAddress,
+ To => $ARGS{'To'} || $Queue->CorrespondAddress
+ || RT->Config->Get('CorrespondAddress'),
Cc => $ARGS{'Cc'},
+ Date => $date_now->RFC2822(Timezone => 'user'),
Body => $sigless,
Type => $ARGS{'ContentType'},
Interface => RT::Interface::Web::MobileClient() ? 'Mobile' : 'Web',
@@ -2466,7 +2471,7 @@ sub MakeMIMEEntity {
"Message-Id" => Encode::encode( "UTF-8", RT::Interface::Email::GenMessageId ),
"X-RT-Interface" => $args{Interface},
map { $_ => Encode::encode( "UTF-8", $args{ $_} ) }
- grep defined $args{$_}, qw(Subject From Cc)
+ grep defined $args{$_}, qw(Subject From Cc To Date)
);
if ( defined $args{'Body'} && length $args{'Body'} ) {
diff --git a/share/html/index.html b/share/html/index.html
index 58274db..e70f4cc 100644
--- a/share/html/index.html
+++ b/share/html/index.html
@@ -111,7 +111,6 @@ if ( $ARGS{'QuickCreate'} ) {
Status => $ARGS{'Status'},
# yes! it's Requestors, not Requestor
Requestors => $ARGS{'Requestors'},
- From => $session{'CurrentUser'}->EmailAddress,
Content => $ARGS{'Content'},
Subject => $ARGS{'Subject'});
push @results, $msg;
commit 6dc7abc9f20704c3e8c66a19db31dbbff17f99bb
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Thu Feb 5 14:33:18 2015 -0800
Add the ability to search for tickets based on queue lifecycle
It's sometimes useful to be able to search for all tickets in a
specific lifecycle. This commit adds the 'Lifecycle' field to
TicketSQL, as well as associated tests.
Code by Alex Vandiver. Tests by Jesse Vincent.
diff --git a/lib/RT/Tickets.pm b/lib/RT/Tickets.pm
index 58900a2..c641cd2 100644
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@ -154,6 +154,7 @@ our %FIELD_METADATA = (
TxnCF => [ 'CUSTOMFIELD' => 'Transaction' ], #loc_left_pair
TransactionCF => [ 'CUSTOMFIELD' => 'Transaction' ], #loc_left_pair
QueueCF => [ 'CUSTOMFIELD' => 'Queue' ], #loc_left_pair
+ Lifecycle => [ 'LIFECYCLE' ], #loc_left_pair
Updated => [ 'TRANSDATE', ], #loc_left_pair
UpdatedBy => [ 'TRANSCREATOR', ], #loc_left_pair
OwnerGroup => [ 'MEMBERSHIPFIELD' => 'Owner', ], #loc_left_pair
@@ -191,6 +192,7 @@ our %dispatch = (
MEMBERSHIPFIELD => \&_WatcherMembershipLimit,
CUSTOMFIELD => \&_CustomFieldLimit,
HASATTRIBUTE => \&_HasAttributeLimit,
+ LIFECYCLE => \&_LifecycleLimit,
);
# Default EntryAggregator per type
@@ -1236,6 +1238,26 @@ sub _HasAttributeLimit {
}
+sub _LifecycleLimit {
+ my ( $self, $field, $op, $value, %rest ) = @_;
+
+ die "Invalid Operator $op for $field" if $op =~ /^(IS|IS NOT)$/io;
+ my $queue = $self->{_sql_aliases}{queues} ||= $_[0]->Join(
+ ALIAS1 => 'main',
+ FIELD1 => 'Queue',
+ TABLE2 => 'Queues',
+ FIELD2 => 'id',
+ );
+
+ $self->Limit(
+ ALIAS => $queue,
+ FIELD => 'Lifecycle',
+ OPERATOR => $op,
+ VALUE => $value,
+ %rest,
+ );
+}
+
# End Helper Functions
# End of SQL Stuff -------------------------------------------------
diff --git a/t/ticket/search.t b/t/ticket/search.t
index 852241f..f40b4e9 100644
--- a/t/ticket/search.t
+++ b/t/ticket/search.t
@@ -283,4 +283,35 @@ like($tix->BuildSelectCountQuery, qr/\bNULL\b/, "Contains upper-case NULL");
unlike($tix->BuildSelectCountQuery, qr/\bnull\b/, "Lacks lower-case NULL");
+# tests for searching by queue lifecycle
+$tix = RT::Tickets->new(RT->SystemUser);
+$tix->FromSQL('Lifecycle="default"');
+is($tix->Count,7,"We found all 7 tickets in a queue with the default lifecycle");
+
+$tix = RT::Tickets->new(RT->SystemUser);
+$tix->FromSQL('Lifecycle ="approvals" OR Lifecycle="default"');
+is($tix->Count,7,"We found 7 tickets in a queue with a lifecycle of default or approvals");
+
+$tix = RT::Tickets->new(RT->SystemUser);
+$tix->FromSQL('Lifecycle ="approvals" AND Lifecycle="default"');
+is($tix->Count,0,"We found 0 tickets in a queue with a lifecycle of default AND approvals...(because that's impossible");
+
+$tix = RT::Tickets->new(RT->SystemUser);
+$tix->FromSQL('Queue="'.$queue.'" AND Lifecycle="default"');
+is($tix->Count,7,"We found 7 tickets in $queue with a lifecycle of default");
+
+
+$tix = RT::Tickets->new(RT->SystemUser);
+$tix->FromSQL('Lifecycle !="approvals"');
+is($tix->Count,7,"We found 7 tickets in a queue with a lifecycle other than approvals");
+
+$tix = RT::Tickets->new(RT->SystemUser);
+$tix->FromSQL('Lifecycle!="default"');
+is($tix->Count,0,"We found 0 tickets in a queue with a lifecycle other than default");
+
+$tix = RT::Tickets->new(RT->SystemUser);
+$tix->FromSQL('Lifecycle="approvals"');
+is($tix->Count,0,"We found 0 tickets in a queue with the approvals lifecycle");
+
+
done_testing;
-----------------------------------------------------------------------
More information about the rt-commit
mailing list