[Rt-commit] rt branch, 3.9-lifecycles_improvments_v2, updated. rt-3.9.5-480-g6b262a9

Ruslan Zakirov ruz at bestpractical.com
Tue Nov 30 21:32:29 EST 2010


The branch, 3.9-lifecycles_improvments_v2 has been updated
       via  6b262a9755c5c5a17f7358ee15b94b2b048030ad (commit)
       via  c8597f32059c3c4aa9dcd2856fcd2bf988813460 (commit)
       via  394ef1bcb172de2b74c3ce510b7b8429573f7dfb (commit)
       via  b6cbef024cff75252421cff946e907ad4d79fff1 (commit)
       via  895b24374b4d1b8324d8b07d057f368b119653fa (commit)
       via  5e8fedcd0584ccde716525d217b8b6a585dd0ed9 (commit)
       via  e033426a1d055be0cc4a87ce29c1b5632cd93114 (commit)
       via  4dd8fc51489ae81baa7813032ec36854dd18660c (commit)
       via  d6aeefc02c1741af65effe7c47d185a5d947f327 (commit)
      from  022930e7240c8116e49fb14962dbc59f78be3b07 (commit)

Summary of changes:
 etc/RT_Config.pm.in                     |   67 ++++++++++++++++++----------
 lib/RT/Lifecycle.pm                     |   53 +++++++++++++++-------
 lib/RT/Ticket_Overlay.pm                |   74 +++---------------------------
 share/html/Admin/Queues/Modify.html     |   11 ++++-
 share/html/Elements/RT__Queue/ColumnMap |    1 +
 share/html/Ticket/Create.html           |    2 +-
 share/html/m/ticket/create              |    2 +-
 t/lifecycles/utils.pl                   |   11 ++++-
 8 files changed, 110 insertions(+), 111 deletions(-)

- Log -----------------------------------------------------------------
commit d6aeefc02c1741af65effe7c47d185a5d947f327
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Nov 24 01:33:26 2010 +0300

    add lifecycle editor to queue's admin page

diff --git a/share/html/Admin/Queues/Modify.html b/share/html/Admin/Queues/Modify.html
index 9757827..6bef4ed 100755
--- a/share/html/Admin/Queues/Modify.html
+++ b/share/html/Admin/Queues/Modify.html
@@ -64,6 +64,15 @@
 <td colspan="3"><input name="Description" value="<% ($Create) ? "" : $QueueObj->Description %>" size="60" /></td>
 </tr>
 
+<tr><td align="right"><&|/l&>Lifecycle</&>:</td>
+<td colspan="3"><& /Widgets/Form/Select:InputOnly,
+    Name         => 'Lifecycle',
+    Values       => [ sort { loc($a) cmp loc($b) } RT::Lifecycle->List ],
+    CurrentValue => $Create ? "default" : $QueueObj->Lifecycle,
+    Default      => 0,
+&></td>
+</tr>
+
 <tr><td align="right"><&|/l&>Subject Tag</&>:</td>
 <td colspan="3"><input name="SubjectTag" value="<% $ARGS{'SubjectTag'} || ($Create ? "" : $QueueObj->SubjectTag || '' ) %>" size="60" /></td>
 </tr>
