Merge pull request #39 from netchampfaris/bounty-system

Show only paid backers
This commit is contained in:
Faris Ansari
2017-08-28 17:53:24 +05:30
committed by GitHub
2 changed files with 15 additions and 11 deletions

View File

@@ -11,7 +11,7 @@ from frappe.website.utils import get_comment_list
class Bounty(WebsiteGenerator):
def get_context(self, context):
paid_backers = [backer for backer in self.bounty_backer if backer.paid]
paid_backers = get_paid_backers(self.bounty_backer)
no_of_backers = len(paid_backers)
if no_of_backers == 0:
no_of_backers = 'Be the first to back this bounty'
@@ -37,12 +37,11 @@ class Bounty(WebsiteGenerator):
from frappe.utils.user import get_user_fullname
self.bounty_collected = 0.0
for backer in self.bounty_backer:
if backer.paid:
amount = backer.amount
if backer.currency == 'INR':
amount = backer.amount / 65.00
self.bounty_collected += amount
for backer in get_paid_backers(self.bounty_backer):
amount = backer.amount
if backer.currency == 'INR':
amount = backer.amount / 65.00
self.bounty_collected += amount
if not self.route:
self.published = 1
@@ -63,3 +62,7 @@ def get_list_context(context):
context.order_by = 'creation desc'
context.introduction = '<a href="new-bounty" class="btn btn-primary">Start a new Bounty</a>'
context.fmt_money = fmt_money
context.get_paid_backers = get_paid_backers
def get_paid_backers(backers):
return [backer for backer in backers if backer.paid]

View File

@@ -12,10 +12,11 @@
<p>
<span class="label">{{ fmt_money(doc.goal, currency="USD") }}</span>
<span class="label">Ends on {{ doc.end_date }}</span>
{% if doc.bounty_backer %}
{% set paid_backers = get_paid_backers(doc.bounty_backer) %}
{% if paid_backers|len > 0 %}
<span class="label">
{{ doc.bounty_backer|len }}
{% if doc.bounty_backer|len > 1 %}
{{ paid_backers|len }}
{% if paid_backers|len > 1 %}
Backers
{% else %}
Backer