From 8c4fe18a07a888e72749c907901981cfaee4ac68 Mon Sep 17 00:00:00 2001 From: Art Rhyno Date: Tue, 21 Jun 2011 23:58:49 -0400 Subject: [PATCH] Initial support for batching updates to revert course materials for a course site. Signed-off-by: Art Rhyno --- conifer/syrup/urls.py | 2 ++ conifer/syrup/views/sites.py | 39 +++++++++++++++++++++++++++++++++ conifer/templates/components/site.xhtml | 6 +++++ conifer/templates/revert_confirm.xhtml | 30 +++++++++++++++++++++++++ conifer/templates/site_detail.xhtml | 1 + 5 files changed, 78 insertions(+) create mode 100644 conifer/templates/revert_confirm.xhtml diff --git a/conifer/syrup/urls.py b/conifer/syrup/urls.py index 9a2594c..49d2b64 100644 --- a/conifer/syrup/urls.py +++ b/conifer/syrup/urls.py @@ -68,6 +68,8 @@ urlpatterns = patterns('conifer.syrup.views', # (r'^admin/terms/$', 'admin_term'), (r'^unapi/$', 'unapi'), + (r'^site/(?P\d+)/revert_parms/$', 'site_revert_parms'), + (r'^site/(?P\d+)/copy_from/$', 'site_clipboard_copy_from'), (r'^site/(?P\d+)/paste_to/$', 'site_clipboard_paste_to'), (r'^site/(?P\d+)/paste_undo/$', 'site_clipboard_paste_undo'), diff --git a/conifer/syrup/views/sites.py b/conifer/syrup/views/sites.py index bc4af67..2f92ba2 100644 --- a/conifer/syrup/views/sites.py +++ b/conifer/syrup/views/sites.py @@ -1,5 +1,11 @@ from _common import * from search import * +from conifer.libsystems.evergreen.support import initialize, E1 +from conifer.plumbing.hooksystem import * +from django.conf import settings +if hasattr(settings, 'OPENSRF_STAFF_USERID'): # TODO: we need an explicit 'we do updates' flag + from conifer.libsystems.evergreen import opensrf + #----------------------------------------------------------------------------- # Creating a new site @@ -257,6 +263,39 @@ def site_fuzzy_user_lookup(request): content_type='application/json') +def _revert_parms(request, source_site): + cnt = 0 + def revert_item(parent, (item, subitems)): + update_status = False + if hasattr(settings, 'OPENSRF_STAFF_USERID'): + update_status = True + dct = dict((k,v) for k,v in item.__dict__.items() if not k.startswith('_')) + dct['parent_heading_id'] = parent.id if parent else None + barcode = dct['barcode'] + orig_call = dct['orig_callno'] + orig_desk = dct['circ_desk'] + orig_modifier = dct['circ_modifier'] + + if barcode and orig_call and orig_desk and orig_modifier: + update_status = opensrf.ils_item_update(barcode, orig_call, + orig_modifier, orig_desk) + if update_status: + for sub in subitems: + revert_item(parent, sub) + else: + return simple_message(_('Unable to update'), + _('Sorry, unable to finish updates, %d processed' % cnt)) + + for branch in source_site.item_tree(): + revert_item(None, branch) + +def site_revert_parms(request, site_id): + site = get_object_or_404(models.Site, pk=site_id) + if request.method != 'POST': + return g.render('revert_confirm.xhtml', **locals()) + _revert_parms(request, site) + return HttpResponseRedirect('../') + def site_clipboard_copy_from(request, site_id): site = get_object_or_404(models.Site, pk=site_id) request.session['copy_source'] = site_id diff --git a/conifer/templates/components/site.xhtml b/conifer/templates/components/site.xhtml index d4ac24a..df15e54 100644 --- a/conifer/templates/components/site.xhtml +++ b/conifer/templates/components/site.xhtml @@ -111,6 +111,12 @@ searchtext = _('search this site...') (${item.published}). ${item.source_title}. ${item.volume}(${item.issue}), ${item.pages}. +
+ Source: + ${item.circ_modifier}, + ${item.orig_callno}, + desk - ${item.circ_desk} +
Awaiting copyright clearance: Not available to students.
diff --git a/conifer/templates/revert_confirm.xhtml b/conifer/templates/revert_confirm.xhtml new file mode 100644 index 0000000..54d6d65 --- /dev/null +++ b/conifer/templates/revert_confirm.xhtml @@ -0,0 +1,30 @@ + + + + + + + ${title} + + +

${title}

+

Please confirm that you want to update the catalogue with the parameters + stored with the course materials.

+ + + + +
+

+ + ${go_back_link()} +

+
+ + diff --git a/conifer/templates/site_detail.xhtml b/conifer/templates/site_detail.xhtml index cf498e6..f402dc4 100644 --- a/conifer/templates/site_detail.xhtml +++ b/conifer/templates/site_detail.xhtml @@ -31,6 +31,7 @@ is_joinable = site.is_joinable_by(request.user)
Join this site -- 2.11.0