fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-10-31 10:10 am

[dw-free] Revamp /update

[commit: http://hg.dwscoalition.org/dw-free/rev/42ca88afc4ea]

http://bugs.dwscoalition.org/show_bug.cgi?id=2524

Don't print the form after we have posted successfuly.

Patch by [personal profile] fu.

Files modified:
  • cgi-bin/DW/Controller/Entry.pm
--------------------------------------------------------------------------------
diff -r 6ab982a2e912 -r 42ca88afc4ea cgi-bin/DW/Controller/Entry.pm
--- a/cgi-bin/DW/Controller/Entry.pm	Mon Oct 31 17:49:19 2011 +0800
+++ b/cgi-bin/DW/Controller/Entry.pm	Mon Oct 31 18:10:52 2011 +0800
@@ -137,6 +137,7 @@
             # if we didn't have any errors with decoding the form, proceed to post
             unless ( @error_list ) {
                 my %post_res = _do_post( $form_req, $flags, \%auth, warnings => \@warnings );
+                return $post_res{render} if $post_res{status} eq "ok";
 
                 # oops errors when posting: show error, fall through to show form
                 push @error_list, $post_res{errors} if $post_res{errors};
@@ -634,6 +635,7 @@
     _persist_props( $auth->{poster}, $form_req );
 
     my $ret = "";
+    my $render_ret;
     my @links;
     my @crossposts;
 
@@ -643,7 +645,7 @@
     # special-case moderated: no itemid, but have a message
     if ( ! defined $res->{itemid} && $res->{message} ) {
         $ret .= qq{<div class="message-box info-box"><p>$res->{message}</p></div>};
-        DW::Template->render_template(
+        $render_ret = DW::Template->render_template(
             'entry-success.tt', {
                 poststatus  => $ret,
             }
@@ -737,7 +739,7 @@
             }
         }
 
-        DW::Template->render_template(
+        $render_ret = DW::Template->render_template(
             'entry-success.tt', {
                 poststatus  => $ret,        # did the update succeed or fail?
                 warnings    => \@warnings,   # warnings about the entry or your account
@@ -747,7 +749,7 @@
         );
     }
 
-    return ( status => "ok" );
+    return ( status => "ok", render => $render_ret );
 }
 
 # remember value of properties, to use the next time the user makes a post
--------------------------------------------------------------------------------