get license from database, not from the record submitter

pull/1/head
eric 2013-07-26 19:52:15 -04:00
parent da9fc648e3
commit eff880ce0b
3 changed files with 2 additions and 16 deletions

View File

@ -17,13 +17,14 @@ from django.core.urlresolvers import reverse
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:
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
can use LCCN to grab record with urllib, but file writes are inconsistent
"""
license = edition.ebooks.all()[0].rights
logger = logging.getLogger(__name__)
logger.info("Making MARC records for edition %s and license %s" % (edition, license))
if '/unglue.it' in settings.BASE_URL:

View File

@ -577,19 +577,6 @@ class MARCUngluifyForm(forms.Form):
error_messages={'required': 'Please specify an edition.'},
)
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 Meta:

View File

@ -2632,13 +2632,11 @@ class MARCUngluifyView(FormView):
success_url = reverse_lazy('MARCUngluify')
def form_valid(self, form):
license = form.cleaned_data['license']
edition = form.cleaned_data['edition']
try:
ungluify_record.makemarc(
marcfile=self.request.FILES['file'],
license=license,
edition=edition
)
messages.success(