all authors now display
had to harden the work model against works without editions to pass tests Lagos 2060 will need 1st author to change back added work.authors_short to work model and to search work mock model used work #415 as an example of a work with 3 authorspull/1/head
parent
f101f0dc20
commit
e540bb7a56
|
@ -1066,7 +1066,7 @@ class Work(models.Model):
|
|||
|
||||
def cover_image_thumbnail(self):
|
||||
try:
|
||||
if self.preferred_edition.cover_image_thumbnail():
|
||||
if self.preferred_edition and self.preferred_edition.cover_image_thumbnail():
|
||||
return self.preferred_edition.cover_image_thumbnail()
|
||||
except IndexError:
|
||||
pass
|
||||
|
@ -1074,19 +1074,29 @@ class Work(models.Model):
|
|||
|
||||
def authors(self):
|
||||
# assumes that they come out in the same order they go in!
|
||||
return self.preferred_edition.authors.all()
|
||||
if self.preferred_edition and self.preferred_edition.authors.all().count()>0:
|
||||
return self.preferred_edition.authors.all()
|
||||
for edition in self.editions.all():
|
||||
if edition.authors.all().count()>0:
|
||||
return edition.authors.all()
|
||||
return []
|
||||
|
||||
def author(self):
|
||||
# assumes that they come out in the same order they go in!
|
||||
if self.authors().count()>0:
|
||||
return self.authors()[0].name
|
||||
return ''
|
||||
|
||||
# just in case that particular edition has no author
|
||||
try:
|
||||
return list(Author.objects.filter(editions__work=self).all()).authors[0].name
|
||||
except:
|
||||
return ''
|
||||
|
||||
def authors_short(self):
|
||||
# assumes that they come out in the same order they go in!
|
||||
if self.authors().count()==1:
|
||||
return self.authors()[0].name
|
||||
elif self.authors().count()==2:
|
||||
return "%s and %s" % (self.authors()[0].name, self.authors()[1].name)
|
||||
elif self.authors().count()>2:
|
||||
return "%s et al." % self.authors()[0].name
|
||||
return ''
|
||||
|
||||
def last_campaign(self):
|
||||
# stash away the last campaign to prevent repeated lookups
|
||||
if hasattr(self, '_last_campaign_'):
|
||||
|
@ -1102,7 +1112,7 @@ class Work(models.Model):
|
|||
if self.last_campaign():
|
||||
if self.last_campaign().edition:
|
||||
return self.last_campaign().edition
|
||||
return self.editions.all()[0]
|
||||
return self.editions.all()[0] if self.editions.all().count() else None
|
||||
|
||||
def last_campaign_status(self):
|
||||
campaign = self.last_campaign()
|
||||
|
|
|
@ -19,8 +19,14 @@ def gluejar_search(q, user_ip='69.243.24.29', page=1):
|
|||
'googlebooks_id': item.get('id')}
|
||||
|
||||
# TODO: allow multiple authors
|
||||
if v.has_key('authors') and len(v['authors']) > 0:
|
||||
if v.has_key('authors') and len(v['authors']) == 1 :
|
||||
r['author'] = r['authors_short'] = v['authors'][0]
|
||||
elif v.has_key('authors') and len(v['authors']) > 2:
|
||||
r['author'] = v['authors'][0]
|
||||
r['authors_short'] = '%s et al.' % v['authors'][0]
|
||||
elif v.has_key('authors') and len(v['authors']) == 2:
|
||||
r['author'] = v['authors'][0]
|
||||
r['authors_short'] = '%s and %s' % (v['authors'][0], v['authors'][1])
|
||||
else:
|
||||
r['author'] = ""
|
||||
r['isbn_13'] = None
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
{% with work.first_ebook as first_ebook %}
|
||||
{% with work.last_campaign.supporters as supporters %}
|
||||
{% with work.cover_image_thumbnail as thumbnail %}
|
||||
{% with work.author as author %}
|
||||
{% with work.authors_short as author %}
|
||||
{% with work.title as title %}
|
||||
{% with work.last_campaign as last_campaign %}
|
||||
{% with work.last_campaign.status as status %}
|
||||
|
@ -192,7 +192,7 @@
|
|||
<div class="title">
|
||||
<a href="{% if workid %}{% url work workid %}{% else %}{% url googlebooks googlebooks_id %}{% endif %}">{{ title }}</a>
|
||||
</div>
|
||||
<div class="listview author {{ author }}">{{ author }}</div>
|
||||
<div class="listview author">{{ author }}</div>
|
||||
</div>
|
||||
|
||||
{% comment %}same logic as above{% endcomment %}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<h3> Work being claimed </h3>
|
||||
<ul>
|
||||
<li>Title: <a href="{% url work work.id %}">{{ work.title }}</a></li>
|
||||
<li>Author: {{ work.author }}</li>
|
||||
<li>Author: {{ work.authors_short }}</li>
|
||||
</ul>
|
||||
{% if active_claims.count %}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
<!-- trim here -->
|
||||
<section epub:type="copyright-page" id="copyright-page">
|
||||
<div class="agate-info">
|
||||
<p>© {{ campaign.work.preferred_edition.publication_date }} by {{ campaign.work.author }}</p>
|
||||
<p>© {{ campaign.work.preferred_edition.publication_date }} by {{ campaign.work.authors_short }}</p>
|
||||
<p>ISBN: {{ campaign.work.preferred_edition.isbn_13 }} .</p>
|
||||
<p>URI: <a href="https://unglue.it/work/{{ campaign.work.id }}/">https://unglue.it/work/{{ campaign.work.id }}/</a> (this work).</p>
|
||||
<p><img src="images/unglueitlogo.png" alt="unglue.it logo" /></p>
|
||||
|
|
|
@ -72,7 +72,7 @@ Please fix the following before launching your campaign:
|
|||
<h2 class="book-name">{{ work.title }}</h2>
|
||||
<div>
|
||||
<div class="pubinfo">
|
||||
<h3 class="book-author">{{ work.author }}</h3>
|
||||
<h3 class="book-author">{{ work.authors_short }}</h3>
|
||||
<h3 class="book-year">{{ work.publication_date_year }}</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<h2 class="book-name"><a href="{% url work work.id %}">{{ work.title }}</a></h2>
|
||||
<div>
|
||||
<div class="pubinfo">
|
||||
<h3 class="book-author">{{ work.author }}</h3>
|
||||
<h3 class="book-author">{{ work.authors_short }}</h3>
|
||||
<h3 class="book-year">{{ work.publication_date_year }}</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
<h2 class="book-name"><a href="{% url work work.id %}">{{ work.title }}</a></h2>
|
||||
<div>
|
||||
<div class="pubinfo">
|
||||
<h3 class="book-author">{{ work.author }}</h3>
|
||||
<h3 class="book-author">{{ work.authors_short }}</h3>
|
||||
<h3 class="book-year">{{ work.publication_date_year }}</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -91,7 +91,7 @@ Any questions not covered here? Please email us at <a href="mailto:rights@gluej
|
|||
<dl>
|
||||
{% for claim in claims %}
|
||||
<dt>Title: <a href="{% url work work_id=claim.work.id %}">{{claim.work.title }}</a> (work #{{ claim.work.id }})</dt>
|
||||
<dd>Author: {{claim.work.author }}
|
||||
<dd>Author: {{claim.work.authors_short }}
|
||||
<br />On Behalf of: {{ claim.rights_holder.rights_holder_name }}
|
||||
<br />PSA #: {{ claim.rights_holder.id }}
|
||||
<br />Date of Claim : {{ claim.created }}
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
<dl>
|
||||
{% for claim, claim_form in pending %}
|
||||
<dt>Title: <a href="{% url work work_id=claim.work.id %}">{{claim.work.title }}</a></dt>
|
||||
<dd>Author: {{claim.work.author }}</dd>
|
||||
<dd>Author: {{claim.work.authors_short }}</dd>
|
||||
<dd>By: {{ claim.user.username }}</dd>
|
||||
<dd>On Behalf of: {{ claim.rights_holder.rights_holder_name }}</dd>
|
||||
<dd>PSA #: {{ claim.rights_holder.id }}</dd>
|
||||
|
@ -61,7 +61,7 @@
|
|||
<dl>
|
||||
{% for claim in active_data %}
|
||||
<dt>Title: <a href="{% url work work_id=claim.work.id %}">{{claim.work.title }}</a></dt>
|
||||
<dd>Author: {{claim.work.author }}</dd>
|
||||
<dd>Author: {{claim.work.authors_short }}</dd>
|
||||
<dd>By: {{ claim.user.username }}</dd>
|
||||
<dd>On Behalf of: {{ claim.rights_holder.rights_holder_name }}</dd>
|
||||
<dd>PSA #: {{ claim.rights_holder.id }}</dd>
|
||||
|
|
|
@ -86,7 +86,19 @@
|
|||
<h2 class="book-name" itemprop="name">{{ work.title }}</h2>
|
||||
<div>
|
||||
<div class="pubinfo">
|
||||
<h3 class="book-author" itemprop="author">{{ work.author }}</h3>
|
||||
<h3 class="book-author">
|
||||
<span itemprop="author">{{ work.authors.0.name }}</span>
|
||||
{% ifequal work.authors.count 2 %}
|
||||
and <span itemprop="author">{{ work.authors.1.name }}
|
||||
{% endifequal %}
|
||||
{% if work.authors.count > 2 %}
|
||||
{% for author in work.authors %}
|
||||
{% if not forloop.first %}
|
||||
, <span itemprop="author">{{ author.name }} </span>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</h3>
|
||||
<h3 class="book-year">
|
||||
{% if work.last_campaign.publisher %}
|
||||
<span itemprop="publisher"><a href="{% url bypubname_list work.last_campaign.publisher.name.id %}">{{ work.last_campaign.publisher }}</a></span>
|
||||
|
|
Loading…
Reference in New Issue