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

[dw-free] create new promo code should have 'active' box checked

[commit: http://hg.dwscoalition.org/dw-free/rev/4e2142c9613b]

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

Check the "active" box by default when creating a new promo code, and save
state properly through page loads.

Patch by [personal profile] rb.

Files modified:
  • htdocs/admin/invites/promo.bml
--------------------------------------------------------------------------------
diff -r 9b6f4fa5ccc3 -r 4e2142c9613b htdocs/admin/invites/promo.bml
--- a/htdocs/admin/invites/promo.bml	Mon Sep 12 15:45:20 2011 +0800
+++ b/htdocs/admin/invites/promo.bml	Mon Sep 12 15:52:33 2011 +0800
@@ -34,6 +34,7 @@
         my $data = $_[0] || {};
         my $errors = $_[1] || {};
         my $suggest_u = ( $data && $data->{suggest_journalid} ) ? LJ::load_userid($data->{suggest_journalid}) : undef;
+        my $active = ( defined $data->{active} ) ? $data->{active} : 1;
 
         if ( $state eq 'create' ) {
             $title = $ML{'.title.create'};
@@ -46,7 +47,7 @@
         $ret .= "<form method='POST' action='/admin/invites/promo'>";
         $ret .= LJ::form_auth();
         $ret .= LJ::html_hidden( { name => 'state', value => $state });
-        $ret .= LJ::html_check( { id => 'active', name => 'active', value => 1, selected => $data->{active}, label => $ML{'.field.active.label'} } );
+        $ret .= LJ::html_check( { id => 'active', name => 'active', value => 0, selected => $active, label => $ML{'.field.active.label'} } );
         $ret .= "  <strong>[$ML{'.error.label'} " . join(', ', @{$errors->{active}}) . "]</strong>" if $errors->{active};
         $ret .= '<br />';
         if ( $state eq 'create' ) {
@@ -97,7 +98,7 @@
         $state = lc( $POST{state} || "" );
         if ( $state eq 'create' ) {
             my $data = {
-                active => $POST{active} ? 1 : 0,
+                active => defined( $POST{active} ) ? 1 : 0,
                 code => $code,
                 current_count => 0,
                 max_count => $POST{max_count} || 0,
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org