ssafronova (ssafronova) wrote in changelog,
ssafronova
ssafronova
changelog

[livejournal] r16148: LJSUP-5453: "Gender" option

Committer: ssafronova
LJSUP-5453: "Gender" option
code based on simplified patch from LJSUP-5276 by Vadim
U   trunk/bin/upgrading/en.dat
U   trunk/cgi-bin/LJ/Widget/CreateAccount.pm
U   trunk/cgi-bin/LJ/Widget/CreateAccountProfile.pm
Modified: trunk/bin/upgrading/en.dat
===================================================================
--- trunk/bin/upgrading/en.dat	2010-01-27 09:47:30 UTC (rev 16147)
+++ trunk/bin/upgrading/en.dat	2010-01-27 09:47:35 UTC (rev 16148)
@@ -3337,6 +3337,8 @@
 
 widget.createaccount.error.email.lj_domain=You cannot use a [[domain]] alias when creating an account.  Please enter a different email address.
 
+widget.createaccount.error.nogender=You can not leave this field blank, please choose some option.
+
 widget.createaccount.error.password.asciionly=You can only use ASCII symbols in the password.
 
 widget.createaccount.error.password.bad=Bad password:
@@ -3355,6 +3357,8 @@
 
 widget.createaccount.field.birthdate=Birthdate:
 
+widget.createaccount.field.gender=Gender:
+
 widget.createaccount.field.captcha=Prove you're human:
 
 widget.createaccount.field.captcha.hear=Type the numbers you hear:
@@ -3383,6 +3387,8 @@
 
 widget.createaccount.tip.captcha=If you can't read the text, type "audio" to take a sound test instead.
 
+widget.createaccount.tip.gender=We do not show your gender to anybody.
+
 widget.createaccount.tip.email=We need your email address to send important information. We will never share or sell your email address.
 
 widget.createaccount.tip.password=Choose a secure password that is at least 6 characters long. Passwords cannot be based on your username, name, or email address.

Modified: trunk/cgi-bin/LJ/Widget/CreateAccount.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/CreateAccount.pm	2010-01-27 09:47:30 UTC (rev 16147)
+++ trunk/cgi-bin/LJ/Widget/CreateAccount.pm	2010-01-27 09:47:35 UTC (rev 16148)
@@ -43,9 +43,10 @@
     $ret .= $class->start_form(%{$opts{form_attr}});
 
     my $tip_birthdate = LJ::ejs($class->ml('widget.createaccount.tip.birthdate2'));
