diff --git a/foundation/erpnext_foundation/doctype/bounty/bounty.py b/foundation/erpnext_foundation/doctype/bounty/bounty.py index ada515e1..44297508 100644 --- a/foundation/erpnext_foundation/doctype/bounty/bounty.py +++ b/foundation/erpnext_foundation/doctype/bounty/bounty.py @@ -6,10 +6,31 @@ from __future__ import unicode_literals import frappe from frappe.website.website_generator import WebsiteGenerator from frappe.website.utils import get_comment_list +from frappe.utils import date_diff, nowdate, fmt_money +from frappe.website.utils import get_comment_list class Bounty(WebsiteGenerator): def get_context(self, context): context.no_cache = True + context.days_to_go = date_diff(self.end_date, nowdate()) + + no_of_backers = len(self.bounty_backer) + if no_of_backers == 0: + no_of_backers = 'No backers yet' + elif no_of_backers == 1: + no_of_backers = str(no_of_backers) + ' backer' + else: + no_of_backers = str(no_of_backers) + ' backers' + context.no_of_backers = no_of_backers + context.fmt_money = fmt_money + + bounty_left = self.goal - self.bounty_collected + + if bounty_left > (self.goal * 0.1) or bounty_left < 0: + bounty_left = self.goal * 0.1 + + context.bounty_left = bounty_left + context.comment_list = get_comment_list(self.doctype, self.name) def validate(self): self.bounty_collected = sum([backer.amount for backer in self.bounty_backer if backer.paid]) @@ -20,4 +41,5 @@ def get_list_context(context): context.title = 'ERPNext Bounties' context.no_breadcrumbs = True context.order_by = 'creation desc' - context.introduction = '

ERPNext feature requests

' + context.introduction = '

List of all ERPNext bounties

' + context.fmt_money = fmt_money \ No newline at end of file diff --git a/foundation/erpnext_foundation/doctype/bounty/templates/bounty.html b/foundation/erpnext_foundation/doctype/bounty/templates/bounty.html index 975ff35a..d698d980 100644 --- a/foundation/erpnext_foundation/doctype/bounty/templates/bounty.html +++ b/foundation/erpnext_foundation/doctype/bounty/templates/bounty.html @@ -1,24 +1,59 @@ {% extends "templates/web.html" %} {% block page_content %} -

{{ title }}

+ + +
+

{{ title }} {{days_to_go}} days to go

{% set bounty_progress = ((doc.bounty_collected/doc.goal)*100) %} -
+
{{ doc.bounty_collected }} of {{ doc.goal }}

-

{{ frappe.utils.fmt_money(doc.bounty_collected, currency="USD") }} - of {{ frappe.utils.fmt_money(doc.goal, currency="USD") }} - +

{{ fmt_money(doc.bounty_collected, currency="USD") }} + of {{ fmt_money(doc.goal, currency="USD") }} +

+

+ {{ no_of_backers }} +

+

+ + + Back this bounty +

-

{{ doc.end_date }}

- -Back this bounty + +
+

+

About this feature

+

{{doc.description}}

+

+

Discuss

{% include 'templates/includes/comments/comments.html' %} diff --git a/foundation/erpnext_foundation/doctype/bounty/templates/bounty_row.html b/foundation/erpnext_foundation/doctype/bounty/templates/bounty_row.html index c42a7bdf..632f974c 100644 --- a/foundation/erpnext_foundation/doctype/bounty/templates/bounty_row.html +++ b/foundation/erpnext_foundation/doctype/bounty/templates/bounty_row.html @@ -2,9 +2,16 @@

{{ doc.feature_name }}

- {{ frappe.format(doc.goal) }} + {{ fmt_money(doc.goal, currency="USD") }} {{ doc.end_date }} - {{ doc.bounty_backer }} Backers + + {{ doc.bounty_backer|len }} + {% if doc.bounty_backer|len > 1 %} + Backers + {% else %} + Backer + {% endif %} +

