aligning book detail layout in pledge and work pages
parent
a060cf0f51
commit
918ce0f904
|
@ -31,21 +31,30 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="jsmodule rounded pledge">
|
||||
<div class="jsmod-content">
|
||||
${{ work.last_campaign.target|floatformat:0|intcomma }} needed by<br />
|
||||
{{ work.last_campaign.deadline }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pledged-info">
|
||||
<div class="pledged-group">
|
||||
{{ work.last_campaign.supporters_count }} Ungluers have pledged ${{ work.last_campaign.current_total|intcomma }}
|
||||
</div>
|
||||
<div class="status">
|
||||
<img src="/static/images/images/icon-book-37by25-{{ work.percent_unglued }}.png" title="book list status" alt="book list status" />
|
||||
</div>
|
||||
<div class="pledged-info noborder">
|
||||
<div class="thermometer">
|
||||
<div class="cover" style="width: {{ cover_width }}%;">
|
||||
</div>
|
||||
</div>
|
||||
<div class="pledged-info noborder">
|
||||
<div class="campaign-status-info">
|
||||
<span>${{ work.last_campaign.current_total|floatformat:0|intcomma }}</span> pledged
|
||||
</div>
|
||||
<div class="campaign-status-info">
|
||||
<span>${{ work.last_campaign.target|floatformat:0|intcomma }}</span> goal
|
||||
</div>
|
||||
<div class="campaign-status-info">
|
||||
{% if work.last_campaign.supporters_count == 1 %}
|
||||
<span>1</span> ungluer
|
||||
{% else %}
|
||||
<span> {{ work.last_campaign.supporters_count }}</span> ungluers
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="campaign-status-info">
|
||||
<span>{{ countdown }}</span> to go
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -116,12 +116,6 @@ $j(document).ready(function(){
|
|||
<div class="campaign-status-info">
|
||||
<span>{{ countdown }}</span> to go
|
||||
</div>
|
||||
|
||||
{% comment %}
|
||||
<div class="status">
|
||||
{% if status == 'ACTIVE' %}{{ work.percent_of_goal }}% {% endif %}
|
||||
</div>
|
||||
{% endcomment %}
|
||||
</div>
|
||||
{% else %}
|
||||
{% ifequal status 'SUCCESSFUL' %}
|
||||
|
|
|
@ -114,6 +114,30 @@ def safe_get_work(work_id):
|
|||
raise Http404
|
||||
return work
|
||||
|
||||
def countdown(work):
|
||||
from math import ceil
|
||||
time_remaining = work.last_campaign().deadline - now()
|
||||
countdown = ""
|
||||
|
||||
if time_remaining.days:
|
||||
countdown = "%s days" % str(time_remaining.days + 1)
|
||||
elif time_remaining.seconds > 3600:
|
||||
countdown = "%s hours" % str(time_remaining.seconds/3600 + 1)
|
||||
elif time_remaining.seconds > 60:
|
||||
countdown = "%s minutes" % str(time_remaining.seconds/60 + 1)
|
||||
else:
|
||||
countdown = "Seconds"
|
||||
|
||||
return countdown
|
||||
|
||||
def cover_width(work):
|
||||
if work.percent_of_goal() < 100:
|
||||
cover_width = 100 - work.percent_of_goal()
|
||||
else:
|
||||
cover_width = 0
|
||||
|
||||
return cover_width
|
||||
|
||||
def home(request, landing=False):
|
||||
if request.user.is_authenticated() and landing == False:
|
||||
return HttpResponseRedirect(reverse('supporter',
|
||||
|
@ -161,8 +185,8 @@ def work(request, work_id, action='display'):
|
|||
pledged = None
|
||||
|
||||
logger.info("pledged: {0}".format(pledged))
|
||||
countdown = ""
|
||||
cover_width = 0
|
||||
countdown_text = ""
|
||||
cover_width_number = 0
|
||||
|
||||
try:
|
||||
assert not (work.last_campaign_status() == 'ACTIVE' and work.first_ebook())
|
||||
|
@ -170,30 +194,8 @@ def work(request, work_id, action='display'):
|
|||
logger.warning("Campaign running for %s when ebooks are already available: why?" % work.title )
|
||||
|
||||
if work.last_campaign_status() == 'ACTIVE':
|
||||
from math import ceil
|
||||
time_remaining = campaign.deadline - now()
|
||||
|
||||
'''
|
||||
we want to round up on all of these; if it's the 3rd and the
|
||||
campaign ends the 8th, users expect to see 5 days remaining,
|
||||
not 4 (as an artifact of 4 days 11 hours or whatever)
|
||||
time_remaining.whatever is an int, so just adding 1 will do
|
||||
that for us (except in the case where .days exists and both other
|
||||
fields are 0, which is unlikely enough I'm not defending against it)
|
||||
'''
|
||||
if time_remaining.days:
|
||||
countdown = "%s days" % str(time_remaining.days + 1)
|
||||
elif time_remaining.seconds > 3600:
|
||||
countdown = "%s hours" % str(time_remaining.seconds/3600 + 1)
|
||||
elif time_remaining.seconds > 60:
|
||||
countdown = "%s minutes" % str(time_remaining.seconds/60 + 1)
|
||||
else:
|
||||
countdown = "Seconds"
|
||||
|
||||
if work.percent_of_goal() < 100:
|
||||
cover_width = 100 - work.percent_of_goal()
|
||||
else:
|
||||
cover_width = 0
|
||||
countdown_text = countdown(work)
|
||||
cover_width_number = cover_width(work)
|
||||
|
||||
if action == 'preview':
|
||||
work.last_campaign_status = 'ACTIVE'
|
||||
|
@ -256,8 +258,8 @@ def work(request, work_id, action='display'):
|
|||
'alert': alert,
|
||||
'claimstatus': claimstatus,
|
||||
'rights_holder_name': rights_holder_name,
|
||||
'countdown': countdown,
|
||||
'cover_width': cover_width
|
||||
'countdown': countdown_text,
|
||||
'cover_width': cover_width_number
|
||||
})
|
||||
|
||||
def new_edition(request, work_id, edition_id, by=None):
|
||||
|
@ -744,6 +746,8 @@ class PledgeView(FormView):
|
|||
'faqmenu': 'modify' if self.transaction else 'pledge',
|
||||
'transaction': self.transaction,
|
||||
'tid': self.transaction.id if self.transaction else None,
|
||||
'countdown': countdown(self.work),
|
||||
'cover_width': cover_width(self.work)
|
||||
})
|
||||
|
||||
return context
|
||||
|
|
Loading…
Reference in New Issue