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): class Bounty(WebsiteGenerator):
def get_context(self, context): 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) no_of_backers = len(paid_backers)
if no_of_backers == 0: if no_of_backers == 0:
no_of_backers = 'Be the first to back this bounty' no_of_backers = 'Be the first to back this bounty'
@@ -37,8 +37,7 @@ class Bounty(WebsiteGenerator):
from frappe.utils.user import get_user_fullname from frappe.utils.user import get_user_fullname
self.bounty_collected = 0.0 self.bounty_collected = 0.0
for backer in self.bounty_backer: for backer in get_paid_backers(self.bounty_backer):
if backer.paid:
amount = backer.amount amount = backer.amount
if backer.currency == 'INR': if backer.currency == 'INR':
amount = backer.amount / 65.00 amount = backer.amount / 65.00
@@ -63,3 +62,7 @@ def get_list_context(context):
context.order_by = 'creation desc' context.order_by = 'creation desc'
context.introduction = '<a href="new-bounty" class="btn btn-primary">Start a new Bounty</a>' context.introduction = '<a href="new-bounty" class="btn btn-primary">Start a new Bounty</a>'
context.fmt_money = fmt_money 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> <p>
<span class="label">{{ fmt_money(doc.goal, currency="USD") }}</span> <span class="label">{{ fmt_money(doc.goal, currency="USD") }}</span>
<span class="label">Ends on {{ doc.end_date }}</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"> <span class="label">
{{ doc.bounty_backer|len }} {{ paid_backers|len }}
{% if doc.bounty_backer|len > 1 %} {% if paid_backers|len > 1 %}
Backers Backers
{% else %} {% else %}
Backer Backer