implement EditionNote
parent
aafbd7c70b
commit
363c86fd94
|
@ -3,7 +3,7 @@ from selectable.registry import registry
|
||||||
|
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.db.models import Count
|
from django.db.models import Count
|
||||||
from regluit.core.models import Work, PublisherName, Edition, Subject
|
from regluit.core.models import Work, PublisherName, Edition, Subject, EditionNote
|
||||||
|
|
||||||
class OwnerLookup(ModelLookup):
|
class OwnerLookup(ModelLookup):
|
||||||
model = User
|
model = User
|
||||||
|
@ -54,8 +54,17 @@ class SubjectLookup(ModelLookup):
|
||||||
def get_query(self, request, term):
|
def get_query(self, request, term):
|
||||||
return super(SubjectLookup, self).get_query( request, term).annotate(Count('works')).order_by('-works__count')
|
return super(SubjectLookup, self).get_query( request, term).annotate(Count('works')).order_by('-works__count')
|
||||||
|
|
||||||
|
class EditionNoteLookup(ModelLookup):
|
||||||
|
model = EditionNote
|
||||||
|
search_fields = ('note__icontains',)
|
||||||
|
def create_item(self, value):
|
||||||
|
new_note, created = EditionNote.objects.get_or_create(note=value)
|
||||||
|
new_note.save()
|
||||||
|
return new_note
|
||||||
|
|
||||||
registry.register(OwnerLookup)
|
registry.register(OwnerLookup)
|
||||||
registry.register(WorkLookup)
|
registry.register(WorkLookup)
|
||||||
registry.register(PublisherNameLookup)
|
registry.register(PublisherNameLookup)
|
||||||
registry.register(EditionLookup)
|
registry.register(EditionLookup)
|
||||||
registry.register(SubjectLookup)
|
registry.register(SubjectLookup)
|
||||||
|
registry.register(EditionNoteLookup)
|
|
@ -11,11 +11,18 @@ class Migration(migrations.Migration):
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='EditionNote',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||||
|
('note', models.CharField(max_length=64, unique=True, null=True, blank=True)),
|
||||||
|
],
|
||||||
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='WorkRelation',
|
name='WorkRelation',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||||
('relation', models.CharField(max_length=15, choices=[(b'translation', b''), (b'revision', b''), (b'sequel', b''), (b'compilation', b'')])),
|
('relation', models.CharField(max_length=15, choices=[(b'translation', b'translation'), (b'revision', b'revision'), (b'sequel', b'sequel'), (b'compilation', b'compilation')])),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
|
@ -23,11 +30,6 @@ class Migration(migrations.Migration):
|
||||||
name='version',
|
name='version',
|
||||||
field=models.CharField(max_length=255, null=True),
|
field=models.CharField(max_length=255, null=True),
|
||||||
),
|
),
|
||||||
migrations.AddField(
|
|
||||||
model_name='edition',
|
|
||||||
name='note',
|
|
||||||
field=models.CharField(max_length=64, null=True),
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='work',
|
model_name='work',
|
||||||
name='age_level',
|
name='age_level',
|
||||||
|
@ -43,9 +45,14 @@ class Migration(migrations.Migration):
|
||||||
name='to_work',
|
name='to_work',
|
||||||
field=models.ForeignKey(related_name='works_related_to', to='core.Work'),
|
field=models.ForeignKey(related_name='works_related_to', to='core.Work'),
|
||||||
),
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='edition',
|
||||||
|
name='note',
|
||||||
|
field=models.ForeignKey(to='core.EditionNote', null=True),
|
||||||
|
),
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='work',
|
model_name='work',
|
||||||
name='related',
|
name='related',
|
||||||
field=models.ManyToManyField(to='core.Work', null=True, through='core.WorkRelation'),
|
field=models.ManyToManyField(related_name='reverse_related', null=True, through='core.WorkRelation', to='core.Work'),
|
||||||
),
|
),
|
||||||
]
|
]
|
|
@ -36,7 +36,7 @@ class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('core', '0003_auto_20160805_1550'),
|
('core', '0003_auto_20160816_1645'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
|
|
@ -77,6 +77,7 @@ from .bibmodels import (
|
||||||
Ebook,
|
Ebook,
|
||||||
EbookFile,
|
EbookFile,
|
||||||
Edition,
|
Edition,
|
||||||
|
EditionNote,
|
||||||
Identifier,
|
Identifier,
|
||||||
path_for_file,
|
path_for_file,
|
||||||
Publisher,
|
Publisher,
|
||||||
|
|
|
@ -763,7 +763,7 @@ class Edition(models.Model):
|
||||||
work = models.ForeignKey("Work", related_name="editions", null=True)
|
work = models.ForeignKey("Work", related_name="editions", null=True)
|
||||||
cover_image = models.URLField(null=True, blank=True)
|
cover_image = models.URLField(null=True, blank=True)
|
||||||
unglued = models.BooleanField(default=False)
|
unglued = models.BooleanField(default=False)
|
||||||
note = models.CharField(max_length=64, null=True, blank=True)
|
note = models.ForeignKey("EditionNote", null=True)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
if self.isbn_13:
|
if self.isbn_13:
|
||||||
|
@ -942,6 +942,10 @@ class Edition(models.Model):
|
||||||
def description(self):
|
def description(self):
|
||||||
return self.work.description
|
return self.work.description
|
||||||
|
|
||||||
|
class EditionNote(models.Model):
|
||||||
|
note = models.CharField(max_length=64, null=True, blank=True, unique=True)
|
||||||
|
def __unicode__(self):
|
||||||
|
return self.note
|
||||||
|
|
||||||
class Publisher(models.Model):
|
class Publisher(models.Model):
|
||||||
created = models.DateTimeField(auto_now_add=True)
|
created = models.DateTimeField(auto_now_add=True)
|
||||||
|
|
|
@ -62,6 +62,7 @@ from regluit.core.lookups import (
|
||||||
WorkLookup,
|
WorkLookup,
|
||||||
PublisherNameLookup,
|
PublisherNameLookup,
|
||||||
SubjectLookup,
|
SubjectLookup,
|
||||||
|
EditionNoteLookup,
|
||||||
)
|
)
|
||||||
from regluit.utils.localdatetime import now
|
from regluit.utils.localdatetime import now
|
||||||
from regluit.utils.fields import ISBNField
|
from regluit.utils.fields import ISBNField
|
||||||
|
@ -211,7 +212,13 @@ class EditionForm(forms.ModelForm):
|
||||||
age_level = forms.ChoiceField(choices=AGE_LEVEL_CHOICES, required=False)
|
age_level = forms.ChoiceField(choices=AGE_LEVEL_CHOICES, required=False)
|
||||||
description = forms.CharField( required=False, widget=CKEditorWidget())
|
description = forms.CharField( required=False, widget=CKEditorWidget())
|
||||||
coverfile = forms.ImageField(required=False)
|
coverfile = forms.ImageField(required=False)
|
||||||
|
note = AutoCompleteSelectField(
|
||||||
|
EditionNoteLookup,
|
||||||
|
widget=AutoCompleteSelectWidget(EditionNoteLookup, allow_new=True),
|
||||||
|
label='Edition Note',
|
||||||
|
required=False,
|
||||||
|
allow_new=True,
|
||||||
|
)
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(EditionForm, self).__init__(*args, **kwargs)
|
super(EditionForm, self).__init__(*args, **kwargs)
|
||||||
self.relators = []
|
self.relators = []
|
||||||
|
@ -238,7 +245,6 @@ class EditionForm(forms.ModelForm):
|
||||||
if not has_isbn and not has_oclc and not has_goog and not has_http and not has_doi:
|
if not has_isbn and not has_oclc and not has_goog and not has_http and not has_doi:
|
||||||
raise forms.ValidationError(_("There must be either an ISBN, a DOI, a URL or an OCLC number."))
|
raise forms.ValidationError(_("There must be either an ISBN, a DOI, a URL or an OCLC number."))
|
||||||
return self.cleaned_data
|
return self.cleaned_data
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Edition
|
model = Edition
|
||||||
exclude = ('created', 'work')
|
exclude = ('created', 'work')
|
||||||
|
|
|
@ -16,6 +16,9 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<br />
|
<br />
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if edition.note %}
|
||||||
|
{{ edition.note }}.<br />
|
||||||
|
{% endif %}
|
||||||
{% if edition.publisher %}
|
{% if edition.publisher %}
|
||||||
Publisher: <a href="{% url 'bypubname_list' edition.publisher_name.id %}">{{edition.publisher}}</a><br />
|
Publisher: <a href="{% url 'bypubname_list' edition.publisher_name.id %}">{{edition.publisher}}</a><br />
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -141,6 +141,7 @@ ul.fancytree-container {
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<p><b>Age Level</b>: {{ form.age_level.errors }}{{ form.age_level }}</p>
|
<p><b>Age Level</b>: {{ form.age_level.errors }}{{ form.age_level }}</p>
|
||||||
|
<p><b>Edition Note</b>: {{ form.note.errors }}{{ form.note }}</p>
|
||||||
<h4> Identifiers </h4>
|
<h4> Identifiers </h4>
|
||||||
{% if id_msg %} <span class="errorlist">{{ id_msg }} </span>{% endif %}
|
{% if id_msg %} <span class="errorlist">{{ id_msg }} </span>{% endif %}
|
||||||
<p> Enter 'delete' to remove the identifier. </p>
|
<p> Enter 'delete' to remove the identifier. </p>
|
||||||
|
|
11
marc/load.py
11
marc/load.py
|
@ -89,6 +89,17 @@ def stub(edition):
|
||||||
)
|
)
|
||||||
record.add_ordered_field(field245)
|
record.add_ordered_field(field245)
|
||||||
|
|
||||||
|
#edition statement
|
||||||
|
if edition.note:
|
||||||
|
field250 = pymarc.Field(
|
||||||
|
tag='250',
|
||||||
|
indicators = [' ', ' '],
|
||||||
|
subfields = [
|
||||||
|
'a', unicode(edition.note),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
record.add_ordered_field(field250)
|
||||||
|
|
||||||
# publisher, date
|
# publisher, date
|
||||||
if edition.publisher:
|
if edition.publisher:
|
||||||
field260 = pymarc.Field(
|
field260 = pymarc.Field(
|
||||||
|
|
|
@ -56,6 +56,7 @@ class AbstractEdition:
|
||||||
publisher = ''
|
publisher = ''
|
||||||
title = ''
|
title = ''
|
||||||
publication_date = ''
|
publication_date = ''
|
||||||
|
note = ''
|
||||||
|
|
||||||
# the edition should be able to report ebook downloads, with should have format and url attributes
|
# the edition should be able to report ebook downloads, with should have format and url attributes
|
||||||
def downloads(self):
|
def downloads(self):
|
||||||
|
|
Loading…
Reference in New Issue