Add visitor profile parsing
authorDan Scott <dscott@laurentian.ca>
Thu, 27 Oct 2016 15:19:27 +0000 (11:19 -0400)
committerDan Scott <dscott@laurentian.ca>
Thu, 27 Oct 2016 15:46:14 +0000 (11:46 -0400)
We have a strange category of students who come here for the summer but are not
officially LU students, so treat them as visitors. More work may need to be
done to distinguish them from guests.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
tools/patron-load/ldap_osrf_sync

index 7deb46c..cf104da 100755 (executable)
@@ -178,15 +178,6 @@ class User:
         Map LDAP record to Evergreen profile
         """
 
-        if 'alumni' in self.cname.lower():
-            affiliation = 'alumni'
-        elif 'lulStudentLevel' in self.ldap_atts:
-            affiliation = self._simple_map('lulStudentLevel').lower()
-        elif 'lulPrimaryAffiliation' in self.ldap_atts:
-            affiliation = self._simple_map('lulPrimaryAffiliation').lower()
-        else:
-            affiliation = r'\N'
-
         profile_map = {
             'ug': 113,
             'student': 113,
@@ -200,9 +191,28 @@ class User:
             'thornloe': 115,
             'proxy': None,
             'retired': None,
-            'affiliate': 115
+            'affiliate': 115,
+            'visitor': 113
         }
 
+        for att in ('lulStudentLevel', 'lulPrimaryAffiliation', 'lulAffiliation'):
+            if att in self.ldap_atts:
+                affiliation = self._simple_map(att).lower()
+                if affiliation in profile_map:
+                    self.affiliation = affiliation
+                    return profile_map[affiliation]
+
+        if 'alumni' in self.cname.lower():
+            # we have a winner!
+            affiliation = 'alumni'
+        elif 'empl' in self.cname.lower():
+            affiliation = 'staff'
+        else:
+            affiliation = r'\N'
+
+        # Let's remember the affiliation
+        self.affiliation = affiliation
+
         if affiliation in profile_map:
             return profile_map[affiliation]
         else: