[open-ils-commits] r1127 - in servres/trunk/conifer: static syrup syrup/views templates (gfawcett)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Dec 28 12:04:06 EST 2010
Author: gfawcett
Date: 2010-12-28 12:04:03 -0500 (Tue, 28 Dec 2010)
New Revision: 1127
Modified:
servres/trunk/conifer/static/edit_site_permissions.js
servres/trunk/conifer/syrup/urls.py
servres/trunk/conifer/syrup/views/sites.py
servres/trunk/conifer/templates/edit_site.xhtml
servres/trunk/conifer/templates/edit_site_permissions.xhtml
servres/trunk/conifer/templates/master.xhtml
Log:
Fix edit-site bug; better save-confirm messages on Permissions; delete groups.
When editing a site (via "Setup"), the owner name was not being set properly,
and would cause the edit to fail if the owner was not changed.
Save-confirmation messages now have a "continue" link on the Permissions page,
making it a bit easier to proceed after making changes.
External groups are now deletable.
Modified: servres/trunk/conifer/static/edit_site_permissions.js
===================================================================
--- servres/trunk/conifer/static/edit_site_permissions.js 2010-12-28 17:04:00 UTC (rev 1126)
+++ servres/trunk/conifer/static/edit_site_permissions.js 2010-12-28 17:04:03 UTC (rev 1127)
@@ -9,4 +9,25 @@
$('#' + cur + '_panel').fadeIn();
}
-$(do_init);
\ No newline at end of file
+$(do_init);
+
+
+function deleteGroup(linkid, groupid) {
+ var link = $('#'+linkid);
+ link.hide();
+ var sure = $('<span>are you sure? </span>');
+ var yes = $('<a href="javascript:void();">yes</a>');
+ var no = $('<a href="javascript:void();">no</a>');
+ yes.click(function() {
+ $.post('delete_group/',
+ {id: groupid},
+ function() {
+ link.parents('tr').fadeOut();
+ });
+ });
+ no.click(function() {
+ link.show(); sure.hide();
+ });
+ sure.append(yes).append(" / ").append(no);
+ link.after(sure);
+}
\ No newline at end of file
Modified: servres/trunk/conifer/syrup/urls.py
===================================================================
--- servres/trunk/conifer/syrup/urls.py 2010-12-28 17:04:00 UTC (rev 1126)
+++ servres/trunk/conifer/syrup/urls.py 2010-12-28 17:04:03 UTC (rev 1127)
@@ -31,6 +31,7 @@
(r'^site/(?P<site_id>\d+)/edit/$', 'edit_site'),
(r'^site/(?P<site_id>\d+)/edit/delete/$', 'delete_site'),
(r'^site/(?P<site_id>\d+)/edit/permission/$', 'edit_site_permissions'),
+ (r'^site/(?P<site_id>\d+)/edit/permission/delete_group/$', 'edit_site_permissions_delete_group'),
(r'^site/(?P<site_id>\d+)/feeds/(?P<feed_type>.*)$', 'site_feeds'),
(r'^site/(?P<site_id>\d+)/join/$', 'site_join'),
(r'^site/.*fuzzy_user_lookup$', 'site_fuzzy_user_lookup'),
Modified: servres/trunk/conifer/syrup/views/sites.py
===================================================================
--- servres/trunk/conifer/syrup/views/sites.py 2010-12-28 17:04:00 UTC (rev 1126)
+++ servres/trunk/conifer/syrup/views/sites.py 2010-12-28 17:04:03 UTC (rev 1127)
@@ -101,10 +101,12 @@
else:
POST = request.POST
message = 'Changes saved.' # default
+ message_iserror = False
if 'action_access_level' in POST:
access = POST.get('access')
site.access = access
+ message = 'Security level changed: "%s"' % dict(choices)[access]
elif 'action_add_group' in POST:
section = POST.get('section', '').strip()
@@ -117,14 +119,23 @@
if not groupcode:
message = 'No group code or section number provided.'
+ message_iserror = True
else:
group, created = models.Group.objects.get_or_create(
site=site, external_id=groupcode)
-
+ message = 'Group %s added.' % groupcode
site.save()
return g.render('edit_site_permissions.xhtml', **locals())
@instructors_only
+def edit_site_permissions_delete_group(request, site_id):
+ site = get_object_or_404(models.Site, pk=site_id)
+ groupId = request.REQUEST.get('id')
+ group = get_object_or_404(models.Group, site=site, pk=groupId)
+ group.delete()
+ return HttpResponse('')
+
+ at instructors_only
def delete_site(request, site_id):
site = get_object_or_404(models.Site, pk=site_id)
if request.POST.get('confirm_delete'):
Modified: servres/trunk/conifer/templates/edit_site.xhtml
===================================================================
--- servres/trunk/conifer/templates/edit_site.xhtml 2010-12-28 17:04:00 UTC (rev 1126)
+++ servres/trunk/conifer/templates/edit_site.xhtml 2010-12-28 17:04:03 UTC (rev 1127)
@@ -44,7 +44,7 @@
<tr py:if="owner_mode=='lookup'">
<th>Primary Instructor</th>
<td>
- <input type="hidden" id="owner" name="owner" value="${form.owner.data}"/>
+ <input type="hidden" id="owner" name="owner" value="${owner and owner.username}"/>
<div id="fuzzyedit"
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>
Modified: servres/trunk/conifer/templates/edit_site_permissions.xhtml
===================================================================
--- servres/trunk/conifer/templates/edit_site_permissions.xhtml 2010-12-28 17:04:00 UTC (rev 1126)
+++ servres/trunk/conifer/templates/edit_site_permissions.xhtml 2010-12-28 17:04:03 UTC (rev 1127)
@@ -15,21 +15,26 @@
<script type="text/javascript" src="${ROOT}/static/edit_site_permissions.js"/>
<style type="text/css">
#access_level li { list-style-type: none; }
- .popup { background-color: #ddd; padding: 24; margin: 0 24; }
- #message { background-color: #fdd; padding: 12; display: inline-block; }
+ .popup { background-color: #ddd; padding: 24; margin: 0 24; }
+ #message { background-color: #fdd; padding: 12; display: inline-block; }
+ h2 { margin-top: 2em; }
</style>
</head>
<body>
${site_banner(site)}
<h1>${title}</h1>
- <div py:if="defined('message')" id="message">${message}</div>
+ <div py:if="defined('message')">
+ <span id="message">
+ ${message}
+ </span>
+ <a py:if="not message_iserror" href="../../" style="margin-left: 1em;">Continue</a>
+ </div>
<form action="." method="POST">
<div>
- <h2>Security level</h2>
- <div>Who has permission to view resources in this site?</div>
+ <p style="margin-bottom: 0;">Who has permission to view resources in this site?</p>
<div id="access_level" style="margin: 8;">${Markup(choose_access.render('access', site.access, {'id':'id_access'}, []))}</div>
<p><input type="submit" name="action_access_level" value="Change security level"/>
- ${go_back_link()}</p>
+ ${go_back_link('../../')}</p>
</div>
<div>
@@ -44,6 +49,7 @@
<tr py:for="eg in extgroups">
<td>${eg.external_id}</td>
<td>${eg.membership__count}</td>
+ <td style="font-size: 90%;"><a id="dg${eg.id}" href="javascript:deleteGroup('dg${eg.id}', ${eg.id});">delete</a></td>
</tr>
</tbody>
</table>
@@ -56,7 +62,8 @@
<li>
Add a class list or group by its group code: <input name="groupcode" style="width: 15em;"/>
</li>
- <p><input type="submit" name="action_add_group" value="Add class list or group"/></p>
+ <p><input id="aad" type="submit" name="action_add_group" value="Add class list or group"/>
+ ${go_back_link('../../')}</p>
</div>
</div>
Modified: servres/trunk/conifer/templates/master.xhtml
===================================================================
--- servres/trunk/conifer/templates/master.xhtml 2010-12-28 17:04:00 UTC (rev 1126)
+++ servres/trunk/conifer/templates/master.xhtml 2010-12-28 17:04:03 UTC (rev 1127)
@@ -79,7 +79,7 @@
</body>
</py:match>
- <span py:def="go_back_link(url=None, msg=_('or Cancel'))" py:with="url=url or request.META.get('HTTP_REFERER', '../')">
+ <span py:def="go_back_link(url=None, msg=_('or go back'))" py:with="url=url or request.META.get('HTTP_REFERER', '../')">
<a style="margin-left: 12px;" href="${url}">${msg}</a>
</span>
More information about the open-ils-commits
mailing list