[open-ils-commits] r1216 - in servres/trunk/conifer: static syrup/views templates (gfawcett)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Jan 31 22:00:20 EST 2011
Author: gfawcett
Date: 2011-01-31 22:00:18 -0500 (Mon, 31 Jan 2011)
New Revision: 1216
Modified:
servres/trunk/conifer/static/fuzzyFinder.js
servres/trunk/conifer/syrup/views/sites.py
servres/trunk/conifer/templates/edit_site_permissions.xhtml
Log:
site permissions: add individual member to site (fuzzy name lookup)
Modified: servres/trunk/conifer/static/fuzzyFinder.js
===================================================================
--- servres/trunk/conifer/static/fuzzyFinder.js 2011-01-29 16:06:52 UTC (rev 1215)
+++ servres/trunk/conifer/static/fuzzyFinder.js 2011-02-01 03:00:18 UTC (rev 1216)
@@ -5,6 +5,7 @@
lastPress: null,
waiting: false,
minWait: 500,
+ includeStudents: false,
lookup: function() {
var text = $(this).val();
@@ -30,7 +31,8 @@
here.waiting = true;
$(Search).css({backgroundColor: 'yellow'}); // debugging
- $.post(ROOT + '/fuzzy_user_lookup', {'q': here.lastText},
+ $.post(ROOT + '/fuzzy_user_lookup', {'q': here.lastText,
+ includeStudents: here.includeStudents},
function(data) {
here.waiting = false;
here.lastPress = null;
@@ -40,7 +42,7 @@
$(Matches).append('No matches.');
}
$.each(data.results, function(i,val) {
- var link = $('<a class="fuzzychoice" href="#"/>');
+ var link = $('<a class="fuzzychoice" href="javascript:void(0);"/>');
link.text(val[1]);
link.data('userid', val[0]);
link.data('display', val[1]);
Modified: servres/trunk/conifer/syrup/views/sites.py
===================================================================
--- servres/trunk/conifer/syrup/views/sites.py 2011-01-29 16:06:52 UTC (rev 1215)
+++ servres/trunk/conifer/syrup/views/sites.py 2011-02-01 03:00:18 UTC (rev 1216)
@@ -109,6 +109,29 @@
site.access = access
message = 'Security level changed: "%s"' % dict(choices)[access]
+ elif 'action_add_member' in POST:
+ userid = request.POST.get('userid')
+ role = request.POST.get('role')
+ try:
+ user = User.objects.get(username=userid)
+ except User.DoesNotExist:
+ user = User.objects.create(username=userid)
+ user.save()
+ user.maybe_decorate()
+ user.save()
+ group = models.Group.objects.get(site=site, external_id=None)
+ mbr, created = models.Membership.objects.get_or_create(
+ group=group, user=user, defaults=dict(role=role))
+ if created:
+ message = '%s has been added as a member (role: %s).' % (
+ user.get_full_name() or user.username, mbr.get_role_display())
+ else:
+ mbr.role = role
+ mbr.save()
+ message = '%s: role changed to %s.' % (
+ user.get_full_name() or user.username,
+ mbr.get_role_display())
+
elif 'action_add_group' in POST:
section = POST.get('section', '').strip()
groupcode = None
@@ -192,7 +215,8 @@
@admin_only
def site_fuzzy_user_lookup(request):
query = request.POST.get('q').lower().strip()
- results = callhook('fuzzy_person_lookup', query) or []
+ include_students = (request.POST.get('includeStudents') == 'true')
+ results = callhook('fuzzy_person_lookup', query, include_students) or []
limit = 10
resp = {'results': results[:limit],
'notshown': max(0, len(results) - limit)}
Modified: servres/trunk/conifer/templates/edit_site_permissions.xhtml
===================================================================
--- servres/trunk/conifer/templates/edit_site_permissions.xhtml 2011-01-29 16:06:52 UTC (rev 1215)
+++ servres/trunk/conifer/templates/edit_site_permissions.xhtml 2011-02-01 03:00:18 UTC (rev 1216)
@@ -19,6 +19,19 @@
#message { background-color: #fdd; padding: 12; display: inline-block; }
h2 { margin-top: 2em; }
</style>
+ <script type="text/javascript" src="${ROOT}/static/fuzzyFinder.js"/>
+ <script>
+ $(function() {
+ var fuzzy = fuzzyFinder(
+ '#fuzzyinput', '#fuzzypanel', '#fuzzyedit', '#fuzzyview', '#fuzzyname', '#fuzzychange', '#userid');
+ fuzzy.includeStudents = true;
+ });
+ </script>
+ <style>
+ .fuzzychoice { display: block; margin: 0.5em 0; font-size: 90%; }
+ #fuzzyview { display: block; margin: 0.5em 0; font-size: 90%; }
+ #fuzzyname { color: navy; }
+ </style>
</head>
<body>
${site_banner(site)}
@@ -56,7 +69,7 @@
</tbody>
</table>
<div>
- <p><input type="button" value="Add external group" onclick="$('#addExternalGroupPopup').fadeIn();"/></p>
+ <p><input type="button" value="Add external group" onclick="$('#addExternalGroupPopup').fadeIn('slow')[0].scrollIntoView(true);"/></p>
<div class="popup" id="addExternalGroupPopup" style="display: none;">
<li py:if="show_add_section_panel">
Add the class list for ${site.course.code}, section <input name="section" style="width: 2em;"/>, ${site.start_term.name}
@@ -84,6 +97,39 @@
<td>${member.group.external_id or '(internal)'}</td>
</tr>
</table>
+ <div>
+ <p><input type="button" value="Add new member" onclick="$('#addMemberPopup').fadeIn('slow')[0].scrollIntoView(true);"/></p>
+ <div class="popup" id="addMemberPopup" style="display: none;">
+ <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>
+ <input type="text" id="fuzzyinput" autocomplete="off" value=""/>
+ <div id="fuzzypanel">
+ </div>
+ </div>
+ <div id="fuzzyview" style="display: none;">
+ <span id="fuzzyname">
+ </span>
+ <input id="fuzzychange" type="button" value="change" onclick="fuzzyLookup.edit();"
+ style="margin-left: 1em;"/>
+ <div>
+ <p>
+ Role for this user:
+ <select name="role">
+ <option py:for="v,k in models.Membership.ROLE_CHOICES" value="${v}">${k}</option>
+ </select>
+ </p>
+ <input type="hidden" id="userid" name="userid" value=""/>
+ <p><input name="action_add_member" type="submit" value="Add this user"/>
+ ${go_back_link('../../')}</p>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+
</div>
</form>
<div class="gap"/>
More information about the open-ils-commits
mailing list