LP1207396 Patron self-registration web form
authorBill Erickson <berick@esilibrary.com>
Tue, 6 Aug 2013 15:48:32 +0000 (11:48 -0400)
committerBill Erickson <berick@esilibrary.com>
Tue, 6 Aug 2013 15:48:32 +0000 (11:48 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Register.pm
Open-ILS/src/templates/opac/register.tt2

index 661b575..de7dee7 100644 (file)
@@ -38,14 +38,26 @@ sub load_patron_reg {
         $user->$_($val);
     }
 
+    # make sure the selected home org unit is in the list 
+    # of valid orgs.  This can happen if the selector 
+    # defaults to CONS, for example.
+    $ctx->{register}{invalid}{bad_home_ou} = 1 unless
+        grep {$_ eq $user->home_ou} @{$ctx->{register}{valid_orgs}};
+
     # address
+    my $has_addr = 0;
     foreach (grep /^stgma\./, $cgi->param) {
         my $val = $cgi->param($_);
         $self->inspect_register_value($_, $val);
         s/^stgma\.//g;
         $addr->$_($val);
+        $has_addr = 1;
     }
 
+    # if the form contains no address fields, do not 
+    # attempt to create a pending address
+    $addr = undef unless $has_addr;
+
     # At least one value was invalid. Exit early and re-render.
     return Apache2::Const::OK if $ctx->{register}{invalid};
 
index 46c353e..f87c6bd 100644 (file)
@@ -12,6 +12,13 @@ ctx_org = ctx.physical_loc || ctx.search_ou || ctx.aou_tree.id;
 # list of the registration fields to (potentially) 
 # display in the order they should be shown
 
+# post_code is the only field below that is required in the database and
+# post_code is only required if an address is created.
+# To prevent any of these fields from showing locally, regardless org unit
+# settings, simply remove the fields from this list.  In the case of 
+# addresses, if all address fields are removed, no attempt at creating
+# an address will be made (and post_code will no longer be required).
+
 register_fields = [
     {class => 'stgu',  name = 'first_given_name', label => l('First Name')},
     {class => 'stgu',  name = 'second_given_name', label => l('Middle Name')},
@@ -36,25 +43,34 @@ register_fields = [
         <hr/>
 
         [% IF ctx.register.success %]
-            <h3>[% |l %]
-            Registration successful!  
-            Please see library staff to complete your registration.
-            [% END %]</h3>
+            <h3>[% l('Registration successful!') %]<h3>
+            <h4>[% l('Please see library staff to complete your registration.') %]</h4>
 
             [% IF ctx.register.username_taken %]
             <p>
                 [% |l %]
-                Note: The selected username may be in use by another
-                patron.  You may select another username when finalizing
-                your registration or in the online catalog.
+                Note: The selected username may be in use by another patron.  
+                You may select another username when finalizing your 
+                registration or in the online catalog.
                 [% END %]
             </p>
             [% END %]
 
+            <br/>
+            <p>
+                <a href="[% ctx.opac_root %]/home" 
+                    class="opac-button">[% l('Return to the Catalog') %]</a>
+            </p>
+
         [% ELSIF ctx.register.error %]
-            <h3>[% |l %]
-            An registration error has occurred. Please see library staff.
-            [% END %]</h3>
+            <h3>[% l('An registration error has occurred') %]</h3>
+            <h4>[% l('Please see library staff to complete your registration.') %]</h4>
+
+            <br/>
+            <p>
+                <a href="[% ctx.opac_root %]/home" 
+                    class="opac-button">[% l('Return to the Catalog') %]</a>
+            </p>
 
         [% ELSE %]
 
@@ -71,6 +87,12 @@ register_fields = [
                             valid_org_list=ctx.register.valid_orgs
                         %]
                     </td>
+                    <td>
+                        [% IF ctx.register.invalid.bad_home_ou %]
+                        <span class='patron-reg-invalid'>
+                            [% l('Please select a valid library') %]
+                        </span>
+                        [% END %]
                 </tr>
 [%
 # <=== shifting code left for readability