@@ -158,7 +167,7 @@ if ($Create) {
 }
 if ( $QueueObj->Id ) {
     my @attribs= qw(Description CorrespondAddress CommentAddress Name
-        InitialPriority FinalPriority DefaultDueIn Sign Encrypt SubjectTag Disabled);
+        InitialPriority FinalPriority DefaultDueIn Sign Encrypt Lifecycle SubjectTag Disabled);
 
     # we're asking about enabled on the web page but really care about disabled
     if ( $SetEnabled ) {

commit 4dd8fc51489ae81baa7813032ec36854dd18660c
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Nov 24 01:42:46 2010 +0300

    add lifecycle to queue's column map

diff --git a/share/html/Elements/RT__Queue/ColumnMap b/share/html/Elements/RT__Queue/ColumnMap
index de05c28..295271b 100644
--- a/share/html/Elements/RT__Queue/ColumnMap
+++ b/share/html/Elements/RT__Queue/ColumnMap
@@ -89,6 +89,7 @@ my $COLUMN_MAP = {
 foreach my $field (qw(
     Name Description CorrespondAddress CommentAddress
     InitialPriority FinalPriority DefaultDueIn
+    Lifecycle
 )) {
     $COLUMN_MAP->{$field} = {
         title => $field,

commit e033426a1d055be0cc4a87ce29c1b5632cd93114
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Dec 1 00:52:42 2010 +0300

    drop historical methods that related to status changes

diff --git a/lib/RT/Ticket_Overlay.pm b/lib/RT/Ticket_Overlay.pm
index 621e8c4..b91b52f 100755
--- a/lib/RT/Ticket_Overlay.pm
+++ b/lib/RT/Ticket_Overlay.pm
@@ -3156,68 +3156,13 @@ Takes no arguments. Marks this ticket for garbage collection
 
 sub Delete {
     my $self = shift;
+    unless ( $self->QueueObj->Lifecycle->IsValid('deleted') ) {
+        return (0, $self->loc('Delete operation is disabled by lifecycle configuration') ); #loc
+    }
     return ( $self->SetStatus('deleted') );
-
-    # TODO: garbage collection
-}
-
-
-
-=head2 Stall
-
-Sets this ticket's status to stalled
-
-=cut
-
-sub Stall {
-    my $self = shift;
-    return ( $self->SetStatus('stalled') );
-}
-
-
-
-=head2 Reject
-
-Sets this ticket's status to rejected
-
-=cut
-
-sub Reject {
-    my $self = shift;
-    return ( $self->SetStatus('rejected') );
-}
-
-
-
-=head2 Open
-
-Sets this ticket\'s status to Open
-
-=cut
-
-sub Open {
-    my $self = shift;
-    return ( $self->SetStatus('open') );
 }
 
 
-
-=head2 Resolve
-
-Sets this ticket\'s status to Resolved
-
-=cut
-
-sub Resolve {
-    my $self = shift;
-    return ( $self->SetStatus('resolved') );
-}
-
-
-
-    
-
-
 =head2 SetTold ISO  [TIMETAKEN]
 
 Updates the told and records a transaction

commit 5e8fedcd0584ccde716525d217b8b6a585dd0ed9
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Dec 1 00:56:09 2010 +0300

    move lifecycle's default values and give them more reasonable names

diff --git a/lib/RT/Lifecycle.pm b/lib/RT/Lifecycle.pm
index 2187c9d..f6be775 100644
--- a/lib/RT/Lifecycle.pm
+++ b/lib/RT/Lifecycle.pm
@@ -272,18 +272,6 @@ sub IsInitial {
 }
 
 
-=head3 DefaultInitial
-
-Returns the "default" initial status for this lifecycle
-
-=cut
-
-sub DefaultInitial {
-    my $self = shift;
-    return $self->{data}->{default_initial};
-}
-
-
 =head3 Active
 
 Returns an array of all active statuses for this lifecycle.
@@ -334,15 +322,48 @@ sub IsInactive {
     return 0;
 }
 
-=head3 DefaultInactive
 
-Returns the "default" inactive status for this lifecycle
+=head2 Default statuses
+
+In some cases when status is not provided a default values should
+be used.
+
+=head3 DefaultStatus
+
+Takes a situation name and returns value. Name should be
+spelled following spelling in the RT config file.
+
+=cut
+
+sub DefaultStatus {
+    my $self = shift;
+    my $situation = shift;
+    return $self->{data}{defaults}{ $situation };
+}
+
+=head3 DefaultOnCreate
+
+Returns the status that should be used by default
+when ticket is created.
+
+=cut
+
+sub DefaultOnCreate {
+    my $self = shift;
+    return $self->DefaultStatus('on_create');
+}
+
+
+=head3 DefaultOnMerge
+
+Returns the status that should be used when tickets
+are merged.
 
 =cut
 
-sub DefaultInactive {
+sub DefaultOnMerge {
     my $self = shift;
-    return $self->{data}->{default_inactive};
+    return $self->DefaultStatus('on_merge');
 }
 
 =head2 Transitions, rights, labels and actions.

commit 895b24374b4d1b8324d8b07d057f368b119653fa
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Dec 1 04:41:00 2010 +0300

    refactor lifecycle defaults in the RT config

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index cec8484..a569ad6 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -1791,30 +1791,19 @@ any number of statuses.
 For example:
 
     default => {
-        default_initial => 'new',
         initial  => ['new'],
         active   => ['open', 'stalled'],
         inactive => ['resolved', 'rejected', 'deleted'],
-        default_inactive => 'resolved',
         ...
     },
 
-Because of database constraints, status names can be from 1
-to 10 characters.  Statuses are localized using RT's standard
-internationalization and localization system.
+Status names can be from 1 to 64 ASCII characters.  Statuses are localized
+using RT's standard internationalization and localization system.
 
 =head3 Status sets
 
 =over 4
 
-=item default_initial
-
-As you'll read below, you can specify a set of statuses which
-RT will treat as valid "initial" statuses for tickets.
-
-If you (or your code) doesn't specify a status when creating a
-ticket, RT will use the L<"default_initial"> status.
-
 =item initial
 
 You can define multiple B<initial> statuses for tickets in a
@@ -1837,7 +1826,7 @@ While you're free to implement a workflow that ignores that description,
 typically once a ticket enters an inactive state, it will never again
 enter an active state.
 
-RT will automatically set the B<Resolved> state when a ticket's status is
+RT will automatically set the B<Resolved> date when a ticket's status is
 changed from an B<Initial> or B<Active> status to an B<Inactive> status.
 
 B<deleted> is still a special status and protected by the B<DeleteTicket>
@@ -1845,14 +1834,6 @@ right, unless you re-defined rights (read below). If you don't want to
 allow ticket deletion at any time simply don't include it in your
 lifecycle.
 
-=item default_inactive
-
-You can specify a set of statuses which RT will treat as valid "inactive"
-statuses for tickets.
-
-If you (or your code) doesn't specify a status when resolving a
-ticket, RT will use the L<"default_inactive"> status.
-
 =back
 
 Statuses in each set are ordered and listed in the UI in the defined
@@ -1861,6 +1842,39 @@ order.
 Changes between statuses are constrained by transition rules,
 as described below.
 
+=head2 Default values
+
+In some cases a default value is used to display in UI or in API when
+value is not provided. You can configure defaults using the following
+syntax:
+
+    default => {
+        ...
+        defaults => {
+            on_create => 'new',
+            on_resolve => 'resolved',
+            ...
+        },
+    },
+
+The following defaults are used.
+
+=over 4
+
+=item on_create
+
+If you (or your code) doesn't specify a status when creating a
+ticket, RT will use the this status. See also L</Statuses available
+during ticket creation>.
+
+=item on_merge
+
+When tickets are merged status of the ticket that merged
+is changed by force to this. It should be one of inactive
+statuses. 'resolved' or its equivalent is the best candidate.
+
+=back
+
 =head2 Transitions between statuses and UI actions
 
 A B<Transition> - is a change of status from A to B. You should define
@@ -1880,6 +1894,8 @@ all possible transitions in each lifecycle using the following format:
         ...
     },
 
+=head3 Statuses available during ticket creation
+
 By default users can create tickets with any status, except deleted. If
 you want to restrict statuses available during creation then describe
 transition from '' (empty string), like in the example above.
@@ -1986,11 +2002,14 @@ you can not move tickets between queues with these lifecycles.
 
 Set(%Lifecycles,
     default => {
-        default_initial => 'new',
         initial         => [ 'new' ],
         active          => [ 'open', 'stalled' ],
         inactive        => [ 'resolved', 'rejected', 'deleted' ],
-        default_inactive => 'resolved',
+
+        defaults => {
+            on_create => 'new',
+            on_merge => 'resolved',
+        },
 
         transitions => {
             ''       => [qw(new open resolved)],

commit b6cbef024cff75252421cff946e907ad4d79fff1
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Dec 1 04:42:59 2010 +0300

    use new lifecycle defaults API

diff --git a/lib/RT/Ticket_Overlay.pm b/lib/RT/Ticket_Overlay.pm
index b91b52f..b56e41d 100755
--- a/lib/RT/Ticket_Overlay.pm
+++ b/lib/RT/Ticket_Overlay.pm
@@ -301,7 +301,7 @@ sub Create {
 
     my $cycle = $QueueObj->Lifecycle;
     unless ( defined $args{'Status'} && length $args{'Status'} ) {
-        $args{'Status'} = $cycle->DefaultInitial;
+        $args{'Status'} = $cycle->DefaultOnCreate;
     }
 
     unless ( $cycle->IsValid( $args{'Status'} ) ) {
@@ -2653,10 +2653,10 @@ sub _MergeInto {
     }
 
 
-    my $default_inactive = $self->QueueObj->Lifecycle->DefaultInactive;
-    if ( $default_inactive ne $self->__Value('Status') ) {
+    my $force_status = $self->QueueObj->Lifecycle->DefaultOnMerge;
+    if ( $force_status && $force_status ne $self->__Value('Status') ) {
         my ( $status_val, $status_msg )
-            = $self->__Set( Field => 'Status', Value => $default_inactive );
+            = $self->__Set( Field => 'Status', Value => $force_status );
 
         unless ($status_val) {
             $RT::Handle->Rollback();

commit 394ef1bcb172de2b74c3ce510b7b8429573f7dfb
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Dec 1 04:43:36 2010 +0300

    don't log localized message

diff --git a/lib/RT/Ticket_Overlay.pm b/lib/RT/Ticket_Overlay.pm
index b56e41d..7d34757 100755
--- a/lib/RT/Ticket_Overlay.pm
+++ b/lib/RT/Ticket_Overlay.pm
@@ -2661,10 +2661,7 @@ sub _MergeInto {
         unless ($status_val) {
             $RT::Handle->Rollback();
             $RT::Logger->error(
-                $self->loc(
-                    "[_1] couldn't set status to resolved. RT's Database may be inconsistent.",
-                    $self
-                )
+                "Couldn't set status to $force_status. RT's Database may be inconsistent."
             );
             return ( 0, $self->loc("Merge failed. Couldn't set Status") );
         }

commit c8597f32059c3c4aa9dcd2856fcd2bf988813460
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Dec 1 04:44:13 2010 +0300

    use new lifecycle defaults API

diff --git a/share/html/Ticket/Create.html b/share/html/Ticket/Create.html
index 3162580..d9a1d3e 100755
--- a/share/html/Ticket/Create.html
+++ b/share/html/Ticket/Create.html
@@ -81,7 +81,7 @@
                 comp => '/Elements/SelectStatus',
                 args => {
                     Name            => "Status",
-                    Default         => $ARGS{Status} || $QueueObj->Lifecycle->DefaultInitial,
+                    Default         => $ARGS{Status} || $QueueObj->Lifecycle->DefaultOnCreate,
                     DefaultValue    => 0,
                     SkipDeleted     => 1,
                     QueueObj        => $QueueObj,
diff --git a/share/html/m/ticket/create b/share/html/m/ticket/create
index 4ce94ce..ffec253 100644
--- a/share/html/m/ticket/create
+++ b/share/html/m/ticket/create
@@ -290,7 +290,7 @@ $showrows->(
         "/Elements/SelectStatus",
         Name         => "Status",
         QueueObj     => $QueueObj,
-        Default      => $ARGS{Status} || $QueueObj->Lifecycle->DefaultInitial,
+        Default      => $ARGS{Status} || $QueueObj->Lifecycle->DefaultOnCreate,
         DefaultValue => 0,
         ),
 

commit 6b262a9755c5c5a17f7358ee15b94b2b048030ad
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Dec 1 05:31:50 2010 +0300

    adjust lifecycle tests

diff --git a/t/lifecycles/utils.pl b/t/lifecycles/utils.pl
index 0146566..6fb2293 100644
--- a/t/lifecycles/utils.pl
+++ b/t/lifecycles/utils.pl
@@ -9,10 +9,13 @@ BEGIN {
 $config = <<END;
 Set(\%Lifecycles,
     default => {
-        default_initial => 'new',
         initial  => [qw(new)],
         active   => [qw(open stalled)],
         inactive => [qw(resolved rejected deleted)],
+        defaults => {
+            on_create => 'new',
+            on_merge => 'resolved',
+        },
         transitions => {
             ''       => [qw(new open resolved)],
             new      => [qw(open resolved rejected deleted)],
@@ -39,11 +42,15 @@ Set(\%Lifecycles,
         },
     },
     delivery => {
-        default_initial => 'ordered',
         initial  => ['ordered'],
         active   => ['on way', 'delayed'],
         inactive => ['delivered'],
+        defaults => {
+            on_create => 'ordered',
+            on_merge => 'delivered',
+        },
         transitions => {
+            ''        => ['ordered'],
             ordered   => ['on way', 'delayed'],
             'on way'  => ['delivered'],
             delayed   => ['on way'],

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


More information about the Rt-commit mailing list