handle no 001 present

pull/1/head
eric 2014-12-09 18:44:08 -05:00
parent f7b796c6a6
commit d7edd8ee6a
1 changed files with 6 additions and 3 deletions

View File

@ -85,9 +85,12 @@ class MARCRecord(models.Model):
self.guts = ''
super(MARCRecord, self).save(*args, **kwargs)
self.guts = _xml(self._the_record)
field001 = self._the_record.get_fields('001')[0]
if field001:
self._the_record.remove_field(field001)
try:
field001 = self._the_record.get_fields('001')[0]
if field001:
self._the_record.remove_field(field001)
except IndexError:
pass
field001 = pymarc.Field(tag='001', data=self.accession)
self._the_record.add_ordered_field(field001)
super(MARCRecord, self).save(*args, **kwargs)