# (r'^admin/terms/$', 'admin_term'),
(r'^unapi/$', 'unapi'),
+ (r'^site/(?P<site_id>\d+)/revert_parms/$', 'site_revert_parms'),
+
(r'^site/(?P<site_id>\d+)/copy_from/$', 'site_clipboard_copy_from'),
(r'^site/(?P<site_id>\d+)/paste_to/$', 'site_clipboard_paste_to'),
(r'^site/(?P<site_id>\d+)/paste_undo/$', 'site_clipboard_paste_undo'),
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
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
<span py:if="item.published">(${item.published}).</span>
<span py:if="item.source_title"><i>${item.source_title}.</i></span>
<span py:if="item.volume or item.issue"><i>${item.volume}</i>(${item.issue}), ${item.pages}.</span>
+ <div py:if="edit">
+ <span><i>Source: </i></span>
+ <span py:if="item.circ_modifier">${item.circ_modifier}, </span>
+ <span py:if="item.orig_callno">${item.orig_callno}, </span>
+ <span py:if="item.circ_desk">desk - ${item.circ_desk}</span>
+ </div>
</div>
<div class="forbidden_notice" py:if="forbidden">Awaiting copyright clearance: Not available to students.</div>
<div>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<?python
+title = _('Revert parameters for this site?')
+?>
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:py="http://genshi.edgewall.org/">
+ <xi:include href="master.xhtml"/>
+ <xi:include href="components/site.xhtml"/>
+ <head>
+ <title>${title}</title>
+ </head>
+ <body>
+ <h2>${title}</h2>
+ <p>Please confirm that you want to update the catalogue with the parameters
+ stored with the course materials.</p>
+ <table class="metadata_table">
+ <tr><th>Source:</th><td><a href="${site.site_url()}">${site}</a></td></tr>
+ <tr><th>Items:</th><td>
+ ${show_tree(site.item_tree(), edit=True)}
+ </td></tr>
+ </table>
+ <form action="." method="POST">
+ <p>
+ <input type="submit" value="Revert these materials"/>
+ ${go_back_link()}
+ </p>
+ </form>
+ </body>
+</html>