implement age_level
parent
abedff089c
commit
9b0c91a439
14
api/onix.py
14
api/onix.py
|
@ -1,5 +1,6 @@
|
|||
import datetime
|
||||
import pytz
|
||||
import re
|
||||
from lxml import etree
|
||||
from regluit.core import models
|
||||
from regluit.core.cc import ccinfo
|
||||
|
@ -134,6 +135,19 @@ def product(edition, facet=None):
|
|||
subj_node.append(text_node("SubjectSchemeIdentifier", "20"))
|
||||
subj_node.append(text_node("SubjectHeadingText", subject.name))
|
||||
|
||||
# audience range composite
|
||||
if work.age_level:
|
||||
range_match = re.search(r'(\d?\d?)-(\d?\d?)', work.age_level)
|
||||
if range_match:
|
||||
audience_range_node = etree.SubElement(descriptive_node, "AudienceRange")
|
||||
audience_range_node.append(text_node("AudienceRangeQualifier", "17")) #Interest age, years
|
||||
if range_match.group(1):
|
||||
audience_range_node.append(text_node("AudienceRangePrecision", "03")) #from
|
||||
audience_range_node.append(text_node("AudienceRangeValue", range_match.group(1)))
|
||||
if range_match.group(2):
|
||||
audience_range_node.append(text_node("AudienceRangePrecision", "04")) #from
|
||||
audience_range_node.append(text_node("AudienceRangeValue", range_match.group(2)))
|
||||
|
||||
# Collateral Detail Block
|
||||
coll_node = etree.SubElement(product_node, "CollateralDetail")
|
||||
desc_node = etree.SubElement(coll_node, "TextContent")
|
||||
|
|
10
api/opds.py
10
api/opds.py
|
@ -163,6 +163,16 @@ def work_node(work, facet=None):
|
|||
# caused by control chars in subject.name
|
||||
logger.warning('Deleting subject: %s' % subject.name)
|
||||
subject.delete()
|
||||
|
||||
# age level
|
||||
# <category term="15-18" scheme="http://schema.org/typicalAgeRange" label="Teen - Grade 10-12, Age 15-18"/>
|
||||
if work.age_level:
|
||||
category_node = etree.Element("category")
|
||||
category_node.attrib["scheme"] = 'http://schema.org/typicalAgeRange'
|
||||
category_node.attrib["term"] = work.age_level
|
||||
category_node.attrib["label"] = work.get_age_level_display()
|
||||
node.append(category_node)
|
||||
|
||||
|
||||
# rating
|
||||
rating_node = etree.Element("{http://schema.org/}Rating")
|
||||
|
|
|
@ -58,7 +58,7 @@ from regluit.core.models import (
|
|||
UNGLUEITAR
|
||||
)
|
||||
from regluit.libraryauth.models import Library
|
||||
from regluit.core.parameters import LIBRARY, REWARDS, BUY2UNGLUE, THANKS
|
||||
from regluit.core.parameters import LIBRARY, REWARDS, BUY2UNGLUE, THANKS, AGE_LEVEL_CHOICES
|
||||
from regluit.core.lookups import (
|
||||
OwnerLookup,
|
||||
WorkLookup,
|
||||
|
@ -199,6 +199,7 @@ class EditionForm(forms.ModelForm):
|
|||
}
|
||||
)
|
||||
language = forms.ChoiceField(choices=LANGUAGES)
|
||||
age_level = forms.ChoiceField(choices=AGE_LEVEL_CHOICES)
|
||||
description = forms.CharField( required=False, widget=CKEditorWidget())
|
||||
coverfile = forms.ImageField(required=False)
|
||||
|
||||
|
|
|
@ -122,6 +122,7 @@ ul.fancytree-container {
|
|||
<input type="submit" name="add_author_submit" value="Add Author" id="submit_author"></p>
|
||||
|
||||
<p><b>Language</b>: {{ form.language.errors }}{{ form.language }}</p>
|
||||
<p><b>Age Level</b>: {{ form.age_level.errors }}{{ form.age_level }}</p>
|
||||
<h4> Identifiers </h4>
|
||||
{% if id_msg %} <span class="errorlist">{{ id_msg }} </span>{% endif %}
|
||||
<p> Enter 'delete' to remove the identifier. </p>
|
||||
|
|
|
@ -102,6 +102,8 @@
|
|||
<span itemprop="publisher"><a href="{% url 'bypubname_list' work.last_campaign.publisher.name.id %}">{{ work.last_campaign.publisher }}</a></span>
|
||||
{% endif %}
|
||||
<span itemprop="datePublished">{{ work.publication_date }}</span>
|
||||
<meta itemprop="inLanguage" content="work.language" />
|
||||
<meta itemprop="typicalAgeRange" content="work.age_range" />
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -514,11 +514,15 @@ def new_edition(request, work_id, edition_id, by=None):
|
|||
language='en'
|
||||
description=''
|
||||
title=''
|
||||
age_level = ''
|
||||
description = ''
|
||||
title = ''
|
||||
if work_id:
|
||||
work = safe_get_work(work_id)
|
||||
language=work.language
|
||||
description=work.description
|
||||
title=work.title
|
||||
age_level = work.age_level
|
||||
else:
|
||||
work=None
|
||||
|
||||
|
@ -533,6 +537,7 @@ def new_edition(request, work_id, edition_id, by=None):
|
|||
edition.work = work
|
||||
language=edition.work.language
|
||||
description=edition.work.description
|
||||
age_level = edition.work.age_level
|
||||
else:
|
||||
edition = models.Edition()
|
||||
if work:
|
||||
|
@ -552,6 +557,7 @@ def new_edition(request, work_id, edition_id, by=None):
|
|||
'doi': edition.id_for('doi'),
|
||||
}
|
||||
if request.method == 'POST' :
|
||||
'age_level': age_level,
|
||||
form = None
|
||||
edition.new_authors=zip(request.POST.getlist('new_author'),request.POST.getlist('new_author_relation'))
|
||||
edition.new_subjects=request.POST.getlist('new_subject')
|
||||
|
@ -577,6 +583,7 @@ def new_edition(request, work_id, edition_id, by=None):
|
|||
form.save()
|
||||
if not work:
|
||||
work= models.Work(title=form.cleaned_data['title'],language=form.cleaned_data['language'],description=form.cleaned_data['description'])
|
||||
age_level=form.cleaned_data['age_level'],
|
||||
work.save()
|
||||
edition.work=work
|
||||
edition.save()
|
||||
|
@ -585,6 +592,7 @@ def new_edition(request, work_id, edition_id, by=None):
|
|||
work.title=form.cleaned_data['title']
|
||||
work.publication_range = None # will reset on next access
|
||||
work.language = form.cleaned_data['language']
|
||||
work.age_level = form.cleaned_data['age_level']
|
||||
work.save()
|
||||
|
||||
id_msg=""
|
||||
|
|
Loading…
Reference in New Issue