{{ html2text(doc.description[:200]) }}{% if doc.description|len > 200 %}...{% endif %}

diff --git a/foundation/erpnext_foundation/web_form/back_this_bounty/back_this_bounty.js b/foundation/erpnext_foundation/web_form/back_this_bounty/back_this_bounty.js index 7373ba61..8d110a16 100644 --- a/foundation/erpnext_foundation/web_form/back_this_bounty/back_this_bounty.js +++ b/foundation/erpnext_foundation/web_form/back_this_bounty/back_this_bounty.js @@ -1,15 +1,3 @@ frappe.ready(function() { - var bounty_name = getParameterByName('bounty'); - $('input[data-fieldname="bounty_name"]').val(bounty_name); - $('[data-fieldname="user"]').val(frappe.session.user); - function getParameterByName(name) { - var url = window.location.href; - name = name.replace(/[\[\]]/g, "\\$&"); - var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), - results = regex.exec(url); - if (!results) return null; - if (!results[2]) return ''; - return decodeURIComponent(results[2].replace(/\+/g, " ")); - } }) \ No newline at end of file diff --git a/foundation/erpnext_foundation/web_form/back_this_bounty/back_this_bounty.json b/foundation/erpnext_foundation/web_form/back_this_bounty/back_this_bounty.json index 0d9907d8..12b1d5c7 100644 --- a/foundation/erpnext_foundation/web_form/back_this_bounty/back_this_bounty.json +++ b/foundation/erpnext_foundation/web_form/back_this_bounty/back_this_bounty.json @@ -19,7 +19,7 @@ "is_standard": 1, "login_required": 1, "max_attachment_size": 0, - "modified": "2017-08-18 08:18:03.166262", + "modified": "2017-08-18 14:41:04.132808", "modified_by": "faris@erpnext.com", "module": "ERPNext Foundation", "name": "back-this-bounty", @@ -33,16 +33,6 @@ "success_url": "/bounty", "title": "Back this bounty", "web_form_fields": [ - { - "fieldname": "bounty_name", - "fieldtype": "Data", - "hidden": 0, - "label": "Bounty Name", - "max_length": 0, - "max_value": 0, - "read_only": 1, - "reqd": 0 - }, { "fieldname": "user", "fieldtype": "Link", @@ -54,6 +44,16 @@ "read_only": 1, "reqd": 0 }, + { + "fieldname": "bounty_name", + "fieldtype": "Data", + "hidden": 0, + "label": "Bounty Name", + "max_length": 0, + "max_value": 0, + "read_only": 1, + "reqd": 0 + }, { "fieldname": "amount", "fieldtype": "Int", diff --git a/foundation/erpnext_foundation/web_form/back_this_bounty/back_this_bounty.py b/foundation/erpnext_foundation/web_form/back_this_bounty/back_this_bounty.py index d0064bde..2334f8b2 100644 --- a/foundation/erpnext_foundation/web_form/back_this_bounty/back_this_bounty.py +++ b/foundation/erpnext_foundation/web_form/back_this_bounty/back_this_bounty.py @@ -3,6 +3,5 @@ from __future__ import unicode_literals import frappe def get_context(context): - print(context) - context.no_breadcrumbs = 1 - context.user = 'faris@erpnext.com' + # do your magic here + pass diff --git a/foundation/hooks.py b/foundation/hooks.py index dc08c7e4..6dda8aec 100644 --- a/foundation/hooks.py +++ b/foundation/hooks.py @@ -47,6 +47,7 @@ website_context = { {"label": "Services", "url": "/service-providers", "right": 1}, {"label": "Jobs", "url": "/erpnext-jobs", "right": 1}, {"label": "Chapters", "url": "/chapters", "right": 1}, + {"label": "Bounties", "url": "/bounty", "right": 1}, {"label": 'Conference', "url": "/conf/2017", "right": 1}, {"label": "About", "url": "/about", "right": 1}, ],