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

? sunnavy sunnavy at bestpractical.com
Tue Apr 13 11:06:29 EDT 2010


The branch, 3.999-trunk has been updated
       via  be7a8d2095615819798ebcc4184c35570817ae1d (commit)
       via  39941906582d83a8a8586bd315c7276de8113e6f (commit)
      from  e1f0850e5ede3b9c2c0ef9d6ec486afb561e877d (commit)

Summary of changes:
 lib/RT/Action/RenewTicket.pm |  100 ++++++++++++++++++++++++++++++++++++++++++
 lib/RT/Dispatcher.pm         |   24 ++++++++++
 lib/RT/View/Ticket.pm        |    3 +
 3 files changed, 127 insertions(+), 0 deletions(-)
 create mode 100644 lib/RT/Action/RenewTicket.pm

- Log -----------------------------------------------------------------
commit 39941906582d83a8a8586bd315c7276de8113e6f
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Apr 13 22:51:29 2010 +0800

    add RenewTicket action

diff --git a/lib/RT/Action/RenewTicket.pm b/lib/RT/Action/RenewTicket.pm
new file mode 100644
index 0000000..3c0888f
--- /dev/null
+++ b/lib/RT/Action/RenewTicket.pm
@@ -0,0 +1,100 @@
+package RT::Action::RenewTicket;
+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');
+
+    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 worked =>
+        render as 'text',
+        label is _('Worked(in minutes)');
+
+    param subject =>
+        render as 'text',
+        display_length is 60,
+        max_length is 200,
+        label is _('Subject');
+
+    param one_time_cc => 
+        render as 'text',
+        label is _('One-time Cc');
+    param one_time_bcc => 
+        render as 'text',
+        label is _('One-time Bcc');
+    param content => 
+        render as 'textarea',
+        label is _('Message');
+    param attachments => 
+        render as 'Uploads',
+        label is _('Attachments');
+};
+
+sub _valid_statuses {
+    my $self = shift;
+
+    my $record = $self->record;
+    return (
+        $record->status,
+        $record->queue->status_schema->transitions($record->status),
+    );
+}
+
+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 =>
+                'CommentOoTicket', 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;
+            }
+        }
+    }
+
+    # XXX reply/comment
+
+    return 1;
+}
+
+1;

commit be7a8d2095615819798ebcc4184c35570817ae1d
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Apr 13 22:52:01 2010 +0800

    jiftify /ticket/update

diff --git a/lib/RT/Dispatcher.pm b/lib/RT/Dispatcher.pm
index 2f2e221..9d004b2 100644
--- a/lib/RT/Dispatcher.pm
+++ b/lib/RT/Dispatcher.pm
@@ -497,6 +497,18 @@ before 'admin/' => run {
       if $custom_field;
 };
 
+before 'Ticket/Display.html' => run {
+    my @monikers = qw/update_ticket/;
+    for my $action ( Jifty->web->request->actions ) {
+        if ( grep { $action->moniker eq $_ } @monikers ) {
+            if ( $action->argument('id') ) {
+                set( id => $action->argument('id') );
+                last;
+            }
+        }
+    }
+};
+
 before 'admin/queues' => run {
     if ( Jifty->web->current_user->has_right( object => RT->system, right => 'AdminQueue' ) ) {
         page_nav->child( _('Select'), url => "/admin/queues/" );
@@ -891,6 +903,18 @@ on '/ticket/modify' => run {
     }
 };
 
+on '/ticket/update' => 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 {
+        set(id => $id);
+        show '/ticket/update';
+    }
+};
+
 # 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 fde2d30..5ed02d9 100644
--- a/lib/RT/View/Ticket.pm
+++ b/lib/RT/View/Ticket.pm
@@ -62,5 +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 '/';
+
 1;
 

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


More information about the Rt-commit mailing list