[Rt-commit] rt branch, create-action, updated. 67ff7341864fb625683e7082293fb2f86a6e2ca8

sartak at bestpractical.com sartak at bestpractical.com
Tue Nov 17 19:04:06 EST 2009


The branch, create-action has been updated
       via  67ff7341864fb625683e7082293fb2f86a6e2ca8 (commit)
      from  1e8e66ac79bffe5431ee94542ed1dfeb89d1aedc (commit)

Summary of changes:
 lib/RT/Action/CreateTicket.pm |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

- Log -----------------------------------------------------------------
commit 67ff7341864fb625683e7082293fb2f86a6e2ca8
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Tue Nov 17 19:03:38 2009 -0500

    Steal some attachment handling code from Hiveminder
    
        Clearly Jifty needs to get better about this :)

diff --git a/lib/RT/Action/CreateTicket.pm b/lib/RT/Action/CreateTicket.pm
index a36d94f..9beb40a 100644
--- a/lib/RT/Action/CreateTicket.pm
+++ b/lib/RT/Action/CreateTicket.pm
@@ -26,7 +26,7 @@ use Jifty::Action schema {
         max_length is 200,
         label is _('Subject');
 
-    param attachments =>
+    param attachment =>
         render as 'upload',
         label is _('Attach file');
 
@@ -189,6 +189,24 @@ sub set_final_priority {
     $self->fill_parameter(final_priority => default_value => $queue->final_priority);
 }
 
+sub take_action {
+    my $self = shift;
+    my $fh = $self->argument_value('attachment');
+    $self->argument_value(attachment_filename => "$fh");
+
+    my $info = Jifty->handler->cgi->uploadInfo( $fh );
+    $self->argument_value(attachment_content_type => $info->{'Content-Type'})
+        if defined $info;
+
+    my $ret = $self->SUPER::take_action( @_ );
+
+    # Kill file handle so it's not in the session or request
+    $self->argument_value(attachment => '');
+    Jifty->web->request->delete('J:A:F-attachment-'.$self->moniker);
+
+    return $ret;
+}
+
 sub report_success {
     my $self = shift;
     my $id = $self->record->id;

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


More information about the Rt-commit mailing list