Fixing up situation where name values are null
authorArt Rhyno <art632000@yahoo.ca>
Wed, 6 Jul 2011 01:50:23 +0000 (21:50 -0400)
committerArt Rhyno <art632000@yahoo.ca>
Wed, 6 Jul 2011 01:50:23 +0000 (21:50 -0400)
instead of blanks.

Signed-off-by: Art Rhyno <art632000@yahoo.ca>
conifer/libsystems/evergreen/opensrf.py
conifer/syrup/models.py
conifer/syrup/views/admin.py
conifer/syrup/views/sites.py
conifer/templates/edit_site.xhtml

index a6a29bf..833e7df 100644 (file)
@@ -267,11 +267,21 @@ def ils_patron_lookup(name, is_staff=True, is_usrname=False, is_everyone=False):
                         authtoken, patron,
                         ["first_given_name","family_name","email","usrname"])
                 patron_info = req.send()
-                display = ('%s %s, '
-                    '<%s>. [%s]') % (patron_info.first_given_name(),
-                    patron_info.family_name(), 
-                    patron_info.email(), patron_info.usrname())
-                out.append((patron_info.usrname(), display))
+                if patron_info.usrname():
+                    first_name = ""
+                    family_name = ""
+                    email = ""
+                    if patron_info.first_given_name():
+                        first_name = patron_info.first_given_name()
+                    if patron_info.family_name():
+                        family_name = patron_info.family_name()
+                    if patron_info.email():
+                        email = patron_info.email()
+                    display = ('%s %s, '
+                        '<%s>. [%s]') % (first_name,
+                        family_name, 
+                        email, patron_info.usrname())
+                    out.append((patron_info.usrname(), display))
                         
             #clean up session
             session_cleanup(authtoken)
index 064bb22..3e048f6 100644 (file)
@@ -125,9 +125,20 @@ class UserExtensionMixin(object):
         if dir_entry is None:
             return
 
-        self.first_name = dir_entry['given_name']
-        self.last_name  = dir_entry['surname']
-        self.email      = dir_entry.get('email', self.email)
+        first_name = ""
+        last_name = ""
+        email = ""
+
+        if dir_entry['given_name']:
+            first_name = dir_entry['given_name']
+        if dir_entry['surname']:
+            last_name = dir_entry['surname']
+        if dir_entry.get('email', self.email):
+            email = dir_entry.get('email', self.email)
+
+        self.first_name = first_name
+        self.last_name  = last_name
+        self.email      = email
         self.save()
 
         if 'patron_id' in dir_entry:
index 993e775..457a8a4 100644 (file)
@@ -156,18 +156,13 @@ def admin_staff_add(request):
         return g.render('admin/staff_add.xhtml', **locals())
     else:
         userid = request.POST.get('userid','').strip()
-        print "userid", userid
         message_continue = True
 
         try:
             user = User.objects.get(username=userid)
         except User.DoesNotExist:
-            print "about to create"
             user = User.objects.create(username=userid)
-            print "created", user
-            print "1"
             user.maybe_decorate()
-            print "2"
 
         user.is_staff = True
         user.is_superuser = True # TODO: are we sure they should be superuser?
index ad342c8..2523a13 100644 (file)
@@ -69,7 +69,8 @@ def _add_or_edit_site(request, instance=None, basis=None):
             # then the owner may be a username instead of an ID, and
             # the user may not exist in the local database.
             userid = POST.get('owner', '').strip()
-            if userid and not userid.isdigit():
+            is_barcode = re.search('\d{14}', userid)
+            if userid and (not userid.isdigit() or is_barcode):
                 try:
                     user = User.objects.get(username=userid)
                 except User.DoesNotExist:
index 8e96f77..3f2d8bb 100644 (file)
@@ -54,6 +54,13 @@ owner = instance.owner if instance.owner_id else None
                           style="display: ${'none' if owner else 'block'}">
                        <div style="font-size: 80%; margin: 0.5em 0;">Type a partial name or userid into the box; then select one of the matches.</div>
                        <input type="text" id="fuzzyinput" autocomplete="off" value="${owner.username if owner else ''}"/>
+                <span style="margin: 8px;">
+                <select id="search_level">
+                <option value="EVERYONE" selected="selected">Everyone</option>
+                <option value="STAFF">Staff</option>
+                <option value="USERNAME">Username</option>
+                </select>
+                </span>
                        <div id="fuzzypanel">
                        </div>
                  </div>