-    my $tip_email = LJ::ejs($class->ml('widget.createaccount.tip.email'));
-    my $tip_password = LJ::ejs($class->ml('widget.createaccount.tip.password'));
-    my $tip_username = LJ::ejs($class->ml('widget.createaccount.tip.username'));
+    my $tip_email     = LJ::ejs($class->ml('widget.createaccount.tip.email'));
+    my $tip_password  = LJ::ejs($class->ml('widget.createaccount.tip.password'));
+    my $tip_username  = LJ::ejs($class->ml('widget.createaccount.tip.username'));
+    my $tip_gender    = LJ::ejs($class->ml('widget.createaccount.tip.gender'));
 
     # tip module
     if ($alt_layout) {
@@ -58,6 +59,7 @@
         $ret .= "CreateAccount.email = \"$tip_email\"\n";
         $ret .= "CreateAccount.password = \"$tip_password\"\n";
         $ret .= "CreateAccount.username = \"$tip_username\"\n";
+        $ret .= "CreateAccount.gender   = \"$tip_gender\"\n";
         $ret .= "</script>\n";
         $ret .= "<div id='tips_box_arrow'></div>";
         $ret .= "<div id='tips_box'></div>";
@@ -153,6 +155,32 @@
     $ret .= $error_msg->('confirmpass', '<br /><span class="formitemFlag">', '</span>');
     $ret .= "</td></tr>\n" unless $alt_layout;
 
+
+    ### gender
+    if ($alt_layout){
+        $ret .= "<label for='create_gender_mm' class='label_create'>" . $class->ml('widget.createaccount.field.gender') . "</label>";
+        $ret .= "<div class='bubble' id='bubble_gender'>";
+        $ret .= "<div class='bubble-arrow'></div>";
+        $ret .= "<div class='bubble-text'>$tip_gender</div>";
+        $ret .= "</div>";
+    } else {
+        $ret .= "<tr><td class='field-name'>" . $class->ml('widget.createaccount.field.gender') . "</td>\n<td>";
+    }
+    $ret .= $class->html_select(
+                name => "gender",
+                id => "create_gender",
+                selected => $post->{gender},
+                list => [ 
+                    '' => '',
+                    'U' =>  LJ::Lang::ml("/manage/profile/index.bml.gender.unspecified"),
+                    'M' =>  LJ::Lang::ml("/manage/profile/index.bml.gender.male"),
+                    'F' =>  LJ::Lang::ml("/manage/profile/index.bml.gender.female"),
+                    ],
+                ) . " ";
+    $ret .= $error_msg->('gender', '<br /><span class="formitemFlag">', '</span>');
+    $ret .= "</td></tr>\n" unless $alt_layout;
+    
+
     ### birthdate
     if ($LJ::COPPA_CHECK) {
         if ($alt_layout) {
@@ -428,6 +456,10 @@
         $from_post{errors}->{password} = $class->ml('widget.createaccount.error.password.asciionly');
     }
 
+    ### gender check
+    $from_post{errors}->{gender} = $class->ml('widget.createaccount.error.nogender')
+        unless $post->{gender} =~ /^M|F|U$/;
+
     ### start COPPA_CHECK
     # age checking to determine how old they are
     if ($LJ::COPPA_CHECK) {
@@ -518,6 +550,9 @@
         );
         return $class->ml('widget.createaccount.error.cannotcreate') unless $nu;
 
+        # set gender
+        $nu->set_prop(gender => $post->{gender});
+
         if ($LJ::HUMAN_CHECK{create} && !LJ::is_enabled("recaptcha")) {
             # mark the captcha for deletion
             LJ::Captcha::expire($capid, $anum, $nu->id);

Modified: trunk/cgi-bin/LJ/Widget/CreateAccountProfile.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/CreateAccountProfile.pm	2010-01-27 09:47:30 UTC (rev 16147)
+++ trunk/cgi-bin/LJ/Widget/CreateAccountProfile.pm	2010-01-27 09:47:35 UTC (rev 16148)
@@ -54,20 +54,6 @@
     $ret .= $error_msg->('name', '<br /><span class="formitemFlag">', '</span>');
     $ret .= "</td></tr>\n";
 
-    ### gender
-    $ret .= "<tr valign='middle'><td class='field-name'>" . $class->ml('widget.createaccountprofile.field.gender') . "</td>\n<td>";
-    $ret .= $class->html_select(
-        name => 'gender',
-        selected => $post->{gender} || $u->prop('gender'),
-        list => [
-            U => LJ::Lang::ml('/manage/profile/index.bml.gender.unspecified'),
-            M => LJ::Lang::ml('/manage/profile/index.bml.gender.male'),
-            F => LJ::Lang::ml('/manage/profile/index.bml.gender.female'),
-        ],
-    );
-    $ret .= $error_msg->('gender', '<br /><span class="formitemFlag">', '</span>');
-    $ret .= "</td></tr>\n";
-
     ### location
     my %countries;
     LJ::load_codes({ "country" => \%countries});
@@ -205,9 +191,6 @@
     $post->{name} =~ s/[\n\r]//g;
     $post->{name} = LJ::text_trim($post->{name}, LJ::BMAX_NAME, LJ::CMAX_NAME);
 
-    # gender
-    $post->{gender} = 'U' unless $post->{gender} =~ m/^[UMF]$/;
-
     # location is handled by LJ::Widget::Location
 
     # interests
@@ -244,7 +227,6 @@
     unless (keys %{$from_post{errors}}) {
         LJ::update_user($u, { name => $post->{name} });
         $u->invalidate_directory_record;
-        $u->set_prop('gender', $post->{gender});
         $u->set_interests($old_interests, \@valid_ints);
         $u->set_bio($post->{bio}, $post->{bio_absent});
     }

Tags: dat, livejournal, pm, ssafronova
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments