scoping than LDAP.
Signed-off-by: Art Rhyno <art632000@yahoo.ca>
--- /dev/null
+from datetime import date
+from evergreen_site import EvergreenIntegration
+import csv
+import subprocess
+from django.conf import settings
+from urllib2 import urlopen
+from django.utils import simplejson
+from conifer.libsystems.evergreen import opensrf
+
+
+class EvergreenExampleIntegration(EvergreenIntegration):
+
+ OSRF_CAT_SEARCH_ORG_UNIT = 28
+
+ OPAC_LANG = 'en-US'
+ OPAC_SKIN = 'default'
+
+ RESERVES_DESK_NAME = 'Reserves'
+ SITE_DEFAULT_ACCESS_LEVEL = 'RESTR'
+
+ def external_person_lookup(self, userid):
+ """
+ Given a userid, return either None (if the user cannot be found),
+ or a dictionary representing the user. The dictionary must contain
+ the keys ('given_name', 'surname') and should contain 'email' if
+ an email address is known, and 'patron_id' if a library-system ID
+ is known.
+ """
+ return opensrf.ils_patron_details(userid)
+
+
+ def fuzzy_person_lookup(self, query, include_students=False, level='STAFF'):
+ patrons = []
+
+ if level == 'USERNAME':
+ patrons = opensrf.ils_patron_lookup(query,False,True,True)
+ elif level == 'EVERYONE':
+ patrons = opensrf.ils_patron_lookup(query,False,False,True)
+ else:
+ patrons = opensrf.ils_patron_lookup(query)
+
+ return patrons
+
+ #---------------------------------------------------------------------------
+ # copyright/permissions
+
+ def download_declaration(self):
+ """
+ Returns a string. The declaration to which students must agree when
+ downloading electronic documents. If not customized, a generic message
+ will be used.
+ """
+ # based on U. of Windsor
+ return ("I warrant that I am a student of this university "
+ "enrolled in a course of instruction. By pressing the "
+ "'Request' button below, I am requesting a digital copy of a "
+ "reserve reading for research, private study, review or criticism "
+ "and that I will not use the copy for any other purpose, nor "
+ "will I transmit the copy to any third party.")
+
return None, None, None
+def ils_patron_details(usrname):
+ dir_entry = {}
+
+ try:
+ authtoken = auth_token(settings.OPENSRF_STAFF_USERID,
+ settings.OPENSRF_STAFF_PW,
+ settings.OPENSRF_STAFF_WORKSTATION)
+
+ if auth_token:
+ patrons = []
+ req = request('open-ils.actor',
+ 'open-ils.actor.patron.search.advanced',
+ authtoken, {'usrname':{'value':usrname.strip(),'group':0}})
+ patron_info = req.send()
+ if patron_info:
+ patrons = patron_info
+ for patron in patrons[0:1]:
+ req = request('open-ils.actor',
+ 'open-ils.actor.user.fleshed.retrieve',
+ authtoken, patron,
+ ["first_given_name","family_name","email","cards"])
+ patron_info = req.send()
+ if patron_info:
+ dir_entry['given_name'] = patron_info.first_given_name()
+ dir_entry['surname'] = patron_info.family_name()
+ dir_entry['email'] = patron_info.email()
+
+ cards = patron_info.cards()
+ if cards:
+ barcode = None
+ for card in cards:
+ barcode = card.barcode()
+ dir_entry['barcode'] = barcode
+
+ #clean up session
+ session_cleanup(authtoken)
+ except:
+ print "item update problem"
+ print "*** print_exc:"
+ traceback.print_exc()
+ pass # fail silently in production
+
+ return dir_entry
+
def ils_patron_lookup(name, is_staff=True, is_usrname=False, is_everyone=False):
"""
This is the barebones of a fuzzy lookup using opensrf
if not is_barcode and is_number(name):
return out
is_email = False
- if name.find('@') > 0:
+ if not is_usrname and name.find('@') > 0:
is_email = True
try:
'open-ils.actor.patron.search.advanced',
authtoken, {'card':{'value':name.strip(),'group':3}})
patrons = req.send()
+ elif is_usrname:
+ req = request('open-ils.actor',
+ 'open-ils.actor.patron.search.advanced',
+ authtoken, {'usrname':{'value':name.strip(),'group':0}})
+ patron_info = req.send()
+ if patron_info:
+ patrons = patron_info
elif is_staff:
patrons.extend(group_search(query,authtoken,patrons))
if (len(patrons) < RESULT_LIMIT and default_query):
authtoken, patron,
["first_given_name","family_name","email","usrname"])
patron_info = req.send()
- display = ('%s %s. %s, '
- '%s. <%s>. [%s]') % (patron_info.first_given_name(),
- patron_info.family_name(), 'Test', 'FACULTY/STAFF',
+ 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))
# other late initializations. See the 'conifer.syrup.integration' module for
# more information.
-#INTEGRATION_CLASS = 'conifer.integration.uwindsor.UWindsorIntegration'
+#INTEGRATION_CLASS = 'conifer.integration.evergreen_example.EvergreenExampleIntegration'
#GATEWAY_SERVER = 'windsor.concat.ca'
#GATEWAY_URL = 'osrf-gateway-v1'
#OPENSRF_STAFF_USERID = 'staff@projectconifer.ca'
here.waiting = true;
$(Search).css({backgroundColor: 'yellow'}); // debugging
+ var search='';
+ var search_level = document.getElementById('search_level');
+ if (search_level)
+ search = search_level.value;
$.post(ROOT + '/fuzzy_user_lookup', {'q': here.lastText,
- includeStudents: here.includeStudents},
+ includeStudents: here.includeStudents, level: search},
function(data) {
here.waiting = false;
here.lastPress = null;
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?
@admin_only
def site_fuzzy_user_lookup(request):
query = request.REQUEST.get('q').lower().strip()
+ level = request.REQUEST.get('level').strip()
include_students = (request.REQUEST.get('includeStudents') == 'true')
- results = callhook('fuzzy_person_lookup', query, include_students) or []
+ results = callhook('fuzzy_person_lookup', query, include_students, level) or []
limit = 10
resp = {'results': results[:limit],
'notshown': max(0, len(results) - limit)}
</p>
<div>
<div id="fuzzyedit" style="display: 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>
+ <div style="font-size: 80%; margin: 0.5em 0;">For fuzzy matches, type a partial name or username into the box, then select one of the matches.</div>
<input type="text" id="fuzzyinput" autocomplete="off" value=""/>
+ <span style="margin: 8px;">
+ <select id="search_level">
+ <option value="STAFF" selected="selected">Staff</option>
+ <option value="USERNAME">Username</option>
+ <option value="EVERYONE">Everyone</option>
+ </select>
+ </span>
<div id="fuzzypanel">
</div>
</div>
</div>
<p><a href="../../">Go back</a></p>
</body>
-</html>
\ No newline at end of file
+</html>
Type a partial name or userid into the box; then select one of the matches.
</div>
<input type="text" id="fuzzyinput" autocomplete="off" value=""/>
+ <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>