From 90ece3a2b01e03df92669579c84da3a56d02ecbe Mon Sep 17 00:00:00 2001 From: Andromeda Yelton Date: Thu, 31 May 2012 13:25:19 -0400 Subject: [PATCH] made logic less awful, cached work.id to speed things up as it's used many times --- frontend/templates/book_panel.html | 208 ++++++++++++++--------------- 1 file changed, 104 insertions(+), 104 deletions(-) diff --git a/frontend/templates/book_panel.html b/frontend/templates/book_panel.html index ae3d01e7..b92eae32 100644 --- a/frontend/templates/book_panel.html +++ b/frontend/templates/book_panel.html @@ -6,6 +6,7 @@ {% with work.last_campaign as last_campaign %} {% with work.last_campaign.status as status %} {% with work.last_campaign.deadline as deadline %} +{% with work.id as workid %}
@@ -13,128 +14,120 @@
- {% if not is_preview %} {% comment %}top section: campaign info + optional action button. Varies by campaign status.{% endcomment %} - {% if first_ebook %} - AVAILABLE! -
-
Read it Now
- - {% else %}{% if status == 'SUCCESSFUL' %} + {% if status == 'SUCCESSFUL' %} UNGLUED!

On: {{ deadline|date:"M d, Y" }}

Raised: {{ work.last_campaign.current_total|floatformat:0|intcomma }}

-
- {% if first_ebook %}
Read it Now
{% else %}
Coming Soon
{% endif %} + {% if first_ebook %} +
Read it Now
+ {% else %} +
Coming Soon
+ {% endif %} {% else %}{% if status == 'ACTIVE' %} UNGLUE IT! -

${{ work.last_campaign.current_total|floatformat:0|intcomma }} raised

${{ work.last_campaign.target|floatformat:0|intcomma }} needed

+

${{ work.last_campaign.current_total|floatformat:0|intcomma }} raised

+

${{ work.last_campaign.target|floatformat:0|intcomma }} needed

by {{ deadline|date:"M d, Y" }}

-
-
Support
+
Support
{% else %}{% if status == 'INITIALIZED' %}

Campaign coming soon!

-
{% else %}{% if status == 'SUSPENDED' %}

This campaign has been suspended.


See the FAQ for details.

-
{% else %}{% if status == 'WITHDRAWN' %}

This campaign has been withdrawn.


See the FAQ for details.

- {% else %}{% if status == 'UNSUCCESSFUL' %}

{{ deadline }}

Watch for a new campaign.

- {% else %} -

No campaign yet.


But if lots of ungluers wishlist this book, maybe there will be!

- - - {% endif %}{% endif %}{% endif %}{% endif %}{% endif %}{% endif %}{% endif %} - - {% else %} -

No campaign yet.


But if lots of ungluers wishlist this book, maybe there will be!

- - {% endif %} + {% if first_ebook %} + AVAILABLE! +
Read it Now
+ {% else %} +

No campaign yet.


But if lots of ungluers wishlist this book, maybe there will be!

+ {% endif %} + {% endif %}{% endif %}{% endif %}{% endif %}{% endif %}{% endif %} + - {% comment %}link to work page{% endcomment %} -
- More Info -
+ {% comment %}link to work page{% endcomment %} +
+ More Info +
- {% comment %}bibliographic data{% endcomment %} -
-

{{ work.title }}

-

{{ author }}

-
- - {% comment %}status of book vis-a-vis user's wishlist{% endcomment %} - {% if works and activetab %} -
- {% if on_search_page %} - Add to Wishlist - {% else %} - Add to Wishlist - {% endif %} -
- {% else %} - {% if request.user.id in supporters %} -
- Pledged! -
- {% else %} - {% ifequal supporter request.user %} -
- Remove This -
- {% else %}{% if request.user.is_anonymous %} -
- Login to Add -
- {% else %}{% if work in request.user.wishlist.works.all %} -
- On Wishlist! -
- {% else %} -
- {% if on_search_page %} - Add to Wishlist - {% else %} - Add to Wishlist - {% endif %} -
- {% endif %}{% endif %}{% endifequal %}{% endif %}{% endif %} + {% comment %}bibliographic data{% endcomment %} +
+

