[Yapcom checkin] rev 56 - lib/YAPC

[prev] [thread] [next] [lurker] [Date index for 2003/11/26]

From: svn
Subject: [Yapcom checkin] rev 56 - lib/YAPC
Date: 12:04 on 26 Nov 2003
Author: jon
Date: 2003-11-26 12:04:40 +0200 (Wed, 26 Nov 2003)
New Revision: 56

Modified:
   lib/YAPC/Organizer.pm
Log:
 added comment, reorganized code

Modified: lib/YAPC/Organizer.pm
===================================================================
--- lib/YAPC/Organizer.pm	2003-11-26 09:57:26 UTC (rev 55)
+++ lib/YAPC/Organizer.pm	2003-11-26 10:04:40 UTC (rev 56)
@@ -169,17 +169,19 @@
     my $t = $self->_server_page('lost_validation');
     my $person;
 
-    if ($q->param('submit')) {
-       eval {
-          ($person) = YAPC::Person->search(email =>  $q->param('email'));
-       };
-       if ($@ or not $person) {
-           $t->param(MESSAGE => 'No such e-mail');
-           return $t->output;
-       } else {
-       }
-    } else {
-       return $t->output;
+# The logic here is that the page 'lost_validation' is used when
+# displaying the page to get your lost validation, and also after submitting
+# the page to get your lost validation. If 'submit' is not present, we
+# display the form, otherwise, we process the results.
+    return $t->output unless $q->param('submit');
+
+    eval {
+       ($person) = YAPC::Person->search(email =>  $q->param('email'));
+    };
+
+    if ($@ or not $person) {
+        $t->param(MESSAGE => 'No such e-mail');
+        return $t->output;
     }
 
     # OK
@@ -199,18 +201,16 @@
 
     my $t = $self->_server_page('lost_password');
 
+# See logic in &lost_validation
+    return $t->output unless $q->param('submit');
+
     my $person;
-    if ($q->param('submit')) {
-       eval {
-          ($person) = YAPC::Person->search(email =>  $q->param('email'));
-       };
-       if ($@ or not $person) {
-           $t->param(MESSAGE => 'No such e-mail');
-           return $t->output;
-       } else {
-       }
-    } else {
-       return $t->output;
+    eval {
+       ($person) = YAPC::Person->search(email =>  $q->param('email'));
+    };
+    if ($@ or not $person) {
+        $t->param(MESSAGE => 'No such e-mail');
+        return $t->output;
     }
 
     # OK
@@ -382,21 +382,22 @@
     my $t = $self->_server_page('login');
     my $login;
 
-    if ($q->param('submit')) {
-       eval {
-         $login = YAPC::Login->new($q->Vars);
-       };
-       if ($@) {
-         my $msg = $@;
-         $t->param(MESSAGE => 'Login failed.');
-         return $t->output;
-       }
-    } else { # first time on this page
+# See logic in &lost_validation
+    unless ($q->param('submit')) {
        $t->param('next' => $self->param('yapcom_next_page')) if $self->param('yapcom_next_page');
        return $t->output;
     }
 
+    eval {
+      $login = YAPC::Login->new($q->Vars);
+    };
 
+    if ($@) {
+      my $msg = $@;
+      $t->param(MESSAGE => 'Login failed.');
+      return $t->output;
+    }
+
     # success
     my $path = $ENV{REQUEST_URI};
     $path =~ s@[^/]*$@@; # remove everything after last /
@@ -441,19 +442,19 @@
 
     my $t = $self->_server_page('registration');
     my $person;
-    if ($q->param('submit')) {
-       eval {
-          $person = YAPC::Person->new($q->Vars);
-       };
-       if ($@) {
-          my $msg = $@;
-          # cannot register (duplicate email ?, other problem ?)
-          $t->param(MESSAGE => 'There was an error in the provided data.');
-          return $t->output;
-        } else {
-        }
-     } else { # first time on this page
-        return $t->output;
+
+# See logic in &lost_validation
+    return $t->output unless $q->param('submit');
+
+    eval {
+       $person = YAPC::Person->new($q->Vars);
+    };
+
+    if ($@) {
+       my $msg = $@;
+       # cannot register (duplicate email ?, other problem ?)
+       $t->param(MESSAGE => 'There was an error in the provided data.');
+       return $t->output;
      }
 
      # success
@@ -506,16 +507,16 @@
 
     my $t = $self->_server_page('proposal');
 
-    if ($q->param('submit')) {
-       eval {
-         $talk = YAPC::Talk->propose($q->Vars, user_id => $id);
-       };
-       if ($@) {
-          my $msg = $@;
-          $t->param(MESSAGE => 'There was an error in the provided data.');
-          return $self->_build_prop_page($t);
-       }
-    } else {  # first time on this page
+# See logic in &lost_validation
+    return $self->_build_prop_page($t) unless $q->param('submit');
+
+    eval {
+      $talk = YAPC::Talk->propose($q->Vars, user_id => $id);
+    };
+
+    if ($@) {
+       my $msg = $@;
+       $t->param(MESSAGE => 'There was an error in the provided data.');
        return $self->_build_prop_page($t);
     }
 

Generated at 13:06 on 26 Nov 2003 by mariachi 0.51