Merge branch 'marc_provision' of github.com:Gluejar/regluit into marc_provision
commit
f18fc27f91
|
@ -175,8 +175,7 @@ class CampaignAction(models.Model):
|
|||
campaign = models.ForeignKey("Campaign", related_name="actions", null=False)
|
||||
|
||||
class CCLicense():
|
||||
CCCHOICES = settings.CCCHOICES
|
||||
CHOICES = CCCHOICES + (('PD-US', 'Public Domain, US'),)
|
||||
CHOICES = settings.CHOICES
|
||||
|
||||
@staticmethod
|
||||
def url(license):
|
||||
|
|
|
@ -132,15 +132,12 @@ def makemarc(marcfile, isbn, license, edition):
|
|||
record.add_ordered_field(field536)
|
||||
|
||||
# add 540 field (terms governing use)
|
||||
license_terms = settings.CCCHOICES
|
||||
license_grants = settings.CCGRANTS
|
||||
|
||||
field540 = pymarc.Field(
|
||||
tag='540',
|
||||
indicators = [' ', ' '],
|
||||
subfields = [
|
||||
'a', dict(license_terms)[license],
|
||||
'u', dict(license_grants)[license],
|
||||
'a', dict(settings.CHOICES)[license],
|
||||
'u', dict(settings.GRANTS)[license],
|
||||
]
|
||||
)
|
||||
record.add_ordered_field(field540)
|
||||
|
|
|
@ -577,7 +577,7 @@ class MARCUngluifyForm(forms.Form):
|
|||
)
|
||||
isbn = forms.CharField(label='ISBN of unglued edition (leave blank if no ISBN)', required=False)
|
||||
file = forms.FileField(label='Download a MARCXML file from Library of Congress; then upload it here.')
|
||||
license = forms.ChoiceField(choices=settings.CCCHOICES)
|
||||
license = forms.ChoiceField(choices=settings.CHOICES)
|
||||
|
||||
# insist that there is at least one ebook to link to
|
||||
def clean(self):
|
||||
|
|
|
@ -16,6 +16,7 @@ from notification import models as notification
|
|||
from random import randint
|
||||
from re import sub
|
||||
from xml.etree import ElementTree as ET
|
||||
from xml.sax import SAXParseException
|
||||
from tastypie.models import ApiKey
|
||||
|
||||
'''
|
||||
|
@ -2625,14 +2626,20 @@ class MARCUngluifyView(FormView):
|
|||
license = form.cleaned_data['license']
|
||||
edition = form.cleaned_data['edition']
|
||||
|
||||
ungluify_record.makemarc(
|
||||
marcfile=self.request.FILES['file'],
|
||||
isbn=isbn,
|
||||
license=license,
|
||||
edition=edition
|
||||
)
|
||||
messages.success(
|
||||
self.request,
|
||||
"You have successfully added a MARC record. Hooray! Add another?"
|
||||
)
|
||||
try:
|
||||
ungluify_record.makemarc(
|
||||
marcfile=self.request.FILES['file'],
|
||||
isbn=isbn,
|
||||
license=license,
|
||||
edition=edition
|
||||
)
|
||||
messages.success(
|
||||
self.request,
|
||||
"You have successfully added a MARC record. Hooray! Add another?"
|
||||
)
|
||||
except SAXParseException:
|
||||
messages.error(
|
||||
self.request,
|
||||
"Sorry, couldn't parse that file."
|
||||
)
|
||||
return super(MARCUngluifyView,self).form_valid(form)
|
|
@ -357,6 +357,7 @@ CCCHOICES = (
|
|||
('CC BY-ND','Creative Commons Attribution-NoDerivs 3.0 Unported (CC BY-ND 3.0)'),
|
||||
('CC0','No Rights Reserved (CC0)'),
|
||||
)
|
||||
CHOICES = CCCHOICES + (('PD-US', 'Public Domain, US'),)
|
||||
|
||||
CCGRANTS = (
|
||||
('CC BY', 'http://creativecommons.org/licenses/by/3.0/'),
|
||||
|
@ -367,6 +368,8 @@ CCGRANTS = (
|
|||
('CC BY-ND', 'http://creativecommons.org/licenses/by-nd/3.0/'),
|
||||
('CC0', 'http://creativecommons.org/about/cc0'),
|
||||
)
|
||||
GRANTS = CCGRANTS + (('PD-US', ''),)
|
||||
|
||||
|
||||
FORMATS = (
|
||||
('pdf','PDF'),
|
||||
|
|
Loading…
Reference in New Issue