Merge branch 'master' into production
commit
edf328418d
|
@ -33,7 +33,9 @@ def onix_feed_for_work(work):
|
|||
feed = etree.fromstring(feed_xml)
|
||||
feed.append(header(work))
|
||||
for edition in models.Edition.objects.filter(work=work,ebooks__isnull=False).distinct():
|
||||
feed.append(product(edition))
|
||||
edition_prod = product(edition)
|
||||
if edition_prod:
|
||||
feed.append(product(edition))
|
||||
return etree.tostring(feed, pretty_print=True)
|
||||
|
||||
def header(facet=None):
|
||||
|
|
|
@ -23123,5 +23123,11 @@ bisac= {
|
|||
"pref_label": "Political Science / Terrorism",
|
||||
"notation": "POL037000",
|
||||
"alt_label": []
|
||||
}
|
||||
},
|
||||
"History / Europe / Greece": {
|
||||
"related": [],
|
||||
"pref_label": "History / Europe / Greece",
|
||||
"notation": "HIS042000",
|
||||
"alt_label": []
|
||||
},
|
||||
}
|
|
@ -413,7 +413,6 @@ def relate_isbn(isbn, cluster_size=1):
|
|||
elif related_edition.work.id != edition.work.id:
|
||||
logger.debug("merge_works path 1 %s %s", edition.work.id, related_edition.work.id )
|
||||
merge_works(related_edition.work, edition.work)
|
||||
|
||||
if related_edition.work.editions.count()>cluster_size:
|
||||
return related_edition.work
|
||||
return edition.work
|
||||
|
@ -452,7 +451,7 @@ def add_related(isbn):
|
|||
related_edition.save()
|
||||
elif related_edition.work.id != work.id:
|
||||
logger.debug("merge_works path 1 %s %s", work.id, related_edition.work.id )
|
||||
merge_works(work, related_edition.work)
|
||||
work = merge_works(work, related_edition.work)
|
||||
else:
|
||||
if other_editions.has_key(related_language):
|
||||
other_editions[related_language].append(related_edition)
|
||||
|
@ -469,12 +468,15 @@ def add_related(isbn):
|
|||
works_to_merge = set([ed.work for ed in lang_group[1:]]) - set([lang_edition.work])
|
||||
for w in works_to_merge:
|
||||
logger.debug("merge_works path 2 %s %s", lang_edition.work.id, w.id )
|
||||
merge_works(lang_edition.work, w)
|
||||
models.WorkRelation.objects.get_or_create(to_work=lang_edition.work, from_work=work, relation='translation')
|
||||
merged_work = merge_works(lang_edition.work, w)
|
||||
models.WorkRelation.objects.get_or_create(
|
||||
to_work=lang_group[0].work,
|
||||
from_work=work,
|
||||
relation='translation'
|
||||
)
|
||||
|
||||
return new_editions
|
||||
|
||||
|
||||
def thingisbn(isbn):
|
||||
"""given an ISBN return a list of related edition ISBNs, according to
|
||||
Library Thing. (takes isbn_10 or isbn_13, returns isbn_10, except for 979 isbns, which come back as isbn_13')
|
||||
|
@ -492,7 +494,7 @@ def merge_works(w1, w2, user=None):
|
|||
logger.info("merging work %s into %s", w2.id, w1.id)
|
||||
# don't merge if the works are the same or at least one of the works has no id (for example, when w2 has already been deleted)
|
||||
if w1 is None or w2 is None or w1.id == w2.id or w1.id is None or w2.id is None:
|
||||
return
|
||||
return w1
|
||||
if w2.selected_edition != None and w1.selected_edition == None:
|
||||
#the merge should be reversed
|
||||
temp = w1
|
||||
|
@ -546,9 +548,14 @@ def merge_works(w1, w2, user=None):
|
|||
for subject in w2.subjects.all():
|
||||
if subject not in w1.subjects.all():
|
||||
w1.subjects.add(subject)
|
||||
|
||||
|
||||
for work_relation in w2.works_related_to.all():
|
||||
work_relation.to_work = w1
|
||||
work_relation.save()
|
||||
for work_relation in w2.works_related_from.all():
|
||||
work_relation.from_work = w1
|
||||
work_relation.save()
|
||||
w2.delete()
|
||||
return w1
|
||||
|
||||
def detach_edition(e):
|
||||
"""will detach edition from its work, creating a new stub work. if remerge=true, will see if there's another work to attach to
|
||||
|
|
|
@ -130,9 +130,9 @@ def add_all_isbns(isbns, work, language=None, title=None):
|
|||
first_edition = first_edition if first_edition else edition
|
||||
if work and (edition.work.id != work.id):
|
||||
if work.created < edition.work.created:
|
||||
merge_works(work, edition.work)
|
||||
work = merge_works(work, edition.work)
|
||||
else:
|
||||
merge_works(edition.work, work)
|
||||
work = merge_works(edition.work, work)
|
||||
else:
|
||||
work = edition.work
|
||||
return first_edition
|
||||
|
|
|
@ -220,9 +220,7 @@ def load_from_books(books):
|
|||
for isbn in isbns:
|
||||
edition = add_by_isbn_from_google(isbn, work=work)
|
||||
if edition and edition.work != work:
|
||||
merge_works(work, edition.work)
|
||||
work = work if work.pk is not None else edition.work
|
||||
edition.work=work # because integrity errors if not
|
||||
work = merge_works(work, edition.work)
|
||||
if not edition:
|
||||
edition= Edition(title=title, work=work)
|
||||
edition.save()
|
||||
|
|
|
@ -1034,6 +1034,7 @@ class Campaign(models.Model):
|
|||
url=ebf.file.url,
|
||||
version_label=ebf.version['label'],
|
||||
version_iter=ebf.version['iter'],
|
||||
filesize=ebf.file.size,
|
||||
)
|
||||
ebf.ebook = ebook
|
||||
ebf.save()
|
||||
|
@ -1041,7 +1042,8 @@ class Campaign(models.Model):
|
|||
|
||||
for old_ebf in self.work.ebookfiles().filter(asking=True).exclude(pk__in=new_ebf_pks):
|
||||
obsolete = Ebook.objects.filter(url=old_ebf.file.url)
|
||||
old_ebf.ebook.deactivate()
|
||||
if old_ebf.ebook:
|
||||
old_ebf.ebook.deactivate()
|
||||
old_ebf.file.delete()
|
||||
old_ebf.delete()
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ def isbn_cleaner(value):
|
|||
if value == 'delete':
|
||||
return value
|
||||
if not value:
|
||||
raise forms.ValidationError('no identifier value found')
|
||||
raise ValidationError('no identifier value found')
|
||||
elif value == 'delete':
|
||||
return value
|
||||
isbn=ISBN(value)
|
||||
|
|
|
@ -204,11 +204,9 @@ ul.fancytree-container {
|
|||
</p>
|
||||
|
||||
<p><b>Cover Image</b>: <br />
|
||||
{% if edition.cover_image %}
|
||||
<img src="{{edition.cover_image}}" /><br />
|
||||
{% else %}
|
||||
[ no cover specified for this edition ]<br />
|
||||
{% endif %}
|
||||
<div class="cover-image">
|
||||
<img src="{{edition.cover_image_thumbnail}}" />
|
||||
</div>
|
||||
{{ form.cover_image.errors }}{{ form.cover_image }}{{ form.cover_image.help_text }}
|
||||
(<i>Enter a URL for an image, at least 300 px wide. The image will be scaled to the proportions of a 6x9 cover. </i>)<br />
|
||||
OR...<br />
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
<div class="clearfix">
|
||||
<div class="editions">
|
||||
{% if edition.googlebooks_id %}
|
||||
<div class="image">
|
||||
<img src="{{ edition.cover_image_small }}" title="edition cover" alt="edition cover" />
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="book-cover">
|
||||
<img src="{{ edition.cover_image_thumbnail }}" title="edition cover" alt="edition cover" />
|
||||
</div>
|
||||
<div class="metadata" id="edition_{{edition.id}}">
|
||||
{% if edition.title != work.title %}
|
||||
Title: {{edition.title}}<br />
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
<div id="content-block">
|
||||
<div class="book-detail">
|
||||
{% if work.uses_google_cover %}
|
||||
<div id="book-detail-img">
|
||||
<div class="book-cover" id="book-detail-img">
|
||||
<a href="{{ work.googlebooks_url }}">
|
||||
<img src="{{ work.cover_image_thumbnail }}" alt="Find {{ work.title }} at Google Books" title="Find {{ work.title }} at Google Books" width="131" height="192" /></a>
|
||||
</div>
|
||||
|
|
|
@ -465,6 +465,7 @@ def edition_uploads(request, edition_id):
|
|||
)
|
||||
form.instance.ebook = new_ebook
|
||||
form.instance.ebook.set_next_iter()
|
||||
form.instance.save()
|
||||
|
||||
else:
|
||||
context['upload_error'] = form.errors
|
||||
|
@ -968,7 +969,7 @@ class MergeView(FormView):
|
|||
context = self.get_context_data()
|
||||
if self.request.POST.has_key('confirm_merge_works'):
|
||||
context['old_work_id'] = other_work.id
|
||||
merge_works(self.work, other_work, self.request.user)
|
||||
self.work = merge_works(self.work, other_work, self.request.user)
|
||||
context['merge_complete'] = True
|
||||
else:
|
||||
context['form'] = WorkForm(initial={'other_work':other_work})
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -9,7 +9,7 @@
|
|||
display:block;
|
||||
}
|
||||
|
||||
#book-detail-img {
|
||||
.book-cover {
|
||||
float: left;
|
||||
margin-right:10px;
|
||||
width:151px;
|
||||
|
|
Loading…
Reference in New Issue