[Bps-public-commit] r18492 - in Net-Google-Code/branches/write: .

sunnavy at bestpractical.com sunnavy at bestpractical.com
Fri Feb 20 03:48:08 EST 2009


Author: sunnavy
Date: Fri Feb 20 03:48:07 2009
New Revision: 18492

Modified:
   Net-Google-Code/branches/write/   (props changed)
   Net-Google-Code/branches/write/lib/Net/Google/Code/Issue.pm

Log:
 r20002 at sunnavys-mb:  sunnavy | 2009-02-20 16:47:53 +0800
 add files support for creating and updating issues


Modified: Net-Google-Code/branches/write/lib/Net/Google/Code/Issue.pm
==============================================================================
--- Net-Google-Code/branches/write/lib/Net/Google/Code/Issue.pm	(original)
+++ Net-Google-Code/branches/write/lib/Net/Google/Code/Issue.pm	Fri Feb 20 03:48:07 2009
@@ -154,11 +154,19 @@
     $self->sign_in;
     $self->fetch( 'issues/entry' );
 
-    $self->mech->form_with_fields( 'comment', 'summary' );
+    if ( $args{files} ) {
+# hack hack hack
+# manually add file fields since we don't have them in page.
+        my $html = $self->mech->content;
+        for ( 1 .. @{$args{files}} ) {
+            $html =~
+s{(?<=id="attachmentareadeventry"></div>)}{<input name="file$_" type="file">};
+        }
+        $self->mech->update_html( $html );
+    }
 
+    $self->mech->form_with_fields( 'comment', 'summary' );
     $self->mech->field( 'label', $args{labels} );
-
-    # the page doesn't have any file field yet :/
     if ( $args{files} ) {
         for ( my $i = 0; $i < scalar @{ $args{files} }; $i++ ) {
             $self->mech->field( 'file' . ($i + 1), $args{files}[$i] );
@@ -208,11 +216,19 @@
     $self->sign_in;
     $self->fetch( 'issues/detail?id=' . $self->id );
 
-    $self->mech->form_with_fields( 'comment', 'summary' );
+    if ( $args{files} ) {
+# hack hack hack
+# manually add file fields since we don't have them in page.
+        my $html = $self->mech->content;
+        for ( 1 .. @{$args{files}} ) {
+            $html =~
+s{(?<=id="attachmentarea"></div>)}{<input name="file$_" type="file">};
+        }
+        $self->mech->update_html( $html );
+    }
 
+    $self->mech->form_with_fields( 'comment', 'summary' );
     $self->mech->field( 'label', $args{labels} );
-
-    # the page doesn't have any file field yet :/
     if ( $args{files} ) {
         for ( my $i = 0; $i < scalar @{ $args{files} }; $i++ ) {
             $self->mech->field( 'file' . ($i + 1), $args{files}[$i] );



More information about the Bps-public-commit mailing list