Merge branch 'master' of github.com:Gluejar/regluit
commit
bf23281340
|
@ -406,6 +406,13 @@ class Work(models.Model):
|
||||||
except IndexError:
|
except IndexError:
|
||||||
return ''
|
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):
|
def __unicode__(self):
|
||||||
return self.title
|
return self.title
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ class BookLoaderTests(TestCase):
|
||||||
|
|
||||||
# work
|
# work
|
||||||
self.assertTrue(edition.work)
|
self.assertTrue(edition.work)
|
||||||
|
|
||||||
|
|
||||||
def test_double_add(self):
|
def test_double_add(self):
|
||||||
bookloader.add_by_isbn('0441012035')
|
bookloader.add_by_isbn('0441012035')
|
||||||
|
@ -75,6 +76,9 @@ class BookLoaderTests(TestCase):
|
||||||
edition = tasks.populate_edition.run(edition)
|
edition = tasks.populate_edition.run(edition)
|
||||||
self.assertTrue(edition.work.editions.all().count() > 20)
|
self.assertTrue(edition.work.editions.all().count() > 20)
|
||||||
self.assertTrue(edition.work.subjects.all().count() > 10)
|
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):
|
def test_merge_works(self):
|
||||||
# add two editions and see that there are two stub works
|
# 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">
|
<div class="book-detail-info">
|
||||||
<h2 class="book-name">Title: <a href="{% url work campaign.work.id %}">{{ campaign.work.title }}</a></h2>
|
<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-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>
|
<h3 class="book-author">Language: {{ campaign.work.editions.all.0.language }}</h3>
|
||||||
<p>Target Price: {{ campaign.pretarget }}</p>
|
<p>Target Price: {{ campaign.pretarget }}</p>
|
||||||
<p>End Date: {{ campaign.predeadline }}</p>
|
<p>End Date: {{ campaign.predeadline }}</p>
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
<div class="book-detail-info">
|
<div class="book-detail-info">
|
||||||
<h2 class="book-name">{{ work.title }}</h2>
|
<h2 class="book-name">{{ work.title }}</h2>
|
||||||
<h3 class="book-author">{{ work.author }}</h3>
|
<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">
|
<div class="find-book">
|
||||||
<label>Find it here</label>
|
<label>Find it here</label>
|
||||||
<!-- todo: these should be a real thing -->
|
<!-- todo: these should be a real thing -->
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<div class="book-detail-info">
|
<div class="book-detail-info">
|
||||||
<h2 class="book-name">Title: {{ work.title }}</h2>
|
<h2 class="book-name">Title: {{ work.title }}</h2>
|
||||||
<h3 class="book-author">Authors: {{ work.author }}</h3>
|
<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>
|
<h3 class="book-author">Language: {{ work.editions.all.0.language }}</h3>
|
||||||
</div>
|
</div>
|
||||||
<form action="#">
|
<form action="#">
|
||||||
|
|
|
@ -97,7 +97,7 @@ def work(request, work_id, action='display'):
|
||||||
except:
|
except:
|
||||||
pledged = None
|
pledged = None
|
||||||
try:
|
try:
|
||||||
pubdate = work.editions.all()[0].publication_date[:4]
|
pubdate = work.publication_date[:4]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
pubdate = 'unknown'
|
pubdate = 'unknown'
|
||||||
if not request.user.is_anonymous():
|
if not request.user.is_anonymous():
|
||||||
|
|
Loading…
Reference in New Issue