{{ work.title }}

+

{{ author }}

+
+ {% comment %} + status of book vis-a-vis user's wishlist. + Non-logged-in users should see login to add option. + Logged-in users, book on wishlist: + If they've pledged, that should be displayed, with no removal option. + If they're on their supporter page, they should have the option to remove it (except when pledged). + Elsewhere, they should see that it's on their wishlist. + Everyone else should have add-to-wishlist option. + (Needed ID for wishlist.js varies on search & supporter page.) + {% endcomment %} + {% if request.user.is_anonymous %} +
+ Login to Add +
+ {% else %}{% if request.user.id in supporters %} +
+ Pledged! +
+ {% else %}{% ifequal supporter request.user %} +
+ Remove This +
+ {% else %}{% if work in request.user.wishlist.works.all %} +
+ On Wishlist! +
+ {% else %} +
+ {% if on_search_page %} + Add to Wishlist + {% else %} + Add to Wishlist + {% endif %} +
+ {% endif %}{% endifequal %}{% endif %}{% endif %} +
- Book cover + Book cover
{{ author }}
- {% if request.user.id in supporters %} + + {% comment %}same logic as above{% endcomment %} + {% if request.user.is_anonymous %} +
+ Login to Add +
+ {% else %}{% if request.user.id in supporters %}
Pledged!
- {% else %} - {% ifequal supporter request.user %} + {% else %}{% ifequal supporter request.user %}
- Remove This -
- {% else %}{% if request.user.is_anonymous %} -
- Login to Add + Remove This
{% else %}{% if work in request.user.wishlist.works.all %}
@@ -142,40 +135,46 @@
{% else %}
- {% if on_search_page %} - Add to Wishlist - {% else %} - Add to Wishlist - {% endif %} -
- {% endif %}{% endif %}{% endifequal %}{% endif %} -
- {% if not is_preview %} - {% ifequal status "ACTIVE" %} - ${{ work.last_campaign.current_total|floatformat:0|intcomma }}/${{ work.last_campaign.target|floatformat:0|intcomma }} - {% else %}{% if status == "INITIALIZED" %} - Status: Coming soon! - {% else %} - Status: {{ status }} - {% endif %}{% endifequal %} + {% if on_search_page %} + Add to Wishlist + {% else %} + Add to Wishlist {% endif %}
+ {% endif %}{% endifequal %}{% endif %}{% endif %} + +
+ {% ifequal status "ACTIVE" %} + ${{ work.last_campaign.current_total|floatformat:0|intcomma }}/${{ work.last_campaign.target|floatformat:0|intcomma }} + {% else %}{% ifequal status "INITIALIZED" %} + Status: Coming soon! + {% else %} + + {% endifequal %}{% endifequal %} +
+ + {% comment %} + For status icons, we should display... + If there is an ebook: options to get it + If no ebook but there is an active or successful campaign: progress toward goal + Otherwise: number of wishes + {% endcomment %} {% if first_ebook %} {% for ebook in work.ebooks|slice:":3" %} {{ ebook.rights}}  {{ ebook.format }} at {{ebook.provider}} {% endfor %} - {% else %}{% if last_campaign == None or status == 'No campaign yet' or status == 'INITIALIZED' %} - Wished by {{ work.num_wishes }} + {% else %}{% if status == 'ACTIVE' or status == 'SUCCESSFUL' %} +
+ book list status +
+
{{ work.percent_of_goal }}%
{% else %} + Wished by {{ work.num_wishes }} + {% endif %}{% endif %} -
- book list status -
- {% if status == 'ACTIVE' or status == 'SUCCESSFUL' %}
{{ work.percent_of_goal }}%
{% endif %} - {% endif %}{% endif %}
@@ -194,3 +193,4 @@ {% endwith %} {% endwith %} {% endwith %} +{% endwith %} \ No newline at end of file