[Rt-commit] rt branch, 3.999-trunk, updated. 2ecfca5748cc60a0614ae31adf3d6ce09c64a915
sartak at bestpractical.com
sartak at bestpractical.com
Tue Jan 19 20:55:23 EST 2010
The branch, 3.999-trunk has been updated
via 2ecfca5748cc60a0614ae31adf3d6ce09c64a915 (commit)
via 7931127e015708c5a9ac70334213491997bd85c9 (commit)
via f184dfa1fbe788dcdf292b1d8f9ed2883b818b03 (commit)
via b1b73c07636c4089ab7e5d32880552824dff160f (commit)
via d77ae5221dd27e0372f861a8a4713a0f74f4ebdd (commit)
via 28b85df66423f8855ef9a0ab1d3cabb9dec214f8 (commit)
via 5c016dfbd506dd72242060721f20963abee06d36 (commit)
via a8d9cfc308826e6df1b64ad1fe5bcee4c8a521b0 (commit)
via a306ca417697c32d2bb2dbc607546fd31d6b4d29 (commit)
via 8521fa6d8273223a0a8fa9cf260435ec529f1048 (commit)
via 0c38c6c17e0c8f95e657d5a3d1d0f7f903cf2c7f (commit)
via cfeb122562fa3b37e79166234da1d0f748474105 (commit)
via f3143779f2e75fbbbb8876695bc8f6aa6c3b8373 (commit)
via 5a249f3f33371289b90275dbae8e1d3897cad95f (commit)
via 3c8f5a52b7b7dc05c209b0f8f41ea2e48a5a2846 (commit)
via 187daaaf258962089d9b5959a4300f93a1ec5ef9 (commit)
via 3944bb7344f659d7c8c0d1a8bee6210f2c591f81 (commit)
via 53b9f8e2293b7d40a1113088acca33e95ecf9079 (commit)
via 0ce1ce7a57d05ab6e4ae64e636b09670ebb890a1 (commit)
via 5ac3fc2698b1c7410a22a419bf0d4d31f388c03a (commit)
via 31b6be2f835143a2dfd9880a7866fde3276a2689 (commit)
via 200af953241207b1bbe68988dbdae98c22215a56 (commit)
via 7d9e04938c068f47b667a498d6062caaabd421e5 (commit)
via 1bc971ac9a846a35b83a312475bfd7013fda1ee8 (commit)
via 37e8dba49a360aedef034f97019046f736118bd9 (commit)
via 34b79c37a3d1c439d75299e03294030eef8cce4d (commit)
via 8138576516900396175dc008cf304dd1630dcd82 (commit)
via a25fe95bad61c34d7ee5f3e9881f86d159ec5d90 (commit)
via 057d86985507db15c0525f5f6fb262d2170ec94e (commit)
via 7dc46684a51f5866bdb678168f5d4a201b12d061 (commit)
via d6dc15ec7e336fb7e8812a2e68fb2b7094410e6c (commit)
via 70aebdae13b621d435f6603cda20b632fa753ce5 (commit)
via 12dd1fb5598bd4ff4eaefc4eb658ef8f5da777f4 (commit)
via 9002518242f7187a18d587352ddf4358f252cf0d (commit)
via 765e0142b57db5c945013b5a01f6ab30f793394c (commit)
via 7109bd2ddef4e8db05e50017b5ebf35a9c3a85aa (commit)
via d06d867ceaa64ef735acdc08207e2468aa420c09 (commit)
via a641a3bf471ae3f178ba2acb7cdd3562d6831266 (commit)
via 46f45b495963d38a4c0510c260fc0a29eb408657 (commit)
via 368de96ba6854c2cb56ed15355f91c3fa5ce7f36 (commit)
from 8b69e3b582a7a2511dd3c90168481d299fc2d8c6 (commit)
Summary of changes:
Makefile.PL | 1 +
lib/RT/Action/CreateTicket.pm | 157 +-------------------
lib/RT/Action/QueueBased.pm | 12 ++
lib/RT/Action/TicketAction.pm | 216 +++++++++++++++++++++++++++
lib/RT/Action/UpdateTicket.pm | 125 +++++-----------
lib/RT/Dispatcher.pm | 12 ++
lib/RT/View/Ticket.pm | 3 +
lib/RT/View/{Ticket.pm => Ticket/Update.pm} | 23 ++-
share/html/Ticket/Display.html | 10 +-
9 files changed, 311 insertions(+), 248 deletions(-)
create mode 100644 lib/RT/Action/TicketAction.pm
copy lib/RT/View/{Ticket.pm => Ticket/Update.pm} (80%)
- Log -----------------------------------------------------------------
commit 368de96ba6854c2cb56ed15355f91c3fa5ce7f36
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Tue Dec 8 05:20:58 2009 -0500
Begin refactoring CreateTicket into TicketAction so UpdateTicket can reuse its code
diff --git a/lib/RT/Action/CreateTicket.pm b/lib/RT/Action/CreateTicket.pm
index c2290f4..e733e9e 100644
--- a/lib/RT/Action/CreateTicket.pm
+++ b/lib/RT/Action/CreateTicket.pm
@@ -1,10 +1,7 @@
package RT::Action::CreateTicket;
use strict;
use warnings;
-use base 'RT::Action::QueueBased', 'RT::Action::WithCustomFields', 'Jifty::Action::Record::Create';
-
-use constant record_class => 'RT::Model::Ticket';
-use constant report_detailed_messages => 1;
+use base 'RT::Action::TicketAction', 'Jifty::Action::Record::Create';
use Jifty::Param::Schema;
use Jifty::Action schema {
diff --git a/lib/RT/Action/TicketAction.pm b/lib/RT/Action/TicketAction.pm
new file mode 100644
index 0000000..ecef656
--- /dev/null
+++ b/lib/RT/Action/TicketAction.pm
@@ -0,0 +1,10 @@
+package RT::Action::TicketAction;
+use strict;
+use warnings;
+use base 'RT::Action::QueueBased', 'RT::Action::WithCustomFields';
+
+use constant record_class => 'RT::Model::Ticket';
+use constant report_detailed_messages => 1;
+
+1;
+
commit 46f45b495963d38a4c0510c260fc0a29eb408657
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Tue Dec 8 05:29:19 2009 -0500
Move set_valid_owners into TicketAction
diff --git a/lib/RT/Action/CreateTicket.pm b/lib/RT/Action/CreateTicket.pm
index e733e9e..f6e4e35 100644
--- a/lib/RT/Action/CreateTicket.pm
+++ b/lib/RT/Action/CreateTicket.pm
@@ -50,7 +50,6 @@ sub after_set_queue {
$self->SUPER::after_set_queue(@_);
$self->set_valid_statuses($queue);
- $self->set_valid_owners($queue);
$self->setup_gnupg($queue);
$self->add_role_group_parameter(
@@ -141,38 +140,6 @@ sub set_valid_statuses {
$self->fill_parameter(status => valid_values => \@valid_statuses);
}
-sub set_valid_owners {
- my $self = shift;
- my $queue = shift;
-
- my $isSU = Jifty->web->current_user->has_right(
- right => 'SuperUser',
- object => RT->system,
- );
-
- my $users = RT::Model::UserCollection->new;
- $users->who_have_right(
- right => 'OwnTicket',
- object => $queue,
- include_system_rights => 1,
- include_superusers => $isSU,
- );
-
- my %user_uniq_hash;
- while (my $user = $users->next) {
- $user_uniq_hash{ $user->id } = $user;
- }
-
- # delete nobody here, so we can make them first later
- delete $user_uniq_hash{RT->nobody->id};
-
- my @valid_owners = sort { uc( $a->name ) cmp uc( $b->name ) }
- values %user_uniq_hash;
- unshift @valid_owners, RT->nobody;
-
- $self->fill_parameter(owner => valid_values => [ map { $_->id } @valid_owners ]);
-}
-
sub setup_gnupg {
my $self = shift;
my $queue = shift;
diff --git a/lib/RT/Action/TicketAction.pm b/lib/RT/Action/TicketAction.pm
index ecef656..7648156 100644
--- a/lib/RT/Action/TicketAction.pm
+++ b/lib/RT/Action/TicketAction.pm
@@ -6,5 +6,45 @@ use base 'RT::Action::QueueBased', 'RT::Action::WithCustomFields';
use constant record_class => 'RT::Model::Ticket';
use constant report_detailed_messages => 1;
+sub after_set_queue {
+ my $self = shift;
+ my $queue = shift;
+ $self->SUPER::after_set_queue($queue, @_);
+
+ $self->set_valid_owners($queue);
+}
+
+sub set_valid_owners {
+ my $self = shift;
+ my $queue = shift;
+
+ my $isSU = Jifty->web->current_user->has_right(
+ right => 'SuperUser',
+ object => RT->system,
+ );
+
+ my $users = RT::Model::UserCollection->new;
+ $users->who_have_right(
+ right => 'OwnTicket',
+ object => $queue,
+ include_system_rights => 1,
+ include_superusers => $isSU,
+ );
+
+ my %user_uniq_hash;
+ while (my $user = $users->next) {
+ $user_uniq_hash{ $user->id } = $user;
+ }
+
+ # delete nobody here, so we can make them first later
+ delete $user_uniq_hash{RT->nobody->id};
+
+ my @valid_owners = sort { uc( $a->name ) cmp uc( $b->name ) }
+ values %user_uniq_hash;
+ unshift @valid_owners, RT->nobody;
+
+ $self->fill_parameter(owner => valid_values => [ map { $_->id } @valid_owners ]);
+}
+
1;
commit a641a3bf471ae3f178ba2acb7cdd3562d6831266
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Tue Dec 8 05:35:46 2009 -0500
Need to pass $queue upwards
diff --git a/lib/RT/Action/CreateTicket.pm b/lib/RT/Action/CreateTicket.pm
index f6e4e35..1ed63e5 100644
--- a/lib/RT/Action/CreateTicket.pm
+++ b/lib/RT/Action/CreateTicket.pm
@@ -47,7 +47,7 @@ use Jifty::Action schema {
sub after_set_queue {
my $self = shift;
my $queue = shift;
- $self->SUPER::after_set_queue(@_);
+ $self->SUPER::after_set_queue($queue, @_);
$self->set_valid_statuses($queue);
$self->setup_gnupg($queue);
commit d06d867ceaa64ef735acdc08207e2468aa420c09
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Tue Dec 8 06:34:36 2009 -0500
Refactor set_valid_statuses into TicketAction
diff --git a/lib/RT/Action/CreateTicket.pm b/lib/RT/Action/CreateTicket.pm
index 1ed63e5..57e68a0 100644
--- a/lib/RT/Action/CreateTicket.pm
+++ b/lib/RT/Action/CreateTicket.pm
@@ -49,7 +49,6 @@ sub after_set_queue {
my $queue = shift;
$self->SUPER::after_set_queue($queue, @_);
- $self->set_valid_statuses($queue);
$self->setup_gnupg($queue);
$self->add_role_group_parameter(
@@ -132,12 +131,10 @@ sub after_set_queue {
$self->set_final_priority($queue);
}
-sub set_valid_statuses {
+sub _valid_statuses {
my $self = shift;
my $queue = shift;
-
- my @valid_statuses = $queue->status_schema->initial;
- $self->fill_parameter(status => valid_values => \@valid_statuses);
+ return $queue->status_schema->initial;
}
sub setup_gnupg {
diff --git a/lib/RT/Action/TicketAction.pm b/lib/RT/Action/TicketAction.pm
index 7648156..2a0129d 100644
--- a/lib/RT/Action/TicketAction.pm
+++ b/lib/RT/Action/TicketAction.pm
@@ -11,9 +11,18 @@ sub after_set_queue {
my $queue = shift;
$self->SUPER::after_set_queue($queue, @_);
+ $self->set_valid_statuses($queue);
$self->set_valid_owners($queue);
}
+sub set_valid_statuses {
+ my $self = shift;
+ my $queue = shift;
+
+ my @valid_statuses = $self->_valid_statuses($queue);
+ $self->fill_parameter(status => valid_values => \@valid_statuses);
+}
+
sub set_valid_owners {
my $self = shift;
my $queue = shift;
commit 7109bd2ddef4e8db05e50017b5ebf35a9c3a85aa
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Tue Dec 8 06:44:26 2009 -0500
Move CF initialization into TicketAction
diff --git a/lib/RT/Action/CreateTicket.pm b/lib/RT/Action/CreateTicket.pm
index 57e68a0..6df07e3 100644
--- a/lib/RT/Action/CreateTicket.pm
+++ b/lib/RT/Action/CreateTicket.pm
@@ -124,9 +124,6 @@ sub after_set_queue {
label => _('Referred to by'),
);
- $self->add_ticket_custom_fields($queue);
- $self->add_ticket_transaction_custom_fields($queue);
-
$self->set_initial_priority($queue);
$self->set_final_priority($queue);
}
@@ -249,28 +246,6 @@ sub report_success {
$self->result->message(_("Created ticket #%1 in queue %2", $id, $queue));
}
-sub add_ticket_custom_fields {
- my $self = shift;
- my $queue = shift;
-
- my $cfs = $queue->ticket_custom_fields;
- $self->_add_custom_fields(
- cfs => $cfs,
- method => 'add_ticket_custom_field_parameter',
- );
-}
-
-sub add_ticket_transaction_custom_fields {
- my $self = shift;
- my $queue = shift;
-
- my $cfs = $queue->ticket_transaction_custom_fields;
- $self->_add_custom_fields(
- cfs => $cfs,
- method => 'add_ticket_transaction_custom_field_parameter',
- );
-}
-
sub _add_parameter_type {
my $class = shift;
my %args = @_;
diff --git a/lib/RT/Action/TicketAction.pm b/lib/RT/Action/TicketAction.pm
index 2a0129d..6f8b056 100644
--- a/lib/RT/Action/TicketAction.pm
+++ b/lib/RT/Action/TicketAction.pm
@@ -13,6 +13,9 @@ sub after_set_queue {
$self->set_valid_statuses($queue);
$self->set_valid_owners($queue);
+
+ $self->add_ticket_custom_fields($queue);
+ $self->add_ticket_transaction_custom_fields($queue);
}
sub set_valid_statuses {
@@ -55,5 +58,27 @@ sub set_valid_owners {
$self->fill_parameter(owner => valid_values => [ map { $_->id } @valid_owners ]);
}
+sub add_ticket_custom_fields {
+ my $self = shift;
+ my $queue = shift;
+
+ my $cfs = $queue->ticket_custom_fields;
+ $self->_add_custom_fields(
+ cfs => $cfs,
+ method => 'add_ticket_custom_field_parameter',
+ );
+}
+
+sub add_ticket_transaction_custom_fields {
+ my $self = shift;
+ my $queue = shift;
+
+ my $cfs = $queue->ticket_transaction_custom_fields;
+ $self->_add_custom_fields(
+ cfs => $cfs,
+ method => 'add_ticket_transaction_custom_field_parameter',
+ );
+}
+
1;
commit 765e0142b57db5c945013b5a01f6ab30f793394c
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Tue Dec 8 06:51:20 2009 -0500
Forgot to move the parameter type creators
diff --git a/lib/RT/Action/CreateTicket.pm b/lib/RT/Action/CreateTicket.pm
index 6df07e3..f34d43a 100644
--- a/lib/RT/Action/CreateTicket.pm
+++ b/lib/RT/Action/CreateTicket.pm
@@ -312,13 +312,5 @@ __PACKAGE__->_add_parameter_type(
},
);
-__PACKAGE__->_add_parameter_type(
- name => 'ticket_custom_field',
-);
-
-__PACKAGE__->_add_parameter_type(
- name => 'ticket_transaction_custom_field',
-);
-
1;
diff --git a/lib/RT/Action/TicketAction.pm b/lib/RT/Action/TicketAction.pm
index 6f8b056..435e982 100644
--- a/lib/RT/Action/TicketAction.pm
+++ b/lib/RT/Action/TicketAction.pm
@@ -80,5 +80,13 @@ sub add_ticket_transaction_custom_fields {
);
}
+__PACKAGE__->_add_parameter_type(
+ name => 'ticket_custom_field',
+);
+
+__PACKAGE__->_add_parameter_type(
+ name => 'ticket_transaction_custom_field',
+);
+
1;
commit 9002518242f7187a18d587352ddf4358f252cf0d
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Tue Dec 8 06:52:06 2009 -0500
Move _add_parameter_type upwards
diff --git a/lib/RT/Action/CreateTicket.pm b/lib/RT/Action/CreateTicket.pm
index f34d43a..1bf9d0f 100644
--- a/lib/RT/Action/CreateTicket.pm
+++ b/lib/RT/Action/CreateTicket.pm
@@ -246,40 +246,6 @@ sub report_success {
$self->result->message(_("Created ticket #%1 in queue %2", $id, $queue));
}
-sub _add_parameter_type {
- my $class = shift;
- my %args = @_;
-
- my $name = $args{name};
- my $key = $args{key} || "_${name}_parameters";
- my $add_method = $args{add_method} || "add_${name}_parameter";
- my $get_method = $args{get_method} || "${name}_parameters";
- my %defaults = %{ $args{defaults} || {} };
-
- no strict 'refs';
-
- *{__PACKAGE__."::$get_method"} = sub {
- use strict 'refs';
- my $self = shift;
- return @{ $self->{$key} || [] };
- };
-
- *{__PACKAGE__."::$add_method"} = sub {
- use strict 'refs';
- my $self = shift;
- my %args = @_;
-
- my $parameter = delete $args{name};
-
- push @{ $self->{$key} }, $parameter;
-
- $self->fill_parameter($parameter => (
- %defaults,
- %args,
- ));
- };
-}
-
__PACKAGE__->_add_parameter_type(
name => 'role_group',
defaults => {
diff --git a/lib/RT/Action/TicketAction.pm b/lib/RT/Action/TicketAction.pm
index 435e982..3a799e9 100644
--- a/lib/RT/Action/TicketAction.pm
+++ b/lib/RT/Action/TicketAction.pm
@@ -80,6 +80,40 @@ sub add_ticket_transaction_custom_fields {
);
}
+sub _add_parameter_type {
+ my $class = shift;
+ my %args = @_;
+
+ my $name = $args{name};
+ my $key = $args{key} || "_${name}_parameters";
+ my $add_method = $args{add_method} || "add_${name}_parameter";
+ my $get_method = $args{get_method} || "${name}_parameters";
+ my %defaults = %{ $args{defaults} || {} };
+
+ no strict 'refs';
+
+ *{__PACKAGE__."::$get_method"} = sub {
+ use strict 'refs';
+ my $self = shift;
+ return @{ $self->{$key} || [] };
+ };
+
+ *{__PACKAGE__."::$add_method"} = sub {
+ use strict 'refs';
+ my $self = shift;
+ my %args = @_;
+
+ my $parameter = delete $args{name};
+
+ push @{ $self->{$key} }, $parameter;
+
+ $self->fill_parameter($parameter => (
+ %defaults,
+ %args,
+ ));
+ };
+}
+
__PACKAGE__->_add_parameter_type(
name => 'ticket_custom_field',
);
commit 12dd1fb5598bd4ff4eaefc4eb658ef8f5da777f4
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Tue Dec 8 06:52:39 2009 -0500
Move datetime/duration parameters upwards too
diff --git a/lib/RT/Action/CreateTicket.pm b/lib/RT/Action/CreateTicket.pm
index 1bf9d0f..7f1941a 100644
--- a/lib/RT/Action/CreateTicket.pm
+++ b/lib/RT/Action/CreateTicket.pm
@@ -69,31 +69,6 @@ sub after_set_queue {
hints => _('(Sends a carbon-copy of this update to a comma-delimited list of administrative email addresses. These people <strong>will</strong> receive future updates.)'),
);
- $self->add_duration_parameter(
- name => 'time_estimated',
- label => _('Time Estimated'),
- );
-
- $self->add_duration_parameter(
- name => 'time_worked',
- label => _('Time Worked'),
- );
-
- $self->add_duration_parameter(
- name => 'time_left',
- label => _('Time Left'),
- );
-
- $self->add_datetime_parameter(
- name => 'starts',
- label => _('Starts'),
- );
-
- $self->add_datetime_parameter(
- name => 'due',
- label => _('Due'),
- );
-
$self->add_link_parameter(
name => 'depends_on',
label => _('Depends on'),
@@ -255,22 +230,6 @@ __PACKAGE__->_add_parameter_type(
);
__PACKAGE__->_add_parameter_type(
- name => 'duration',
- defaults => {
- render_as => 'text', # ideally would be Duration
- display_length => 3,
- },
-);
-
-__PACKAGE__->_add_parameter_type(
- name => 'datetime',
- defaults => {
- render_as => 'DateTime',
- display_length => 16,
- },
-);
-
-__PACKAGE__->_add_parameter_type(
name => 'link',
defaults => {
render_as => 'text',
diff --git a/lib/RT/Action/TicketAction.pm b/lib/RT/Action/TicketAction.pm
index 3a799e9..34c3149 100644
--- a/lib/RT/Action/TicketAction.pm
+++ b/lib/RT/Action/TicketAction.pm
@@ -16,6 +16,31 @@ sub after_set_queue {
$self->add_ticket_custom_fields($queue);
$self->add_ticket_transaction_custom_fields($queue);
+
+ $self->add_duration_parameter(
+ name => 'time_estimated',
+ label => _('Time Estimated'),
+ );
+
+ $self->add_duration_parameter(
+ name => 'time_worked',
+ label => _('Time Worked'),
+ );
+
+ $self->add_duration_parameter(
+ name => 'time_left',
+ label => _('Time Left'),
+ );
+
+ $self->add_datetime_parameter(
+ name => 'starts',
+ label => _('Starts'),
+ );
+
+ $self->add_datetime_parameter(
+ name => 'due',
+ label => _('Due'),
+ );
}
sub set_valid_statuses {
@@ -122,5 +147,21 @@ __PACKAGE__->_add_parameter_type(
name => 'ticket_transaction_custom_field',
);
+__PACKAGE__->_add_parameter_type(
+ name => 'duration',
+ defaults => {
+ render_as => 'text', # ideally would be Duration
+ display_length => 3,
+ },
+);
+
+__PACKAGE__->_add_parameter_type(
+ name => 'datetime',
+ defaults => {
+ render_as => 'DateTime',
+ display_length => 16,
+ },
+);
+
1;
commit 70aebdae13b621d435f6603cda20b632fa753ce5
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Tue Dec 8 07:07:17 2009 -0500
Gut most of the existing UpdateTicket
diff --git a/lib/RT/Action/UpdateTicket.pm b/lib/RT/Action/UpdateTicket.pm
index c0860cd..9c69891 100644
--- a/lib/RT/Action/UpdateTicket.pm
+++ b/lib/RT/Action/UpdateTicket.pm
@@ -1,96 +1,7 @@
package RT::Action::UpdateTicket;
use strict;
use warnings;
-
-use base qw/Jifty::Action::Record::Update/;
-
-sub record_class { 'RT::Model::Ticket' }
-
-use constant report_detailed_messages => 1;
-
-sub arguments {
- my $self = shift;
-
- my $args = $self->SUPER::arguments();
- $args->{status}{valid_values} = $self->_compute_possible_statuses;
- $args->{queue}{valid_values} = $self->_compute_possible_queues;
- $args->{owner}{valid_values} = $self->_compute_possible_owners;
- return $args;
-}
-
-=head2 take_action
-
-=cut
-
-sub take_action {
- my $self = shift;
- my @date_fields = qw/told starts started due/;
-
- foreach my $field (@date_fields) {
- my $value = $self->argument_value($field);
- if ( defined $value ) {
-
- # convert date to be as UTC
- my $date = RT::DateTime->new_from_string($value);
- $self->argument_value($field, $date);
- }
- }
-
- my @time_fields = qw/time_left time_estimated time_worked/;
-
- foreach my $field (@time_fields) {
- my $value = $self->argument_value($field);
- if ( defined $value ) {
- if ( $value =~ /([\d.]+)h(our)?/ ) {
- $value = int $1 * 60;
- }
- elsif ( $value =~ /(\d+)/ ) {
- $value = $1;
- }
- $self->argument_value( $field, $value );
- }
- }
-
- $self->SUPER::take_action;
- return 1;
-}
-
-sub _compute_possible_owners {
- my $self = shift;
-
- my @objects = ( $self->record, $self->record->queue );
-
- my %user_uniq_hash;
-
- my $isSU = Jifty->web->current_user->has_right(
- right => 'SuperUser',
- object => RT->system
- );
-
- foreach my $object (@objects) {
- my $Users = RT::Model::UserCollection->new;
- $Users->who_have_right(
- right => 'OwnTicket',
- object => $object,
- include_system_rights => 1,
- include_superusers => $isSU
- );
- while ( my $user = $Users->next() ) {
- next
- if ( $user->id == RT->nobody->id )
- ; # skip nobody here, so we can make them first later
- $user_uniq_hash{ $user->id() } = $user;
- }
- }
-
- my $owners = [
- map { { display => $_->name, value => $_->id } }
- sort { uc( $a->name ) cmp uc( $b->name ) } values %user_uniq_hash
- ];
- unshift @$owners, { display => 'Nobody', value => RT->nobody->id };
-
- return $owners;
-}
+use base 'RT::Action::TicketAction', 'Jifty::Action::Record::Update';
sub _compute_possible_queues {
my $self = shift;
@@ -117,15 +28,4 @@ sub _compute_possible_queues {
return $queues;
}
-sub _compute_possible_statuses {
- my $self = shift;
-
- my $record = $self->record;
- return [
- map { { display => $_, value => $_ } }
- $record->status,
- $record->queue->status_schema->transitions( $record->status )
- ];
-}
-
1;
commit d6dc15ec7e336fb7e8812a2e68fb2b7094410e6c
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Tue Dec 8 07:33:42 2009 -0500
More appropriate _valid_statuses for UpdateTicket
diff --git a/lib/RT/Action/UpdateTicket.pm b/lib/RT/Action/UpdateTicket.pm
index 9c69891..fbcacba 100644
--- a/lib/RT/Action/UpdateTicket.pm
+++ b/lib/RT/Action/UpdateTicket.pm
@@ -3,6 +3,16 @@ use strict;
use warnings;
use base 'RT::Action::TicketAction', 'Jifty::Action::Record::Update';
+sub _valid_statuses {
+ my $self = shift;
+
+ my $record = $self->record;
+ return (
+ $record->status,
+ $record->queue->status_schema->transitions($record->status),
+ );
+}
+
sub _compute_possible_queues {
my $self = shift;
commit 7dc46684a51f5866bdb678168f5d4a201b12d061
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Wed Dec 9 04:13:03 2009 -0500
Various improvements to set_valid_owners
diff --git a/lib/RT/Action/TicketAction.pm b/lib/RT/Action/TicketAction.pm
index 34c3149..e196da5 100644
--- a/lib/RT/Action/TicketAction.pm
+++ b/lib/RT/Action/TicketAction.pm
@@ -60,17 +60,21 @@ sub set_valid_owners {
object => RT->system,
);
- my $users = RT::Model::UserCollection->new;
- $users->who_have_right(
- right => 'OwnTicket',
- object => $queue,
- include_system_rights => 1,
- include_superusers => $isSU,
- );
-
my %user_uniq_hash;
- while (my $user = $users->next) {
- $user_uniq_hash{ $user->id } = $user;
+ for my $object ($self->record, $queue) {
+ next if !$object->id;
+
+ my $users = RT::Model::UserCollection->new;
+ $users->who_have_right(
+ right => 'OwnTicket',
+ object => $object,
+ include_system_rights => 1,
+ include_superusers => $isSU,
+ );
+
+ while (my $user = $users->next) {
+ $user_uniq_hash{ $user->id } = $user;
+ }
}
# delete nobody here, so we can make them first later
@@ -80,7 +84,10 @@ sub set_valid_owners {
values %user_uniq_hash;
unshift @valid_owners, RT->nobody;
- $self->fill_parameter(owner => valid_values => [ map { $_->id } @valid_owners ]);
+ $self->fill_parameter(owner => (
+ valid_values => [ map { $_->id } @valid_owners ],
+ default_value => $self->record->owner->id,
+ ));
}
sub add_ticket_custom_fields {
commit 057d86985507db15c0525f5f6fb262d2170ec94e
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Wed Dec 9 06:30:17 2009 -0500
Catch setting the record in TicketAction so we can set queue
diff --git a/lib/RT/Action/TicketAction.pm b/lib/RT/Action/TicketAction.pm
index e196da5..c5b12e9 100644
--- a/lib/RT/Action/TicketAction.pm
+++ b/lib/RT/Action/TicketAction.pm
@@ -6,6 +6,21 @@ use base 'RT::Action::QueueBased', 'RT::Action::WithCustomFields';
use constant record_class => 'RT::Model::Ticket';
use constant report_detailed_messages => 1;
+# We can't use SUPER here because TicketAction does not inherit from
+# Jifty::Action::Record, and SUPER is statically determined. Maybe time to
+# switch to roles.
+sub record {
+ my $self = shift;
+ return $self->Jifty::Action::Record::record if @_ == 0; # reader
+
+ my $record = shift;
+ my $ret = $self->Jifty::Action::Record::record($record, @_);
+
+ $self->set_queue($record->queue);
+
+ return $ret;
+}
+
sub after_set_queue {
my $self = shift;
my $queue = shift;
commit a25fe95bad61c34d7ee5f3e9881f86d159ec5d90
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Wed Dec 9 06:32:46 2009 -0500
Only set_queue if we actually have a queue
diff --git a/lib/RT/Action/TicketAction.pm b/lib/RT/Action/TicketAction.pm
index c5b12e9..3e0f7a0 100644
--- a/lib/RT/Action/TicketAction.pm
+++ b/lib/RT/Action/TicketAction.pm
@@ -16,7 +16,8 @@ sub record {
my $record = shift;
my $ret = $self->Jifty::Action::Record::record($record, @_);
- $self->set_queue($record->queue);
+ $self->set_queue($record->queue)
+ if $record->queue->id;
return $ret;
}
commit 8138576516900396175dc008cf304dd1630dcd82
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Wed Dec 9 07:45:30 2009 -0500
Depend on Time::Duration::Parse
diff --git a/Makefile.PL b/Makefile.PL
index 08fa2b1..fd60b97 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -29,6 +29,7 @@ requires(
'Text::Wrapper' => 0,
'Time::ParseDate' => 0,
'Time::HiRes' => 0,
+ 'Time::Duration::Parse' => 0,
'File::Temp' => '0.18',
'Text::Quoted' => '2.02',
'Tree::Simple' => '1.04',
commit 34b79c37a3d1c439d75299e03294030eef8cce4d
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Wed Dec 9 07:48:17 2009 -0500
_canonicalize_duration in TicketAction
diff --git a/lib/RT/Action/TicketAction.pm b/lib/RT/Action/TicketAction.pm
index 3e0f7a0..9c580ad 100644
--- a/lib/RT/Action/TicketAction.pm
+++ b/lib/RT/Action/TicketAction.pm
@@ -6,6 +6,8 @@ use base 'RT::Action::QueueBased', 'RT::Action::WithCustomFields';
use constant record_class => 'RT::Model::Ticket';
use constant report_detailed_messages => 1;
+use Time::Duration::Parse;
+
# We can't use SUPER here because TicketAction does not inherit from
# Jifty::Action::Record, and SUPER is statically determined. Maybe time to
# switch to roles.
@@ -162,6 +164,17 @@ sub _add_parameter_type {
};
}
+sub _canonicalize_duration {
+ my $self = shift;
+ my $value = shift;
+
+ if (defined $value) {
+ $value = parse_duration($value);
+ }
+
+ return $value;
+}
+
__PACKAGE__->_add_parameter_type(
name => 'ticket_custom_field',
);
commit 37e8dba49a360aedef034f97019046f736118bd9
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Wed Dec 9 07:55:40 2009 -0500
Add canonicalizers for the time duration fields
diff --git a/lib/RT/Action/TicketAction.pm b/lib/RT/Action/TicketAction.pm
index 9c580ad..33647bd 100644
--- a/lib/RT/Action/TicketAction.pm
+++ b/lib/RT/Action/TicketAction.pm
@@ -162,6 +162,21 @@ sub _add_parameter_type {
%args,
));
};
+
+ if (my $shared_canonicalizer = $args{shared_canonicalizer}) {
+ $shared_canonicalizer = "_canonicalize_$name"
+ if $shared_canonicalizer eq '1';
+
+ unless (__PACKAGE__->can("canonicalize_$name")) {
+ *{__PACKAGE__."::canonicalize_$name"} = sub {
+ use strict 'refs';
+ my $self = shift;
+ my $value = shift;
+
+ return $self->$shared_canonicalizer($value, @_);
+ };
+ }
+ }
}
sub _canonicalize_duration {
@@ -189,6 +204,7 @@ __PACKAGE__->_add_parameter_type(
render_as => 'text', # ideally would be Duration
display_length => 3,
},
+ shared_canonicalizer => 1,
);
__PACKAGE__->_add_parameter_type(
commit 1bc971ac9a846a35b83a312475bfd7013fda1ee8
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Wed Dec 9 07:57:32 2009 -0500
Use $class since we have it, not __PACKAGE__
diff --git a/lib/RT/Action/TicketAction.pm b/lib/RT/Action/TicketAction.pm
index 33647bd..3ee16f3 100644
--- a/lib/RT/Action/TicketAction.pm
+++ b/lib/RT/Action/TicketAction.pm
@@ -142,13 +142,13 @@ sub _add_parameter_type {
no strict 'refs';
- *{__PACKAGE__."::$get_method"} = sub {
+ *{$class."::$get_method"} = sub {
use strict 'refs';
my $self = shift;
return @{ $self->{$key} || [] };
};
- *{__PACKAGE__."::$add_method"} = sub {
+ *{$class."::$add_method"} = sub {
use strict 'refs';
my $self = shift;
my %args = @_;
@@ -167,8 +167,8 @@ sub _add_parameter_type {
$shared_canonicalizer = "_canonicalize_$name"
if $shared_canonicalizer eq '1';
- unless (__PACKAGE__->can("canonicalize_$name")) {
- *{__PACKAGE__."::canonicalize_$name"} = sub {
+ unless ($class->can("canonicalize_$name")) {
+ *{$class."::canonicalize_$name"} = sub {
use strict 'refs';
my $self = shift;
my $value = shift;
commit 7d9e04938c068f47b667a498d6062caaabd421e5
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Thu Dec 10 03:42:05 2009 -0500
Unconfuse the shared_canonicalizer logic by just using a coderef
diff --git a/lib/RT/Action/TicketAction.pm b/lib/RT/Action/TicketAction.pm
index 3ee16f3..9f72e2b 100644
--- a/lib/RT/Action/TicketAction.pm
+++ b/lib/RT/Action/TicketAction.pm
@@ -163,33 +163,19 @@ sub _add_parameter_type {
));
};
- if (my $shared_canonicalizer = $args{shared_canonicalizer}) {
- $shared_canonicalizer = "_canonicalize_$name"
- if $shared_canonicalizer eq '1';
-
+ if (my $canonicalizer = $args{canonicalizer}) {
unless ($class->can("canonicalize_$name")) {
*{$class."::canonicalize_$name"} = sub {
use strict 'refs';
my $self = shift;
my $value = shift;
- return $self->$shared_canonicalizer($value, @_);
+ return $self->$canonicalizer($value, @_);
};
}
}
}
-sub _canonicalize_duration {
- my $self = shift;
- my $value = shift;
-
- if (defined $value) {
- $value = parse_duration($value);
- }
-
- return $value;
-}
-
__PACKAGE__->_add_parameter_type(
name => 'ticket_custom_field',
);
@@ -204,7 +190,16 @@ __PACKAGE__->_add_parameter_type(
render_as => 'text', # ideally would be Duration
display_length => 3,
},
- shared_canonicalizer => 1,
+ canonicalizer => sub {
+ my $self = shift;
+ my $value = shift;
+
+ if (defined $value) {
+ $value = parse_duration($value);
+ }
+
+ return $value;
+ },
);
__PACKAGE__->_add_parameter_type(
commit 200af953241207b1bbe68988dbdae98c22215a56
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Thu Dec 10 04:28:07 2009 -0500
Add some parameters to UpdateTicket
diff --git a/lib/RT/Action/UpdateTicket.pm b/lib/RT/Action/UpdateTicket.pm
index fbcacba..4335410 100644
--- a/lib/RT/Action/UpdateTicket.pm
+++ b/lib/RT/Action/UpdateTicket.pm
@@ -3,6 +3,25 @@ use strict;
use warnings;
use base 'RT::Action::TicketAction', 'Jifty::Action::Record::Update';
+use Jifty::Param::Schema;
+use Jifty::Action schema {
+ param status =>
+ render as 'select',
+ label is _('Status');
+
+ param owner =>
+ render as 'RT::View::Form::Field::SelectUser',
+ # valid_values are queue-specific
+ valid_values are lazy { RT->nobody->id },
+ label is _('Owner');
+
+ param subject =>
+ render as 'text',
+ display_length is 60,
+ max_length is 200,
+ label is _('Subject');
+};
+
sub _valid_statuses {
my $self = shift;
commit 31b6be2f835143a2dfd9880a7866fde3276a2689
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Thu Dec 10 04:30:54 2009 -0500
AJAX-canonicalize duration fields
diff --git a/lib/RT/Action/TicketAction.pm b/lib/RT/Action/TicketAction.pm
index 9f72e2b..1f8f512 100644
--- a/lib/RT/Action/TicketAction.pm
+++ b/lib/RT/Action/TicketAction.pm
@@ -187,8 +187,9 @@ __PACKAGE__->_add_parameter_type(
__PACKAGE__->_add_parameter_type(
name => 'duration',
defaults => {
- render_as => 'text', # ideally would be Duration
- display_length => 3,
+ render_as => 'text', # ideally would be Duration
+ display_length => 3,
+ ajax_canonicalizes => 1,
},
canonicalizer => sub {
my $self = shift;
commit 5ac3fc2698b1c7410a22a419bf0d4d31f388c03a
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Thu Dec 10 06:24:51 2009 -0500
First cut of Ticket::Update view code
diff --git a/lib/RT/View/Ticket/Update.pm b/lib/RT/View/Ticket/Update.pm
new file mode 100644
index 0000000..928658f
--- /dev/null
+++ b/lib/RT/View/Ticket/Update.pm
@@ -0,0 +1,74 @@
+# BEGIN BPS TAGGED BLOCK {{{
+#
+# COPYRIGHT:
+#
+# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC
+# <jesse 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/copyleft/gpl.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 }}}
+use warnings;
+use strict;
+
+package RT::View::Ticket::Update;
+use Jifty::View::Declare -base;
+
+__PACKAGE__->use_mason_wrapper;
+
+template 'modify' => page { title => _('Modify a ticket') } content {
+ my $ticket = get('ticket');
+
+ my $update = new_action(
+ class => 'UpdateTicket',
+ moniker => 'modify_ticket',
+ arguments => {
+ record => $ticket,
+ },
+ );
+
+ with ( name => 'ticket_modify' ), form {
+ form_next_page url => '/Ticket/Display.html';
+
+ render_action($update);
+ form_submit( label => _('Save') );
+ };
+};
+
commit 0ce1ce7a57d05ab6e4ae64e636b09670ebb890a1
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Thu Dec 10 06:30:22 2009 -0500
Stitch /ticket/modify into the dispatcher
diff --git a/lib/RT/Dispatcher.pm b/lib/RT/Dispatcher.pm
index 118aa27..cbdd903 100644
--- a/lib/RT/Dispatcher.pm
+++ b/lib/RT/Dispatcher.pm
@@ -747,6 +747,20 @@ on '/ticket/create' => run {
}
};
+on '/ticket/modify' => run {
+ my $action = Jifty->web->request->action('update_ticket');
+ my $id = $action ? $action->argument('id') : get('id');
+ if (!defined($id)) {
+ die "no ticket selected";
+ }
+ else {
+ my $ticket = RT::Model::Ticket->new;
+ $ticket->load($id);
+ set(ticket => $ticket);
+ show '/ticket/modify';
+ }
+};
+
# Backward compatibility with old RT URLs
before '/NoAuth/Logout.html' => run { redirect '/logout' };
diff --git a/lib/RT/View/Ticket.pm b/lib/RT/View/Ticket.pm
index 17e31bf..fde2d30 100644
--- a/lib/RT/View/Ticket.pm
+++ b/lib/RT/View/Ticket.pm
@@ -59,5 +59,8 @@ alias RT::View::Ticket::Links under '/';
require RT::View::Ticket::Create;
alias RT::View::Ticket::Create under '/';
+require RT::View::Ticket::Update;
+alias RT::View::Ticket::Update under '/';
+
1;
commit 53b9f8e2293b7d40a1113088acca33e95ecf9079
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Fri Dec 11 03:39:01 2009 -0500
Remove useless use of indirection
diff --git a/lib/RT/Action/TicketAction.pm b/lib/RT/Action/TicketAction.pm
index 1f8f512..261d54c 100644
--- a/lib/RT/Action/TicketAction.pm
+++ b/lib/RT/Action/TicketAction.pm
@@ -165,13 +165,7 @@ sub _add_parameter_type {
if (my $canonicalizer = $args{canonicalizer}) {
unless ($class->can("canonicalize_$name")) {
- *{$class."::canonicalize_$name"} = sub {
- use strict 'refs';
- my $self = shift;
- my $value = shift;
-
- return $self->$canonicalizer($value, @_);
- };
+ *{$class."::canonicalize_$name"} = $canonicalizer;
}
}
}
commit 3944bb7344f659d7c8c0d1a8bee6210f2c591f81
Merge: 53b9f8e 144befc
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Tue Dec 15 13:23:42 2009 -0500
Merge branch '3.999' into update-action
diff --cc lib/RT/Action/CreateTicket.pm
index 7f1941a,79477fb..6a924d4
--- a/lib/RT/Action/CreateTicket.pm
+++ b/lib/RT/Action/CreateTicket.pm
@@@ -1,8 -1,13 +1,10 @@@
package RT::Action::CreateTicket;
use strict;
use warnings;
-use base 'RT::Action::QueueBased', 'RT::Action::WithCustomFields', 'Jifty::Action::Record::Create';
-
-use constant record_class => 'RT::Model::Ticket';
-use constant report_detailed_messages => 1;
+use base 'RT::Action::TicketAction', 'Jifty::Action::Record::Create';
+ use RT::Crypt::GnuPG;
+
use Jifty::Param::Schema;
use Jifty::Action schema {
param status =>
commit 187daaaf258962089d9b5959a4300f93a1ec5ef9
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Tue Dec 15 14:05:32 2009 -0500
Don't load the ticket in the dispatcher, load it in the template
diff --git a/lib/RT/Dispatcher.pm b/lib/RT/Dispatcher.pm
index cbdd903..6a38504 100644
--- a/lib/RT/Dispatcher.pm
+++ b/lib/RT/Dispatcher.pm
@@ -754,9 +754,7 @@ on '/ticket/modify' => run {
die "no ticket selected";
}
else {
- my $ticket = RT::Model::Ticket->new;
- $ticket->load($id);
- set(ticket => $ticket);
+ set(id => $id);
show '/ticket/modify';
}
};
diff --git a/lib/RT/View/Ticket/Update.pm b/lib/RT/View/Ticket/Update.pm
index 928658f..dbda010 100644
--- a/lib/RT/View/Ticket/Update.pm
+++ b/lib/RT/View/Ticket/Update.pm
@@ -54,7 +54,9 @@ use Jifty::View::Declare -base;
__PACKAGE__->use_mason_wrapper;
template 'modify' => page { title => _('Modify a ticket') } content {
- my $ticket = get('ticket');
+ my $id = get('id');
+ my $ticket = RT::Model::Ticket->new;
+ $ticket->load($id);
my $update = new_action(
class => 'UpdateTicket',
commit 3c8f5a52b7b7dc05c209b0f8f41ea2e48a5a2846
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Tue Dec 15 14:11:47 2009 -0500
Arg, Action::Record takes a top-level record parameter, not a record inside the arguments argument
diff --git a/lib/RT/View/Ticket/Update.pm b/lib/RT/View/Ticket/Update.pm
index dbda010..8996bcc 100644
--- a/lib/RT/View/Ticket/Update.pm
+++ b/lib/RT/View/Ticket/Update.pm
@@ -59,11 +59,9 @@ template 'modify' => page { title => _('Modify a ticket') } content {
$ticket->load($id);
my $update = new_action(
- class => 'UpdateTicket',
- moniker => 'modify_ticket',
- arguments => {
- record => $ticket,
- },
+ class => 'UpdateTicket',
+ moniker => 'modify_ticket',
+ record => $ticket,
);
with ( name => 'ticket_modify' ), form {
commit 5a249f3f33371289b90275dbae8e1d3897cad95f
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Tue Dec 15 14:25:58 2009 -0500
Keep track of the id between requests
diff --git a/lib/RT/Action/TicketAction.pm b/lib/RT/Action/TicketAction.pm
index 261d54c..9e236b8 100644
--- a/lib/RT/Action/TicketAction.pm
+++ b/lib/RT/Action/TicketAction.pm
@@ -21,6 +21,8 @@ sub record {
$self->set_queue($record->queue)
if $record->queue->id;
+ $self->fill_parameter(id => default => $record->id);
+
return $ret;
}
diff --git a/lib/RT/Action/UpdateTicket.pm b/lib/RT/Action/UpdateTicket.pm
index 4335410..033bbda 100644
--- a/lib/RT/Action/UpdateTicket.pm
+++ b/lib/RT/Action/UpdateTicket.pm
@@ -5,6 +5,10 @@ use base 'RT::Action::TicketAction', 'Jifty::Action::Record::Update';
use Jifty::Param::Schema;
use Jifty::Action schema {
+ param id =>
+ render as 'hidden',
+ is constructor;
+
param status =>
render as 'select',
label is _('Status');
commit f3143779f2e75fbbbb8876695bc8f6aa6c3b8373
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Tue Dec 15 14:47:39 2009 -0500
Pull the id out of modify_ticket too
diff --git a/share/html/Ticket/Display.html b/share/html/Ticket/Display.html
index 34944f8..b2871f8 100755
--- a/share/html/Ticket/Display.html
+++ b/share/html/Ticket/Display.html
@@ -95,7 +95,8 @@ $collapsed => undef
<%INIT>
-$id ||= Jifty->web->response->result('create_ticket')->content('id');
+$id ||= Jifty->web->response->result('create_ticket')->content('id')
+ || Jifty->web->response->result('modify_ticket')->content('id');
$m->callback( ticket_obj => $ticket_obj, args_ref => \%ARGS, callback_name => 'Initial' );
commit cfeb122562fa3b37e79166234da1d0f748474105
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Wed Dec 16 14:05:43 2009 -0500
Only provide a default id if we have one, otherwise we break CreateTicket
diff --git a/lib/RT/Action/TicketAction.pm b/lib/RT/Action/TicketAction.pm
index 9e236b8..28a76f0 100644
--- a/lib/RT/Action/TicketAction.pm
+++ b/lib/RT/Action/TicketAction.pm
@@ -21,7 +21,8 @@ sub record {
$self->set_queue($record->queue)
if $record->queue->id;
- $self->fill_parameter(id => default => $record->id);
+ $self->fill_parameter(id => default => $record->id)
+ if $record->id;
return $ret;
}
commit 0c38c6c17e0c8f95e657d5a3d1d0f7f903cf2c7f
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Wed Dec 16 14:32:52 2009 -0500
We actually add a canonicalizer when they add a parameter
Not when we create a parameter of a given type
diff --git a/lib/RT/Action/TicketAction.pm b/lib/RT/Action/TicketAction.pm
index 28a76f0..92e7d35 100644
--- a/lib/RT/Action/TicketAction.pm
+++ b/lib/RT/Action/TicketAction.pm
@@ -151,6 +151,8 @@ sub _add_parameter_type {
return @{ $self->{$key} || [] };
};
+ my $canonicalizer = $args{canonicalizer};
+
*{$class."::$add_method"} = sub {
use strict 'refs';
my $self = shift;
@@ -164,13 +166,14 @@ sub _add_parameter_type {
%defaults,
%args,
));
- };
- if (my $canonicalizer = $args{canonicalizer}) {
- unless ($class->can("canonicalize_$name")) {
- *{$class."::canonicalize_$name"} = $canonicalizer;
+ if ($canonicalizer) {
+ unless ($class->can("canonicalize_$parameter")) {
+ no strict 'refs';
+ *{$class."::canonicalize_$parameter"} = $canonicalizer;
+ }
}
- }
+ };
}
__PACKAGE__->_add_parameter_type(
commit 8521fa6d8273223a0a8fa9cf260435ec529f1048
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Wed Dec 16 14:46:52 2009 -0500
Canonicalize to minutes, not seconds
diff --git a/lib/RT/Action/TicketAction.pm b/lib/RT/Action/TicketAction.pm
index 92e7d35..a014b5b 100644
--- a/lib/RT/Action/TicketAction.pm
+++ b/lib/RT/Action/TicketAction.pm
@@ -195,8 +195,9 @@ __PACKAGE__->_add_parameter_type(
my $self = shift;
my $value = shift;
- if (defined $value) {
- $value = parse_duration($value);
+ if ($value) {
+ # parse_duration gives seconds, we want minutes
+ $value = int(parse_duration($value) / 60);
}
return $value;
commit a306ca417697c32d2bb2dbc607546fd31d6b4d29
Merge: 8521fa6 089d41b
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Wed Jan 6 14:54:39 2010 -0500
Merge branch '3.999-trunk' into update-action
commit a8d9cfc308826e6df1b64ad1fe5bcee4c8a521b0
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Wed Jan 13 19:37:24 2010 -0500
In UpdateTicket, merge arguments from both superclass hierarchies
diff --git a/lib/RT/Action/UpdateTicket.pm b/lib/RT/Action/UpdateTicket.pm
index 033bbda..f6d55fb 100644
--- a/lib/RT/Action/UpdateTicket.pm
+++ b/lib/RT/Action/UpdateTicket.pm
@@ -26,6 +26,23 @@ use Jifty::Action schema {
label is _('Subject');
};
+sub arguments {
+ my $self = shift;
+ return $self->Jifty::Action::Record::Update::arguments(@_);
+
+ if (!$self->{_cached_arguments}) {
+ my $ticket_args = $self->RT::Action::TicketAction::arguments(@_);
+ my $update_args = $self->Jifty::Action::Record::Update::arguments(@_);
+
+ $self->{_cached_arguments} = Jifty::Param::Schema::merge_params(
+ $update_args,
+ $ticket_args,
+ );
+ }
+
+ return $self->{_cached_arguments};
+}
+
sub _valid_statuses {
my $self = shift;
commit 5c016dfbd506dd72242060721f20963abee06d36
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Fri Jan 15 14:39:23 2010 -0500
owner default has to be an arrayref
diff --git a/lib/RT/Action/CreateTicket.pm b/lib/RT/Action/CreateTicket.pm
index 6a924d4..4c9bc8c 100644
--- a/lib/RT/Action/CreateTicket.pm
+++ b/lib/RT/Action/CreateTicket.pm
@@ -16,7 +16,7 @@ use Jifty::Action schema {
param owner =>
render as 'RT::View::Form::Field::SelectUser',
# valid_values are queue-specific
- valid_values are lazy { RT->nobody->id },
+ valid_values are lazy { [ RT->nobody->id ] },
label is _('Owner');
param subject =>
diff --git a/lib/RT/Action/UpdateTicket.pm b/lib/RT/Action/UpdateTicket.pm
index f6d55fb..437e179 100644
--- a/lib/RT/Action/UpdateTicket.pm
+++ b/lib/RT/Action/UpdateTicket.pm
@@ -16,7 +16,7 @@ use Jifty::Action schema {
param owner =>
render as 'RT::View::Form::Field::SelectUser',
# valid_values are queue-specific
- valid_values are lazy { RT->nobody->id },
+ valid_values are lazy { [ RT->nobody->id ] },
label is _('Owner');
param subject =>
commit 28b85df66423f8855ef9a0ab1d3cabb9dec214f8
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Fri Jan 15 14:42:47 2010 -0500
Better id-plucking logic for action results
diff --git a/share/html/Ticket/Display.html b/share/html/Ticket/Display.html
index b2871f8..a9731fd 100755
--- a/share/html/Ticket/Display.html
+++ b/share/html/Ticket/Display.html
@@ -95,8 +95,15 @@ $collapsed => undef
<%INIT>
-$id ||= Jifty->web->response->result('create_ticket')->content('id')
- || Jifty->web->response->result('modify_ticket')->content('id');
+# if the user didn't pass in an id, guess it based on action results
+if (!$id) {
+ if (my $create_result = Jifty->web->response->result('create_ticket')) {
+ $id = $create_result->content('id')
+ }
+ elsif (my $modify_result = Jifty->web->response->result('modify_ticket')) {
+ $id = $modify_result->content('id')
+ }
+}
$m->callback( ticket_obj => $ticket_obj, args_ref => \%ARGS, callback_name => 'Initial' );
commit d77ae5221dd27e0372f861a8a4713a0f74f4ebdd
Merge: 28b85df 8b69e3b
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Fri Jan 15 15:14:41 2010 -0500
Merge branch '3.999-trunk' into update-action
commit b1b73c07636c4089ab7e5d32880552824dff160f
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Fri Jan 15 15:56:09 2010 -0500
Warn if we never find a queue for the queue-based action
diff --git a/lib/RT/Action/QueueBased.pm b/lib/RT/Action/QueueBased.pm
index 306734a..ca0146a 100644
--- a/lib/RT/Action/QueueBased.pm
+++ b/lib/RT/Action/QueueBased.pm
@@ -42,6 +42,10 @@ sub arguments {
$queue = $queue->[0] if ref $queue eq 'ARRAY';
$self->set_queue($queue);
}
+
+ if (!$queue) {
+ warn "No queue found for $self";
+ }
}
return $self->{_cached_arguments};
commit f184dfa1fbe788dcdf292b1d8f9ed2883b818b03
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Fri Jan 15 15:58:24 2010 -0500
Pluck the queue out of the record if we have one
diff --git a/lib/RT/Action/QueueBased.pm b/lib/RT/Action/QueueBased.pm
index ca0146a..852896a 100644
--- a/lib/RT/Action/QueueBased.pm
+++ b/lib/RT/Action/QueueBased.pm
@@ -35,17 +35,25 @@ sub arguments {
# after_set_queue to be called twice, and that leads to a lot of
# duplicate work and possibly duplicate data.
my $already_setting_queue = (caller(1))[3] eq __PACKAGE__.'::set_queue';
+
+ # if we have a queue argument, use it
my $action = Jifty->web->request->action($self->moniker);
my $queue = $action ? $action->argument('queue') : 0;
- if (!$already_setting_queue && $queue) {
- $queue = $queue->[0] if ref $queue eq 'ARRAY';
- $self->set_queue($queue);
+ # otherwise, try to pluck the queue from the record if we have one
+ if (!$queue && $self->can('record')) {
+ $queue = $self->record->queue_id;
}
if (!$queue) {
warn "No queue found for $self";
}
+
+ # run set_queue logic
+ if (!$already_setting_queue && $queue) {
+ $queue = $queue->[0] if ref $queue eq 'ARRAY';
+ $self->set_queue($queue);
+ }
}
return $self->{_cached_arguments};
commit 7931127e015708c5a9ac70334213491997bd85c9
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Fri Jan 15 16:00:48 2010 -0500
The moniker is modify_ticket not update_ticket
diff --git a/lib/RT/Dispatcher.pm b/lib/RT/Dispatcher.pm
index 6a38504..474c9a2 100644
--- a/lib/RT/Dispatcher.pm
+++ b/lib/RT/Dispatcher.pm
@@ -748,7 +748,7 @@ on '/ticket/create' => run {
};
on '/ticket/modify' => run {
- my $action = Jifty->web->request->action('update_ticket');
+ my $action = Jifty->web->request->action('modify_ticket');
my $id = $action ? $action->argument('id') : get('id');
if (!defined($id)) {
die "no ticket selected";
commit 2ecfca5748cc60a0614ae31adf3d6ce09c64a915
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Fri Jan 15 16:05:48 2010 -0500
Don't cache the combined arguments for now
diff --git a/lib/RT/Action/UpdateTicket.pm b/lib/RT/Action/UpdateTicket.pm
index 437e179..8218ca1 100644
--- a/lib/RT/Action/UpdateTicket.pm
+++ b/lib/RT/Action/UpdateTicket.pm
@@ -28,19 +28,16 @@ use Jifty::Action schema {
sub arguments {
my $self = shift;
- return $self->Jifty::Action::Record::Update::arguments(@_);
- if (!$self->{_cached_arguments}) {
- my $ticket_args = $self->RT::Action::TicketAction::arguments(@_);
- my $update_args = $self->Jifty::Action::Record::Update::arguments(@_);
+ my $update_args = $self->Jifty::Action::Record::Update::arguments(@_);
+ my $ticket_args = $self->RT::Action::TicketAction::arguments(@_);
- $self->{_cached_arguments} = Jifty::Param::Schema::merge_params(
- $update_args,
- $ticket_args,
- );
- }
+ my $combined_args = Jifty::Param::Schema::merge_params(
+ $update_args,
+ $ticket_args,
+ );
- return $self->{_cached_arguments};
+ return $combined_args;
}
sub _valid_statuses {
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list