From: gfawcett Date: Sat, 4 Apr 2009 02:42:19 +0000 (+0000) Subject: on selection of item from catalogue, store whole MARC record X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=735a021322dc0f4bd3a1856d1cc9f70cc7326230;p=Syrup.git on selection of item from catalogue, store whole MARC record For the moment, I'm storing the MARC in a syrup:marc Metadata record. The format is not standard yet: I'm writing it out as a JSON assoc-array. git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@257 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- diff --git a/conifer/syrup/models.py b/conifer/syrup/models.py index df32f8e..69ab4a5 100644 --- a/conifer/syrup/models.py +++ b/conifer/syrup/models.py @@ -468,6 +468,7 @@ metadata_attributes = { 'dc:title': _('Title'), 'dc:type': _('Type'), 'syrup:barcode': _('Barcode'), + 'syrup:marc': _('MARC'), 'syrup:enumeration': _('Enumeration'), 'syrup:chronology': _('Chronology')} diff --git a/conifer/syrup/views.py b/conifer/syrup/views.py index d992eaf..cc708ad 100644 --- a/conifer/syrup/views.py +++ b/conifer/syrup/views.py @@ -721,8 +721,8 @@ def item_add_cat_search(request, course_id, item_id): if request.method != 'POST': return g.render('item_add_cat_search.xhtml', results=[], query='@and dylan thomas') query = request.POST.get('query','').strip() - pickitem = request.POST.get('pickitem', '').strip() - if not pickitem: + _pickitem = request.POST.get('pickitem', '').strip() + if not _pickitem: assert query, 'must provide a query.' from conifer.libsystems.z3950 import yaz_search host, db, query = ('dwarf.cs.uoguelph.ca:2210', 'conifer', query) @@ -742,18 +742,19 @@ def item_add_cat_search(request, course_id, item_id): if not course.can_edit(request.user): return _access_denied(_('You are not an editor.')) - pickitem = eval(pickitem) # fixme, dangerous. cache result server-side instead, or encrypt it. + pickitem = eval(_pickitem) # fixme, dangerous. cache result server-side instead, or encrypt it. item = course.item_set.create(parent_heading=parent_item, title=pickitem.get('245a', 'Untitled'), item_type='PHYS') item.save() # these are a temporary hack, must replace meta = [('245a', 'dc:title'), ('100a', 'dc:creator'), ('260b', 'dc:publisher'), - ('dc:260c', 'dc:date'), ('700a', 'dc:contributor')] + ('260c', 'dc:date'), ('700a', 'dc:contributor')] for marc, dc in meta: value = pickitem.get(marc) if value: md = item.metadata_set.create(item=item, name=dc, value=value) + item.metadata_set.create(item=item, name='syrup:marc', value=simplejson.dumps(pickitem)) item.save() return HttpResponseRedirect('../../../%d/' % item.id)