fixed issues with null pubdates
parent
5dea6b7fea
commit
c3dcd3d294
|
@ -406,6 +406,13 @@ class Work(models.Model):
|
|||
except IndexError:
|
||||
return ''
|
||||
|
||||
@property
|
||||
def publication_date(self):
|
||||
for edition in Edition.objects.filter(work=self):
|
||||
if edition.publication_date:
|
||||
return edition.publication_date
|
||||
return ''
|
||||
|
||||
def __unicode__(self):
|
||||
return self.title
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ class BookLoaderTests(TestCase):
|
|||
|
||||
# work
|
||||
self.assertTrue(edition.work)
|
||||
|
||||
|
||||
def test_double_add(self):
|
||||
bookloader.add_by_isbn('0441012035')
|
||||
|
@ -75,6 +76,9 @@ class BookLoaderTests(TestCase):
|
|||
edition = tasks.populate_edition.run(edition)
|
||||
self.assertTrue(edition.work.editions.all().count() > 20)
|
||||
self.assertTrue(edition.work.subjects.all().count() > 10)
|
||||
self.assertTrue(edition.work.publication_date)
|
||||
edition.publication_date = None
|
||||
self.assertTrue(edition.work.publication_date)
|
||||
|
||||
def test_merge_works(self):
|
||||
# add two editions and see that there are two stub works
|
||||
|
|
|
@ -23,7 +23,7 @@ Please fix the following before launching your campaign:
|
|||
<div class="book-detail-info">
|
||||
<h2 class="book-name">Title: <a href="{% url work campaign.work.id %}">{{ campaign.work.title }}</a></h2>
|
||||
<h3 class="book-author">Authors: {{ campaign.work.author }}</h3>
|
||||
<h3 class="book-year">Published: {{ campaign.work.editions.all.0.publication_date }}</h3>
|
||||
<h3 class="book-year">Published: {{ campaign.work.publication_date }}</h3>
|
||||
<h3 class="book-author">Language: {{ campaign.work.editions.all.0.language }}</h3>
|
||||
<p>Target Price: {{ campaign.pretarget }}</p>
|
||||
<p>End Date: {{ campaign.predeadline }}</p>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<div class="book-detail-info">
|
||||
<h2 class="book-name">{{ work.title }}</h2>
|
||||
<h3 class="book-author">{{ work.author }}</h3>
|
||||
<h3 class="book-year">{{ work.editions.all.0.publication_date }}</h3>
|
||||
<h3 class="book-year">{{ work.publication_date }}</h3>
|
||||
<div class="find-book">
|
||||
<label>Find it here</label>
|
||||
<!-- todo: these should be a real thing -->
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<div class="book-detail-info">
|
||||
<h2 class="book-name">Title: {{ work.title }}</h2>
|
||||
<h3 class="book-author">Authors: {{ work.author }}</h3>
|
||||
<h3 class="book-year">Published: {{ work.editions.all.0.publication_date }}</h3>
|
||||
<h3 class="book-year">Published: {{ work.publication_date }}</h3>
|
||||
<h3 class="book-author">Language: {{ work.editions.all.0.language }}</h3>
|
||||
</div>
|
||||
<form action="#">
|
||||
|
|
|
@ -97,7 +97,7 @@ def work(request, work_id, action='display'):
|
|||
except:
|
||||
pledged = None
|
||||
try:
|
||||
pubdate = work.editions.all()[0].publication_date[:4]
|
||||
pubdate = work.publication_date[:4]
|
||||
except IndexError:
|
||||
pubdate = 'unknown'
|
||||
if not request.user.is_anonymous():
|
||||
|
|
Loading…
Reference in New Issue