B2U campaign percentages
parent
c2f3910fe8
commit
75c32569e2
|
@ -791,20 +791,23 @@ class Work(models.Model):
|
|||
|
||||
def percent_unglued(self):
|
||||
status = 0
|
||||
if self.last_campaign() is not None:
|
||||
if(self.last_campaign_status() == 'SUCCESSFUL'):
|
||||
campaign = self.last_campaign()
|
||||
if campaign is not None:
|
||||
print campaign.status
|
||||
if(campaign.status == 'SUCCESSFUL'):
|
||||
status = 6
|
||||
elif(self.last_campaign_status() == 'ACTIVE'):
|
||||
target = float(self.last_campaign().target)
|
||||
elif(campaign.status == 'ACTIVE'):
|
||||
target = float(campaign.target)
|
||||
if target <= 0:
|
||||
status = 6
|
||||
else:
|
||||
total = float(self.last_campaign().current_total)
|
||||
percent = int(total*6/target)
|
||||
if percent >= 6:
|
||||
status = 6
|
||||
print campaign.type
|
||||
if campaign.type == BUY2UNGLUE:
|
||||
status = int( 6 - 6*campaign.left/campaign.target)
|
||||
else:
|
||||
status = percent
|
||||
status = int(float(campaign.current_total)*6/target)
|
||||
if status >= 6:
|
||||
status = 6
|
||||
return status
|
||||
|
||||
def percent_of_goal(self):
|
||||
|
@ -812,9 +815,10 @@ class Work(models.Model):
|
|||
campaign = self.last_campaign()
|
||||
if campaign is not None:
|
||||
if(campaign.status == 'SUCCESSFUL' or campaign.status == 'ACTIVE'):
|
||||
target = campaign.target
|
||||
total = campaign.current_total
|
||||
percent = int(total/target*100)
|
||||
if campaign.type == BUY2UNGLUE:
|
||||
percent = int(100 - 100*campaign.left/campaign.target)
|
||||
else:
|
||||
percent = int(campaign.current_total/campaign.target*100)
|
||||
return percent
|
||||
|
||||
def ebooks(self):
|
||||
|
|
|
@ -432,10 +432,18 @@ class CampaignTests(TestCase):
|
|||
deadline=datetime(2013, 1, 1),
|
||||
work=w, type=2,
|
||||
cc_date_initial=datetime(2113, 1, 1),
|
||||
status='INITIALIZED',
|
||||
)
|
||||
self.assertTrue(c.set_dollar_per_day()<0.34)
|
||||
self.assertTrue(c.dollar_per_day>0.31)
|
||||
#c.save()
|
||||
#self.assertEqual(w.percent_unglued(),0)
|
||||
c._current_total = D(6000.1)
|
||||
c.status = 'ACTIVE'
|
||||
c.save()
|
||||
c.update_left()
|
||||
print(w.percent_of_goal())
|
||||
self.assertEqual(w.percent_unglued(),3)
|
||||
self.assertTrue(w.percent_of_goal()>49)
|
||||
|
||||
def test_required_fields(self):
|
||||
# a campaign must have a target, deadline and a work
|
||||
|
|
|
@ -80,7 +80,11 @@ Please fix the following before launching your campaign:
|
|||
|
||||
<div class="pledged-info">
|
||||
<div class="pledged-group">
|
||||
{% ifequal work.last_campaign.type 1 %}
|
||||
{{ work.last_campaign.supporters_count }} Ungluers have pledged ${{ work.last_campaign.current_total|intcomma }}
|
||||
{% else %}
|
||||
Total revenue: ${{ work.last_campaign.current_total|intcomma }} from {{ work.last_campaign.supporters_count }} Ungluers
|
||||
{% endifequal %}
|
||||
</div>
|
||||
<div class="status">
|
||||
<img src="/static/images/images/icon-book-37by25-{{ work.percent_unglued }}.png" title="book list status" alt="book list status" />
|
||||
|
|
|
@ -54,7 +54,7 @@ Any questions not covered here? Please email us at <a href="mailto:rights@gluej
|
|||
{% ifequal campaign.type 1 %}
|
||||
${{ campaign.current_total }} pledged of ${{ campaign.target }}, {{ campaign.supporters_count }} supporters
|
||||
{% else %}
|
||||
${{ campaign.current_total }} sold of ${{ campaign.target }}, CC Date: {{ campaign.cc_date }}
|
||||
${{ campaign.current_total }} sold. ${{ campaign.target }} to go. CC Date: {{ campaign.cc_date }}
|
||||
{% endifequal %}
|
||||
</div>
|
||||
{% if campaign.status = 'ACTIVE' or campaign.status = 'INITIALIZED' %}
|
||||
|
@ -134,7 +134,7 @@ Any questions not covered here? Please email us at <a href="mailto:rights@gluej
|
|||
{% ifequal campaign.type 1 %}
|
||||
${{ campaign.current_total }} pledged of ${{ campaign.target }}, {{ campaign.supporters_count }} supporters
|
||||
{% else %}
|
||||
${{ campaign.current_total }} sold of ${{ campaign.target }}, CC Date: {{ campaign.cc_date }}
|
||||
${{ campaign.current_total }} sold. ${{ campaign.target }} to go, CC Date: {{ campaign.cc_date }}
|
||||
{% endifequal %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
|
Loading…
Reference in New Issue