Tweak graduate vs. undergraduate profile determination
authorDan Scott <dan@coffeecode.net>
Thu, 29 Aug 2019 16:19:18 +0000 (12:19 -0400)
committerDan Scott <dan@coffeecode.net>
Thu, 29 Aug 2019 16:19:18 +0000 (12:19 -0400)
If lulPrimaryAffiliation = 'Student', we also need to check
lulStudentLevel to determine if they are graduate or undergraduate
students.

Signed-off-by: Dan Scott <dan@coffeecode.net>
tools/patron-load/ldap_osrf_sync

index b5104ca..ebd1725 100755 (executable)
@@ -199,13 +199,18 @@ class User:
             if att in self.ldap_atts:
                 affiliation = self._simple_map(att).lower()
                 if affiliation in profile_map:
+                    if affiliation == 'student':
+                        if 'lulStudentLevel' in self.ldap_atts and self._simple_map('lulStudentLevel').lower() == 'gr':
+                            self.affiliation = 'gr'
+                        else:
+                            self.affiliation = 'ug'
+                else:
                     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():
+        if hasattr(self, 'affiliation'):
+            return profile_map[affiliation]
+
+        if  'empl' in self.cname.lower():
             affiliation = 'staff'
         else:
             affiliation = r'\N'