[Rt-commit] rt branch, 3.999-trunk, updated. e0a15cffcf66c4342c8f28d0862bbae3f42a21e1

? sunnavy sunnavy at bestpractical.com
Wed Apr 14 04:57:41 EDT 2010


The branch, 3.999-trunk has been updated
       via  e0a15cffcf66c4342c8f28d0862bbae3f42a21e1 (commit)
       via  20a853994d83d3d34c1f2e4d7dcd14e7e397be79 (commit)
       via  d82ac235763ea3b39ce29cc70c91bef5a5a53e16 (commit)
       via  ea38d9ce76b3182c04711b81fb0bad28f575941e (commit)
      from  eab79e3283c7083ea3aef1a3e207055e8e014969 (commit)

Summary of changes:
 lib/RT/Action/CommentOnTicket.pm           |    8 +++
 lib/RT/Action/ReplyToTicket.pm             |   88 +++++++++++++++++----------
 lib/RT/Action/TicketAction.pm              |    5 +-
 lib/RT/Dispatcher.pm                       |   20 +++++-
 lib/RT/Interface/Web.pm                    |    9 +--
 lib/RT/View/Ticket.pm                      |    4 +-
 lib/RT/View/Ticket/{Update.pm => Reply.pm} |   48 ++++++++++++---
 7 files changed, 127 insertions(+), 55 deletions(-)
 create mode 100644 lib/RT/Action/CommentOnTicket.pm
 copy lib/RT/View/Ticket/{Update.pm => Reply.pm} (66%)

- Log -----------------------------------------------------------------
commit ea38d9ce76b3182c04711b81fb0bad28f575941e
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Apr 14 16:51:25 2010 +0800

    small fix

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 3fb0226..87a7ffc 100755
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -417,11 +417,10 @@ is true.
 =cut
 
 sub process_update_message {
-
     my %args = (
         args_ref          => undef,
         ticket_obj        => undef,
-        SkipSignatureOnly => 1,
+        skip_signature_only => 1,
         @_
     );
 
@@ -504,10 +503,10 @@ sub process_update_message {
         time_taken     => $args{args_ref}->{'update_time_worked'}
     );
 
-    unless ( $args{'args_ref'}->{'UpdateIgnoreAddressCheckboxes'} ) {
+    unless ( $args{'args_ref'}->{'update_ignore_address_checkboxes'} ) {
         
         foreach my $key ( keys %{ $args{args_ref} } ) {
-            next unless $key =~ /^Update(cc|Bcc)-(.*)$/;
+            next unless $key =~ /^update_(cc|bcc)-(.*)$/;
 
             my $var   = ucfirst($1) . 'MessageTo';
             my $value = $2;
@@ -520,7 +519,7 @@ sub process_update_message {
     }
 
     my @results;
-    if ( $args{args_ref}->{'update_type'} =~ /^(private|public)$/ ) {
+    if ( $args{args_ref}->{'update_type'} =~ /^(private|public|comment)$/ ) {
         my ( $Transaction, $description, $object ) = $args{ticket_obj}->comment(%message_args);
         push( @results, $description );
         $object->update_custom_fields( %{ $args{args_ref} } ) if $object;

commit d82ac235763ea3b39ce29cc70c91bef5a5a53e16
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Apr 14 16:52:41 2010 +0800

    /ticket/reply and /ticket/comment view

diff --git a/lib/RT/View/Ticket.pm b/lib/RT/View/Ticket.pm
index 5ed02d9..14c1906 100644
--- a/lib/RT/View/Ticket.pm
+++ b/lib/RT/View/Ticket.pm
@@ -62,8 +62,8 @@ alias RT::View::Ticket::Create under '/';
 require RT::View::Ticket::Update;
 alias RT::View::Ticket::Update under '/';
 
-require RT::View::Ticket::Renew;
-alias RT::View::Ticket::Renew under '/';
+require RT::View::Ticket::Reply;
+alias RT::View::Ticket::Reply under '/';
 
 1;
 
diff --git a/lib/RT/View/Ticket.pm b/lib/RT/View/Ticket/Reply.pm
similarity index 60%
copy from lib/RT/View/Ticket.pm
copy to lib/RT/View/Ticket/Reply.pm
index 5ed02d9..c22ad1a 100644
--- a/lib/RT/View/Ticket.pm
+++ b/lib/RT/View/Ticket/Reply.pm
@@ -48,22 +48,57 @@
 use warnings;
 use strict;
 
-package RT::View::Ticket;
+package RT::View::Ticket::Reply;
 use Jifty::View::Declare -base;
 
 __PACKAGE__->use_mason_wrapper;
 
-require RT::View::Ticket::Links;
-alias RT::View::Ticket::Links under '/';
+template 'reply' => page { title => _('Reply to ticket') } content {
+    my $id     = get('id');
+    my $ticket = RT::Model::Ticket->new;
+    $ticket->load($id);
 
-require RT::View::Ticket::Create;
-alias RT::View::Ticket::Create under '/';
+    my $action = new_action(
+        class   => 'ReplyToTicket',
+        moniker => 'reply_to_ticket',
+        record  => $ticket,
+    );
 
-require RT::View::Ticket::Update;
-alias RT::View::Ticket::Update under '/';
+    with( name => 'ticket_reply' ), form {
+        form_next_page url => '/Ticket/Display.html';
 
-require RT::View::Ticket::Renew;
-alias RT::View::Ticket::Renew under '/';
+        render_action(
+            $action,
+            [
+                qw/id status owner time_worked subject cc bcc
+                  attachments content/
+            ]
+        );
+        form_submit( label => _('Reply To Ticket') );
+    };
+};
 
-1;
+template 'comment' => page { title => _('Comment on ticket') } content {
+    my $id = get('id');
+    my $ticket = RT::Model::Ticket->new;
+    $ticket->load($id);
+
+    my $action = new_action(
+        class   => 'CommentOnTicket',
+        moniker => 'comment_on_ticket',
+        record  => $ticket,
+    );
+
+    with ( name => 'ticket_comment' ), form {
+        form_next_page url => '/Ticket/Display.html';
+        render_action(
+            $action,
+            [
+                qw/id status owner time_worked subject cc bcc
+                  attachments content/
+            ]
+        );
+        form_submit( label => _('Comment On Ticket') );
+    };
+};
 

commit 20a853994d83d3d34c1f2e4d7dcd14e7e397be79
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Apr 14 16:53:33 2010 +0800

    update ticket reply/comment action

diff --git a/lib/RT/Action/CommentOnTicket.pm b/lib/RT/Action/CommentOnTicket.pm
new file mode 100644
index 0000000..608b4af
--- /dev/null
+++ b/lib/RT/Action/CommentOnTicket.pm
@@ -0,0 +1,8 @@
+package RT::Action::CommentOnTicket;
+use strict;
+use warnings;
+use base 'RT::Action::ReplyToTicket';
+
+sub type { 'comment' }
+
+1;
diff --git a/lib/RT/Action/ReplyToTicket.pm b/lib/RT/Action/ReplyToTicket.pm
index 9822247..4907ad6 100644
--- a/lib/RT/Action/ReplyToTicket.pm
+++ b/lib/RT/Action/ReplyToTicket.pm
@@ -2,19 +2,12 @@ package RT::Action::ReplyToTicket;
 use strict;
 use warnings;
 use base 'RT::Action::TicketAction', 'Jifty::Action::Record';
-
 use Jifty::Param::Schema;
 use Jifty::Action schema {
     param id =>
         render as 'hidden',
         is constructor;
 
-    param type =>
-        render as 'select',
-        available are [
-            map { { display => _($_), value => $_ } }
-                qw/correspond comment/ ],
-        label is _('Type');
     param status =>
         render as 'select',
         label is _('Status');
@@ -25,7 +18,7 @@ use Jifty::Action schema {
         valid_values are lazy { [ RT->nobody->id ] },
         label is _('Owner');
 
-    param worked =>
+    param time_worked =>
         render as 'text',
         label is _('Worked(in minutes)');
 
@@ -59,43 +52,72 @@ sub _valid_statuses {
     );
 }
 
+# XXX TODO 
+# sign, encrypt, content_type, transaction, signature, quote_transaction
+# attach_tickets, update_ignore_address_checkboxes, cf
 sub take_action {
     my $self = shift;
 
     my $record = $self->record;
     return unless $record && $record->id;
 
-    my $type = $self->argument_value('type');
-    return unless $type;
-
-    if (
-        (
-            $type eq 'correspond'
-            && Jifty->web->current_user->has_right( right => 'ReplyToTicket',
-                object => $record->queue )
-        )
-        || ( $type eq 'comment'
-            && Jifty->web->current_user->has_right( right =>
-                'CommentOnTicket', object => $record->queue )
-        )
-      )
-    {
-
-        # update basics
-        for my $field (qw/status owner/) {
-            my $method = "set_$field";
-            my $value  = $self->argument_value($field);
-            if ( $record->$field ne $value ) {
-                my ( $ret, $msg ) = $record->$method($value);
-                Jifty->log->error($msg) unless $ret;
-            }
+    # update basics
+    for my $field (qw/status owner/) {
+        my $method = "set_$field";
+        my $value  = $self->argument_value($field);
+        if (  $value ne ( ref $record->$field
+            ? $record->$field->id
+            : $record->$field ) )
+        {
+            my ( $ret, $msg ) = $record->$method($value);
+            Jifty->log->error($msg) unless $ret;
         }
     }
 
-    # XXX reply/comment
+    if ( my $worked = $self->argument_value('time_worked') ) {
+        my ( $ret, $msg ) =
+          $record->set_time_worked( $record->time_worked + $worked );
+        Jifty->log->error($msg) unless $ret;
+    }
 
+    my $attachments = $self->argument_value('attachments');
+    my %mime_atts;
+
+    if ($attachments) {
+        for my $att (
+            ref $attachments eq 'ARRAY'
+            ? @$attachments
+            : $attachments
+          )
+        {
+            my $filename = Encode::decode_utf8( $att->filename );
+            my $mime     = MIME::Entity->build(
+                Type    => 'multipart/mixed',
+                Subject => $filename,
+            );
+            $mime->attach(
+                Type     => $att->content_type,
+                Filename => $filename,
+                Data     => [ $att->content ],
+            );
+            $mime_atts{$filename} = $mime;
+        }
+    }
 
+    my @results = HTML::Mason::Commands::process_update_message(
+        ticket_obj => $record,
+        args_ref   => {
+            update_attachments => \%mime_atts,
+            update_type        => $self->type,
+            map { 'update_' . $_ => $self->argument_value($_) || '' }
+              qw/subject cc bcc content/,
+        },
+    );
+    $self->result->message(join ', ', @results);
     return 1;
 }
 
+sub type { 'response' }
+
+
 1;
diff --git a/lib/RT/Dispatcher.pm b/lib/RT/Dispatcher.pm
index 9d004b2..7edff86 100644
--- a/lib/RT/Dispatcher.pm
+++ b/lib/RT/Dispatcher.pm
@@ -498,7 +498,7 @@ before 'admin/' => run {
 };
 
 before 'Ticket/Display.html' => run {
-    my @monikers = qw/update_ticket/;
+    my @monikers = qw/reply_to_ticket comment_on_ticket/;
     for my $action ( Jifty->web->request->actions ) {
         if ( grep { $action->moniker eq $_ } @monikers ) {
             if ( $action->argument('id') ) {
@@ -903,15 +903,27 @@ on '/ticket/modify' => run {
     }
 };
 
-on '/ticket/update' => run {
-    my $action = Jifty->web->request->action('update_ticket');
+on '/ticket/reply' => run {
+    my $action = Jifty->web->request->action('reply_to_ticket');
     my $id = $action ? $action->argument('id') : get('id');
     if (!defined($id)) {
         die "no ticket selected";
     }
     else {
         set(id => $id);
-        show '/ticket/update';
+        show '/ticket/reply';
+    }
+};
+
+on '/ticket/comment' => run {
+    my $action = Jifty->web->request->action('comment_on_ticket');
+    my $id = $action ? $action->argument('id') : get('id');
+    if (!defined($id)) {
+        die "no ticket selected";
+    }
+    else {
+        set(id => $id);
+        show '/ticket/comment';
     }
 };
 

commit e0a15cffcf66c4342c8f28d0862bbae3f42a21e1
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Apr 14 16:57:34 2010 +0800

    call parse_duration only when need to do, or our plain minutes will be treated as seconds

diff --git a/lib/RT/Action/TicketAction.pm b/lib/RT/Action/TicketAction.pm
index a014b5b..0b3071a 100644
--- a/lib/RT/Action/TicketAction.pm
+++ b/lib/RT/Action/TicketAction.pm
@@ -194,8 +194,9 @@ __PACKAGE__->_add_parameter_type(
     canonicalizer => sub {
         my $self  = shift;
         my $value = shift;
-
-        if ($value) {
+        $value =~ s/^\s+//;
+        $value =~ s/\s+$//;
+        if ($value && $value =~ /\D/ ) {
             # parse_duration gives seconds, we want minutes
             $value = int(parse_duration($value) / 60);
         }

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


More information about the Rt-commit mailing list