JBAS-2040 College cards use email; fixes
authorBill Erickson <berickxx@gmail.com>
Wed, 11 Jul 2018 15:37:24 +0000 (11:37 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
College cards now use email for student_id values.  Values are scrubbed
and made lower case.

Fix sftp agent to properly pass the --college flag to the generator
script.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
KCLS/utility-scripts/import_students/generate-patrons-from-csv.pl
KCLS/utility-scripts/import_students/sftp-client-agent.sh

index ce22ae9..ffd8c3f 100755 (executable)
@@ -284,10 +284,25 @@ sub iterate_csv_rows {
         $phash->{student_id} = sprintf('%04s', $phash->{student_id})
             if $is_teacher && length($phash->{student_id}) < 4;
 
-        # All teacher ID's, which can be alpha-numeric, are upper case.
-        # Student ID's can also be alpha-numeric, but remain in the
-        # provided case.
-        $phash->{student_id} = uc($phash->{student_id}) if $is_teacher;
+        if ($is_college) {
+            # College student/teacher IDs are email addresses.
+            my $s = $phash->{student_id};
+            # Remove the @domain just in case
+            $s =~ s/@.*//g;
+            # Barcodes cannot have non-ascii chars, strip them.
+            $s =~ s/[^[:ascii:]]//g;
+            # Email barcodes are lowercase
+            $s = lc($s);
+            # a minimal set of characters are allowed.
+            $s =~ s/[^a-z0-9_\-\.]//g;
+            $phash->{student_id} = $s;
+
+        } elsif ($is_teacher) {
+            # All non-college teacher ID's, which can be alpha-numeric,
+            # are upper case.  Student ID's can also be alpha-numeric,
+            # but remain in the provided case.
+            $phash->{student_id} = uc($phash->{student_id});
+        }
 
         # Avoid processing duplicates
         next if $seen{$phash->{student_id}};
@@ -295,7 +310,9 @@ sub iterate_csv_rows {
 
         $phash->{barcode}  = $district_code;
         $phash->{barcode}  = uc($district_code) if $is_college;
-        $phash->{barcode} .= 't' if $is_teacher;
+        if ($is_teacher) {
+            $phash->{barcode} .= $is_college ? 'e' : 't';
+        }
         $phash->{barcode} .= $phash->{student_id};
 
         $row_handler->($phash);
index e4a7362..a5a39bf 100755 (executable)
@@ -209,7 +209,7 @@ for code in "${CODES_TO_PROCESS[@]}"; do
 
             announce "Processing file $LOCAL_FILE"
             INFO=$(perl ./generate-patrons-from-csv.pl \
-                --log-stdout $TEACHER_FLAG \
+                --log-stdout $TEACHER_FLAG $COLLEGE_FLAG \
                 --db-host $DB_HOST \
                 --district-code $code \
                 --commit-mode each \