adapt work and book panel to t4u

also: start migration to “Fave”
also: start showing faves on ready to read books
also: on panel view, fixed the num-wishes link was unclickable
but: the fave count looks ugly
pull/1/head
eric 2014-02-11 11:37:39 -05:00
parent bb676f9500
commit 36ebc83a5b
7 changed files with 145 additions and 64 deletions

View File

@ -268,6 +268,13 @@ class Offer(models.Model):
def days_per_copy(self):
return Decimal(float(self.price) / self.work.last_campaign().dollar_per_day )
@property
def get_thanks_display(self):
if self.license == LIBRARY:
return 'Suggested contribution for libraries'
else:
return 'Suggested contribution for individuals'
class Acq(models.Model):
"""
Short for Acquisition, this is a made-up word to describe the thing you acquire when you buy or borrow an ebook

View File

@ -13,7 +13,7 @@
{% with work.id as workid %}
{% with request.user.wishlist.works.all as wishlist %}
{% purchased %}{% lib_acqs %}{% bookpanel %}
<div class="thewholebook listview tabs {% if first_ebook or status == 'SUCCESSFUL' %}tabs-1{% else %}{% if status == 'ACTIVE' %}tabs-2{% else %}tabs-3{% endif %}{% endif %}">
<div class="thewholebook listview tabs {% if tab_override %}{{tab_override}}{% else %}{% if first_ebook or status == 'SUCCESSFUL' %}tabs-1{% else %}{% if status == 'ACTIVE' %}tabs-2{% else %}tabs-3{% endif %}{% endif %}{% endif %}">
<div class="listview book-list">
<div class="listview panelback side2">
{% comment %} hover state of panel {% endcomment %}
@ -52,7 +52,7 @@
{% endif %}{% endif %}{% endif %}
</div>
<div class="add_button">
{% include "book_panel_addbutton.html" %}
{% include "book_panel_addbutton.html" %}
</div>
<div class="white_text bottom_button" >
{% if purchased %}
@ -92,11 +92,14 @@
<p><b>${{ work.last_campaign.current_total|floatformat:0|intcomma }}</b> raised</p>
<p><b>${{ work.last_campaign.target|floatformat:0|intcomma }}</b> needed</p>
<p>by {{ deadline|naturalday:"M d, Y" }}</p>
{% else %}
{% else %}{% ifequal work.last_campaign.type 2 %}
<p><b>${{ work.last_campaign.left|floatformat:0|intcomma }}</b> needed</p>
<p>will unglue on </p>
<p>{{ work.last_campaign.cc_date|naturalday:"M d, Y" }}</p>
{% endifequal %}
{% else %}{% ifequal work.last_campaign.type 3 %}
<p><b>${{ work.last_campaign.current_total|floatformat:0|intcomma }}</b> raised</p>
<p><b>${{ work.last_campaign.supporters_count }}</b> supporters</p>
{% endifequal %}{% endifequal %}{% endifequal %}
{% endif %}
</div>
</div>
@ -111,13 +114,15 @@
<div class="white_text bottom_button" >
{% ifequal work.last_campaign.type 1 %}
<a href="{% url pledge work_id=workid %}"><span class="read_itbutton pledge button_text"><span>Pledge</span></span></a>
{% else %}
{% else %}{% ifequal work.last_campaign.type 2 %}
{% if in_library %}
<a href="{% url purchase work_id=workid %}"><span class="read_itbutton pledge button_text"><span>Reserve It</span></span></a>
{% else %}
<a href="{% url purchase work_id=workid %}"><span class="read_itbutton pledge button_text"><span>Purchase</span></span></a>
{% endif %}
{% endifequal %}
{% else %}{% ifequal work.last_campaign.type 3 %}
<a href="{% url thank workid %}" class="hijax"><span class="read_itbutton button_text"><span>Read it Now</span></span></a>
{% endifequal %}{% endifequal %}{% endifequal %}
</div>
{% endif %}
@ -143,10 +148,11 @@
<p>{{ deadline }}</p>
<p>Watch for a new campaign.</p>
{% endif %}{% endif %}{% endif %}{% endif %}
</div>
{% include "book_panel_addbutton.html" %}
</div>
</div>
<div class="white_text bottom_button">
{% include "book_panel_addbutton.html" %}
{% include "num_wishes.html" %}
</div>
{% endif %}{% endif %}
{% else %}
@ -164,19 +170,19 @@
{% if first_ebook %}
<b>AVAILABLE!</b>
<div class="add_button">
{% include "book_panel_addbutton.html" %}
{% include "book_panel_addbutton.html" %}
</div>
{% else %}
<p>No campaign yet.</p><br /><p>But if lots of ungluers wishlist this book, maybe there will be!</p>
<p>No campaign yet.</p><br /><p>But if lots of ungluers fave this book, maybe there will be!</p>
{% endif %}
{% include "book_panel_addbutton.html" %}
</div>
</div>
<div class="white_text bottom_button">
{% if first_ebook %}
<a href="{% url download workid %}" class="hijax"><span class="read_itbutton button_text"><span>Read it Now</span></span></a>
{% else %}
{% include "book_panel_addbutton.html" %}
{% include "num_wishes.html" %}
{% endif %}
</div>
@ -206,13 +212,13 @@
</div>
{% else %}{% if request.user.is_anonymous %}
<div class="listview panelfront side1 create-account">
<span title="{% if workid %}{% url work workid %}{% else %}{% url googlebooks googlebooks_id %}{% endif %}">Login to Add</span>
<span title="{% if workid %}{% url work workid %}{% else %}{% url googlebooks googlebooks_id %}{% endif %}">Login to Fave</span>
</div>
{% else %}{% if work in wishlist %}
{% ifequal supporter request.user %}
{% comment %} used only on your own supporter page. {% endcomment %}
<div class="listview panelfront side1 remove-wishlist">
<span id="l{{ workid }}">Un-list</span>
<span id="l{{ workid }}">Un-Fave</span>
</div>
{% else %}
<div class="listview panelfront side1 on-wishlist">
@ -223,40 +229,56 @@
{% else %}{% if request.user.id in supporters %}
<span>Pledged!</span>
{% else %}
<span>On My List!</span>
<span>Faved!</span>
{% endif %}{% endif %}{% endif %}
</div>
{% endifequal %}
{% else %}
<div class="listview panelfront side1 add-wishlist">
{% if on_search_page %}
<span class="gb_id" id="l{{ googlebooks_id }}">Add to My List</span>
<span class="gb_id" id="l{{ googlebooks_id }}">Fave</span>
{% else %}
<span class="work_id" id="l{{ workid }}">Add to My List</span>
<span class="work_id" id="l{{ workid }}">Fave</span>
{% endif %}
</div>
{% endif %}{% endif %}{% endif %}{% endif %}
<div class="listview panelfront side1 booklist-status">
{% ifequal status "ACTIVE" %}
{% if in_library %}
{% if borrowed %}
<span class="booklist-status-text">{{ borrowed.expires|date:"M j, Y" }}</span>
{% else %}
<span class="booklist-status-text" style="line-height:19px">available<br />{{ next_acq.refreshes|date:"M j, Y" }}</span>
{% endif %}
{% else %}{% ifequal work.last_campaign.type 1 %}
<span class="booklist-status-text"><b>${{ work.last_campaign.current_total|floatformat:0|intcomma }}</b>/<b>${{ work.last_campaign.target|floatformat:0|intcomma }}</b></span>
{% else %}
<span class="booklist-status-text"><b>${{ work.last_campaign.left|floatformat:0|intcomma }}</b> to go</span>
{% endifequal %}{% endif %}
{% ifequal work.last_campaign.type 1 %}
<div class="booklist-status-label">{{ work.percent_of_goal }}%</div>
{% endifequal %}
{% ifequal work.last_campaign.type 2 %}
{% if in_library %}
{% if borrowed %}
<span class="booklist-status-text">{{ borrowed.expires|date:"M j, Y" }}</span>
{% else %}
<span class="booklist-status-text" style="line-height:19px">available<br />
{% if next_acq.refreshes %}
{{ next_acq.refreshes|date:"M j, Y" }}
{% else %}
now
{% endif %}
</span>
{% endif %}
{% else %}
<div class="booklist-status-label"><b>{{ work.percent_of_goal }}%</b> of goal</div>
{% endif %}
{% endifequal %}
{% ifequal work.last_campaign.type 3 %}
{% include 'num_wishes.html' %}
{% endifequal %}
{% else %}{% ifequal status "INITIALIZED" %}
<span class="booklist-status-label">Status:&nbsp;</span><span class="booklist-status-text">Coming soon!</span>
{% else %}{% ifequal status "SUCCESSFUL" %}
{% if not first_ebook %}
<span class="booklist-status-text">Ebook coming soon</span>
{% else %}
<span class="booklist-status-label"></span>
{% include 'num_wishes.html' %}
{% endif %}
{% else %}
{% if first_ebook %}
{% include 'num_wishes.html' %}
{% endif %}
{% endifequal %}{% endifequal %}{% endifequal %}
</div>
@ -283,11 +305,7 @@
<div class="booklist-status-label panel">{{ work.percent_of_goal }}%</div>
{% endif %}
{% else %}
{% if work.num_wishes %}
<a href="{% if workid %}{% url work workid %}{% else %}{% url googlebooks googlebooks_id %}{% endif %}?tab=3" class="nobold"><span class="rounded"><span class="grey"><span class="panelnope">Listed by&nbsp;</span>{{ work.num_wishes }}</span></span></a>
{% else %}
<a href="{% if workid %}{% url work workid %}{% else %}{% url googlebooks googlebooks_id %}{% endif %}?tab=3" class="nobold"><span class="rounded"><span class="grey"><span class="panelnope">Listed by&nbsp;</span>0</span></span></a>
{% endif %}
{% include "num_wishes.html" %}
{% endif %}{% endif %}{% endif %}{% endif %}
</div>

View File

@ -10,7 +10,7 @@
{% endcomment %}
{% if request.user.is_anonymous %}
<div class="moreinfo create-account">
<span title="{% if workid %}{% url work workid %}{% else %}{% url googlebooks googlebooks_id %}{% endif %}">Login to Add</span>
<span title="{% if workid %}{% url work workid %}{% else %}{% url googlebooks googlebooks_id %}{% endif %}">Login to Fave</span>
</div>
{% else %}{% if request.user.id in supporters %}
<div class="moreinfo on-wishlist">
@ -19,24 +19,24 @@
{% else %}{% ifequal supporter request.user %}
{% if wishlist %}
<div class="moreinfo remove-wishlist">
<span id="p{{ workid }}">Un-list</span>
<span id="p{{ workid }}">Un-Fave</span>
</div>
{% else %}
{% comment %} on the empty-wishlist slideshow {% endcomment %}
<div class="moreinfo add-wishlist">
<span class="work_id" id="p{{ workid }}">Add&nbsp;to&nbsp;My&nbsp;List</span>
<span class="work_id" id="p{{ workid }}">Add&nbsp;to&nbsp;My&nbsp;Faves</span>
</div>
{% endif %}
{% else %}{% if work in wishlist %}
<div class="moreinfo on-wishlist">
<a href="/#">On My List!</a>
<a href="/#">A Fave!</a>
</div>
{% else %}
<div class="moreinfo add-wishlist">
{% if on_search_page %}
<span class="gb_id" id="p{{ googlebooks_id }}">Add&nbsp;to&nbsp;My&nbsp;List</span>
<span class="gb_id" id="p{{ googlebooks_id }}">Add&nbsp;to&nbsp;My&nbsp;Faves</span>
{% else %}
<span class="work_id" id="p{{ workid }}">Add&nbsp;to&nbsp;My&nbsp;List</span>
<span class="work_id" id="p{{ workid }}">Add&nbsp;to&nbsp;My&nbsp;Faves</span>
{% endif %}
</div>
{% endif %}{% endifequal %}{% endif %}{% endif %}

View File

@ -0,0 +1,9 @@
{% if work.last_campaign.type == 3 %}
<a href="{% url work workid %}?tab=3" class="nobold"><span class="rounded"><span class="grey"><span class="">Thanked by&nbsp;</span>{{ work.last_campaign.supporters_count }}</span></span></a>
{% else %}
{% if work.num_wishes %}
<a href="{% if workid %}{% url work workid %}{% else %}{% url googlebooks googlebooks_id %}{% endif %}?tab=3" class="nobold"><span class="rounded"><span class="grey"><span class="">Faved by&nbsp;</span>{{ work.num_wishes }}</span></span></a>
{% else %}
<a href="{% if workid %}{% url work workid %}{% else %}{% url googlebooks googlebooks_id %}{% endif %}?tab=3" class="nobold"><span class="rounded"><span class="grey"><span class="">No Faves</span></a>
{% endif %}
{% endif %}

View File

@ -357,9 +357,9 @@ function highlightTarget(targetdiv) {
{% lazy_paginate 20 works_active using "works_active" %}
{% for work in works_active %}
<div class="{% cycle 'row1' 'row2' %}">
{% with work.googlebooks_id as googlebooks_id %}
{% with work.googlebooks_id as googlebooks_id %}{% with 'tabs-2' as tab_override %}
{% include "book_panel.html" %}
{% endwith %}
{% endwith %}{% endwith %}
</div>
{% endfor %}
<div class="pagination content-block-heading tabs-2">

View File

@ -102,28 +102,37 @@
</div>
</div>
{% ifequal status 'ACTIVE' %}
<div class="thermometer" title="{{ work.percent_of_goal }}% of goal">
<div class="cover" style="width: {{ cover_width }}%;">
{% ifnotequal work.last_campaign.type 3 %}
<div class="thermometer" title="{{ work.percent_of_goal }}% of goal">
<div class="cover" style="width: {{ cover_width }}%;">
</div>
<span>{{ work.percent_of_goal }}% of goal</span>
</div>
<span>{{ work.percent_of_goal }}% of goal</span>
</div>
{% endifnotequal %}
<div class="pledged-info noborder">
<div class="campaign-status-info">
{% ifequal work.last_campaign.type 1 %}
<span>${{ work.last_campaign.current_total|floatformat:0|intcomma }}</span> pledged
{% else %}
{% endifequal %}
{% ifequal work.last_campaign.type 2 %}
current ungluing date:
{% endifequal %}
{% ifequal work.last_campaign.type 3 %}
<span>${{ work.last_campaign.current_total|floatformat:0|intcomma }}</span> of thanks from
{% endifequal %}
</div>
<div class="campaign-status-info explainer">
{% ifequal work.last_campaign.type 1 %}
<span>${{ work.last_campaign.target|floatformat:0|intcomma }}</span> goal
{% else %}
{% endifequal %}
{% ifequal work.last_campaign.type 2 %}
<span class="current_cc_date ">{{ work.last_campaign.cc_date|date:"M j, Y" }}</span>
<span class="explanation">After {{ work.last_campaign.cc_date|date:"M j, Y" }} this book will be available for free to anyone, anywhere. Every purchase before then brings that date closer.</span>
{% endifequal %}
{% endifequal %}
{% ifnotequal work.last_campaign.type 3 %}
</div>
<div class="campaign-status-info">
{% endifnotequal %}
{% if work.last_campaign.supporters_count == 1 %}
<span>1</span> ungluer
{% else %}
@ -139,14 +148,16 @@
{% endif %}
</div>
{% endifequal %}
<div class="campaign-status-info explainer">
{% ifequal work.last_campaign.type 1 %}
<span>{{ work.last_campaign.countdown }}</span> to go
{% else %}
<span>${{ work.last_campaign.left|floatformat:0|intcomma }}</span> to go
<span class="explanation">${{ work.last_campaign.left|floatformat:0|intcomma }} is the amount it would take to make this ebook free to the world tomorrow.</span>
{% endifequal %}
</div>
{% ifnotequal work.last_campaign.type 3 %}
<div class="campaign-status-info explainer">
{% ifequal work.last_campaign.type 1 %}
<span>{{ work.last_campaign.countdown }}</span> to go
{% else %}
<span>${{ work.last_campaign.left|floatformat:0|intcomma }}</span> to go
<span class="explanation">${{ work.last_campaign.left|floatformat:0|intcomma }} is the amount it would take to make this ebook free to the world tomorrow.</span>
{% endifequal %}
</div>
{% endifnotequal %}
</div>
{% else %}
{% ifequal status 'SUCCESSFUL' %}
@ -235,13 +246,17 @@
<div id="content-block-content">
<div id="tabs-1" class="tabs {% if activetab == '1' %}active{% endif %}">
<div class="tabs-content">
{% if status == 'ACTIVE' or status == 'SUCCESSFUL' %}
<div itemprop="description">{{ work.last_campaign.description|safe }}</div>
<div itemprop="description">
{% if status == 'ACTIVE' %}
{% if work.last_campaign.type != 3 %}
{{ work.last_campaign.description|safe }}
{% else %}
{{ work.description|safe }}
{% endif %}
{% else %}
<h3 class="tabcontent-title">{{work.title}}</h3>
<p itemprop="description">{{ work.description|safe }}
</p>
{{ work.description|safe }}
{% endif %}
</div>
</div>
</div>
<div id="tabs-2" class="tabs {% if activetab == '2' %}active{% endif %}">
@ -474,6 +489,11 @@
{% else %}
<div class="btn_support"><form action="{% url pledge work_id %}" method="get"><input type="submit" value="Pledge" /></form></div>
{% endif %}
{% else %}{% if work.last_campaign.type == 3 %}
<div class="btn_support">
<a href="{% url download work_id %}" class="hijax"><span>Download</span></a>
</div>
<div style="text-align: center;">... and thank the creators!</div>
{% else %}
{% if license_is_active %}
<div class="btn_support">
@ -484,7 +504,7 @@
{% else %}
<div class="btn_support"><form action="{% url purchase work_id %}" method="get"><input type="submit" value="{% if next_acq %}{% if on_hold %}On Hold{% else %}Reserve{% endif %}{% else %}Purchase{% endif %}" /></form></div>
{% endif %}{% endif %}
{% endif %}
{% endif %}{% endif %}
{% else %}
{% if work.first_ebook %}
<div class="btn_support">
@ -618,7 +638,8 @@
{% endif %}
</ul>
</div>
{% else %}
{% endifequal %}
{% ifequal work.last_campaign.type 2 %}
{% if lib_licenses.available %}
<h3 class="jsmod-title"><span>Borrow</span></h3>
<div class="jsmod-content">
@ -672,6 +693,31 @@
</div>
{% endif %}
{% endifequal %}
{% ifequal work.last_campaign.type 3 %}
<h3 class="jsmod-title"><span>Thank the Creators</span></h3>
<div class="jsmod-content">
<ul class="support menu">
{% if purchased %}
<li class="first no_link">
<span class="menu-item-desc">You're welcome!</span>
</li>
{% else %}
<li class="first">
<a href="{% url thank work_id %}?offer_id={{work.last_campaign.individual_offer.id}}">
<span class="menu-item-price">${{ work.last_campaign.individual_offer.price|floatformat:0|intcomma }}</span>
<span class="menu-item-desc">{{ work.last_campaign.individual_offer.get_thanks_display }}</span>
</a>
</li>
<li class="last">
<a href="{% url thank work_id %}?offer_id={{work.last_campaign.library_offer.id}}">
<span class="menu-item-price">${{ work.last_campaign.library_offer.price|floatformat:0|intcomma }}</span>
<span class="menu-item-desc">{{ work.last_campaign.library_offer.get_thanks_display }}</span>
</a>
</li>
{% endif %}
</ul>
</div>
{% endifequal %}
</div>
{% endif %}
</div>

View File

@ -88,6 +88,7 @@ urlpatterns = patterns(
url(r"^work/(?P<work_id>\d+)/lockss/$", "lockss", name="lockss"),
url(r"^lockss/(?P<year>\d+)/$", "lockss_manifest", name="lockss_manifest"),
url(r"^work/(?P<work_id>\d+)/download/$", "download", name="download"),
url(r"^work/(?P<work_id>\d+)/download/$", "download", name="thank"),
url(r"^work/(?P<work_id>\d+)/unglued/(?P<format>\w+)/$", "download_campaign", name="download_campaign"),
url(r"^work/(?P<work_id>\d+)/borrow/$", "borrow", name="borrow"),
url(r"^work/(?P<work_id>\d+)/reserve/$", "reserve", name="reserve"),