[Rt-commit] [rtir] 04/09: Made basic RTIR ticket creation interfaces aware of constituencies
Jesse Vincent
jesse at bestpractical.com
Mon Mar 16 02:41:34 EDT 2015
This is an automated email from the git hooks/post-receive script.
jesse pushed a commit to branch 3.4/remove_old_constituencies
in repository rtir.
commit cab91e85966094f61a157d130a9fc28ea57e89df
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Sun Mar 15 19:43:25 2015 -0700
Made basic RTIR ticket creation interfaces aware of constituencies
---
html/RTIR/Create.html | 16 +++++++++++---
html/RTIR/Incident/Create.html | 39 +++++++++++++++++++++++++++++----
html/RTIR/Investigation/Elements/Create | 21 ++++++++++++++++--
3 files changed, 67 insertions(+), 9 deletions(-)
diff --git a/html/RTIR/Create.html b/html/RTIR/Create.html
index cac8064..e04bd07 100644
--- a/html/RTIR/Create.html
+++ b/html/RTIR/Create.html
@@ -105,8 +105,8 @@
Default => $ARGS{'Queue'} || $QueueObj->Id,
ShowNullOption => 0,
Lifecycle => $QueueObj->Lifecycle,
- LimitToConstituency => $m->{'RTIR_ConstituencyFilter'} ? 1:0,
- Constituency => $m->{'RTIR_ConstituencyFilter'}
+ LimitToConstituency => 1,
+ Constituency => $constituency
}
},
{
@@ -331,6 +331,9 @@ if ($Lifecycle && ! $Queue) {
$ARGS{'Queue'} = $Queue;
}
+my $constituency = $m->{'RTIR_ConstituencyFilter'};
+
+
my %CFDefaults;
$m->callback(
CallbackName => 'Init', CallbackPage => '/Ticket/Create.html',
@@ -346,7 +349,7 @@ my $Type = RT::IR::TicketType( Lifecycle => $QueueObj->Lifecycle);
if ($QueueObj->Lifecycle eq RT::IR->lifecycle_countermeasure
&& RT->Config->Get('RTIR_DisableBlocksQueue') ) {
Abort(loc("Blocks queue is disabled via config file"));
- }
+}
# As of RTIR 3.8, that's only true for Incidents
@@ -384,6 +387,13 @@ foreach my $id ( grep $_, @Incident ) {
push @results, loc('Ticket #[_1] is not an Incident', $id );
}
else {
+ my $incident_constituency = RT::IR->ConstituencyFor($inc);
+ if ($constituency && $incident_constituency ne $constituency) {
+ push @results, loc("Incident constituency '[_1]' does not match current constituency '[_2]'", $incident_constituency, $constituency);
+ }
+ if(!$constituency) {
+ $constituency = RT::IR->ConstituencyFor($inc);
+ }
push @IncidentObj, $inc;
$error = 0;
}
diff --git a/html/RTIR/Incident/Create.html b/html/RTIR/Incident/Create.html
index 5b868e0..264169b 100644
--- a/html/RTIR/Incident/Create.html
+++ b/html/RTIR/Incident/Create.html
@@ -87,9 +87,13 @@ if ( $ChildObj && !$ChildObj->CurrentUserHasRight('ModifyTicket') ) {
<a name="incident"></a>
<div class="ticket-create-basics">
-<&| /Widgets/TitleBox, title => $Title, class => 'ticket-info-basics' &>
+<&| /Widgets/TitleBox, title => 'Basics', class => 'ticket-info-basics' &>
<table width="100%" border="0">
+% if ($constituency) {
+<tr class="constituency"><td class="label"><% loc('Constituency') %>:</td>
+ <td class="value"><% $constituency %></td></tr>
+% }
% if ( $Split ) {
<tr class="split-from"><td class="label"><% loc('Split from') %>:</td>
<td class="value"><a href="<%RT::IR->HREFTo('Incident/Display.html?id='.$SplitObj->id)%>"><% loc("[_1] #[_2]: [_3]", RT::IR::TicketType(Lifecycle => $SplitObj->QueueObj->Lifecycle), $SplitObj->Id, $SplitObj->Subject) %></a></td></tr>
@@ -108,8 +112,8 @@ if ( $ChildObj && !$ChildObj->CurrentUserHasRight('ModifyTicket') ) {
Name => 'Queue',
Default => $ARGS{'Queue'} || $QueueObj->Id,
Lifecycle => RT::IR->lifecycle_incident,
- LimitToConstituency => $m->{'RTIR_ConstituencyFilter'} ? 1:0,
- Constituency => $m->{'RTIR_ConstituencyFilter'}
+ LimitToConstituency => $constituency ? 1:0,
+ Constituency => $constituency
&>
</td>
</tr>
@@ -265,7 +269,8 @@ if ( $ChildObj && !$ChildObj->CurrentUserHasRight('ModifyTicket') ) {
<& /RTIR/Investigation/Elements/Create,
%ARGS,
NamePrefix => 'Investigation',
- Queue => 'Investigations',
+ Lifecycle => RT::IR->lifecycle_investigation,
+ Constituency => $constituency,
SkipField => { Owner => 1, Attachments => 1, DateFields => 1 },
IncludeSignature => (exists $ARGS{'InvestigationContent'} ? 0 : 1),
&>
@@ -308,6 +313,32 @@ $m->callback(
Child => $ChildObj
);
+
+
+my $constituency = $m->{'RTIR_ConstituencyFilter'};
+
+
+if($ChildObj) {
+ my $child_constituency = RT::IR->ConstituencyFor($ChildObj);
+ if ($constituency && $constituency ne $child_constituency) {
+ push @results, loc("[_1] constituency '[_2]' does not match current constituency '[_3]'", RT::IR::TicketType(Ticket=>$ChildObj), $child_constituency, $constituency);
+ } elsif(!$constituency) {
+ $constituency = $child_constituency;
+ }
+}
+
+
+if ($SplitObj) {
+ my $split_constituency = RT::IR->ConstituencyFor($SplitObj);
+ if ($constituency && $constituency ne $split_constituency) {
+ push @results, loc("[_1] constituency '[_2]' does not match current constituency '[_3]'", RT::IR::TicketType(Ticket=>$SplitObj), $split_constituency, $constituency);
+ } elsif(!$constituency) {
+ $constituency = $split_constituency;
+ }
+}
+
+
+
my $QueueObj = RT::Queue->new( $session{'CurrentUser'} );
$QueueObj->Load( 'Incidents' ) || Abort( loc("Queue could not be loaded.") );
diff --git a/html/RTIR/Investigation/Elements/Create b/html/RTIR/Investigation/Elements/Create
index f47ad41..dd17ad9 100644
--- a/html/RTIR/Investigation/Elements/Create
+++ b/html/RTIR/Investigation/Elements/Create
@@ -50,14 +50,22 @@
<div class="ticket-create-basics">
<&| /Widgets/TitleBox, title => loc("Basics"), class => 'ticket-info-basics' &>
<table width="100%" border="0">
-
-<tr>
+% if($Constituency) {
+%
+<tr class="constituency">
+ <td class="label"><%loc('Constituency') %>:</td>
+ <td><% $Constituency %></td>
+</tr>
+% }
+<tr class="queue">
<td class="label"><&|/l&>Queue</&>:</td>
<td>
<& /RTIR/Elements/SelectRTIRQueue,
Name => $NamePrefix.'Queue',
Default => $ARGS{'Queue'} || $QueueObj->Id,
Lifecycle => RT::IR->lifecycle_investigation,
+ LimitToConstituency => $Constituency ? 1 : 0,
+ Constituency => $Constituency
&>
</td>
</tr>
@@ -216,6 +224,7 @@ $QueueObj => undef
$TicketObj => undef
%HideField => ()
%SkipField => ()
+$Constituency => undef
</%ARGS>
<%INIT>
my %CFDefaults;
@@ -233,9 +242,17 @@ unless ( $QueueObj ) {
if ( my $queue = $value_cb->('Queue') ) {
$QueueObj = RT::Queue->new( $session{'CurrentUser'} );
$QueueObj->Load( $queue );
+ } else {
+ $QueueObj = RT::Queue->new( $session{'CurrentUser'} );
+ # XXX TODO DO NOT HARDCODE THIS. THIS IS WRONG
+ $QueueObj->Load('Investigations'.($Constituency? ' - '.$Constituency : ''));
+
}
}
+
+
+
my $ticket = RT::Ticket->new($session{'CurrentUser'}); # empty ticket object
if ( RT->Config->Get('GnuPG')->{'Enable'} ) {
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the rt-commit
mailing list