get license from database, not from the record submitter
parent
da9fc648e3
commit
eff880ce0b
|
@ -17,13 +17,14 @@ from django.core.urlresolvers import reverse
|
||||||
|
|
||||||
from regluit.core import models
|
from regluit.core import models
|
||||||
|
|
||||||
def makemarc(marcfile, license, edition):
|
def makemarc(marcfile, edition):
|
||||||
"""
|
"""
|
||||||
fyi if we're going to suck down LOC records directly:
|
fyi if we're going to suck down LOC records directly:
|
||||||
parse_xml_to_array takes a file, so we need to faff about with file writes
|
parse_xml_to_array takes a file, so we need to faff about with file writes
|
||||||
would be nice to have a suitable z39.50
|
would be nice to have a suitable z39.50
|
||||||
can use LCCN to grab record with urllib, but file writes are inconsistent
|
can use LCCN to grab record with urllib, but file writes are inconsistent
|
||||||
"""
|
"""
|
||||||
|
license = edition.ebooks.all()[0].rights
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
logger.info("Making MARC records for edition %s and license %s" % (edition, license))
|
logger.info("Making MARC records for edition %s and license %s" % (edition, license))
|
||||||
if '/unglue.it' in settings.BASE_URL:
|
if '/unglue.it' in settings.BASE_URL:
|
||||||
|
|
|
@ -577,19 +577,6 @@ class MARCUngluifyForm(forms.Form):
|
||||||
error_messages={'required': 'Please specify an edition.'},
|
error_messages={'required': 'Please specify an edition.'},
|
||||||
)
|
)
|
||||||
file = forms.FileField(label='Download a MARCXML file from Library of Congress; then upload it here.')
|
file = forms.FileField(label='Download a MARCXML file from Library of Congress; then upload it here.')
|
||||||
license = forms.ChoiceField(choices=settings.CHOICES)
|
|
||||||
|
|
||||||
# insist that there is at least one ebook to link to
|
|
||||||
def clean(self):
|
|
||||||
ebooks = False
|
|
||||||
for format_tuple in settings.FORMATS:
|
|
||||||
format = format_tuple[0]
|
|
||||||
if self.cleaned_data['edition'].ebooks.filter(format=format):
|
|
||||||
ebooks = True
|
|
||||||
break
|
|
||||||
if not ebooks:
|
|
||||||
raise forms.ValidationError('Please add at least one unglued ebook link to THIS EDITION through the work or admin page before creating a MARC record.')
|
|
||||||
return self.cleaned_data
|
|
||||||
|
|
||||||
class MARCFormatForm(forms.ModelForm):
|
class MARCFormatForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
|
@ -2632,13 +2632,11 @@ class MARCUngluifyView(FormView):
|
||||||
success_url = reverse_lazy('MARCUngluify')
|
success_url = reverse_lazy('MARCUngluify')
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
license = form.cleaned_data['license']
|
|
||||||
edition = form.cleaned_data['edition']
|
edition = form.cleaned_data['edition']
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ungluify_record.makemarc(
|
ungluify_record.makemarc(
|
||||||
marcfile=self.request.FILES['file'],
|
marcfile=self.request.FILES['file'],
|
||||||
license=license,
|
|
||||||
edition=edition
|
edition=edition
|
||||||
)
|
)
|
||||||
messages.success(
|
messages.success(
|
||||||
|
|
Loading…
Reference in New Issue