diff --git a/foundation/erpnext_foundation/doctype/bounty/bounty.py b/foundation/erpnext_foundation/doctype/bounty/bounty.py index 4a9241a5..97c13221 100644 --- a/foundation/erpnext_foundation/doctype/bounty/bounty.py +++ b/foundation/erpnext_foundation/doctype/bounty/bounty.py @@ -11,33 +11,42 @@ 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) + paid_backers = [backer for backer in self.bounty_backer if backer.paid] + no_of_backers = len(paid_backers) 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.no_cache = True + context.days_to_go = date_diff(self.end_date, nowdate()) + context.paid_backers = paid_backers + context.no_of_backers = no_of_backers + context.fmt_money = fmt_money context.bounty_left = bounty_left context.comment_list = get_comment_list(self.doctype, self.name) def validate(self): + from frappe.utils.user import get_user_fullname + self.bounty_collected = sum([backer.amount for backer in self.bounty_backer if backer.paid]) if not self.route: self.published = 1 self.route = 'bounties/' + self.feature_name.lower().replace(' ', '-') + bounty_backers = [] + for backer in self.bounty_backer: + if backer.user and not backer.full_name: + backer.full_name = get_user_fullname(backer.user) + bounty_backers.append(backer) + self.bounty_backer = bounty_backers + def get_list_context(context): context.allow_guest = True context.no_cache = True diff --git a/foundation/erpnext_foundation/doctype/bounty/templates/bounty.html b/foundation/erpnext_foundation/doctype/bounty/templates/bounty.html index ecc92a34..64428bdf 100644 --- a/foundation/erpnext_foundation/doctype/bounty/templates/bounty.html +++ b/foundation/erpnext_foundation/doctype/bounty/templates/bounty.html @@ -6,11 +6,25 @@ margin-bottom: 50px; } - input[type=number] { + .bounty-amount { width: 200px; margin-bottom: 12px; } + .bounty-amount .dropdown-menu { + min-width: 100px; + } + + .bounty-amount .dropdown-toggle { + border: 1px solid #d1d8dd; + } + + input::-webkit-outer-spin-button, + input::-webkit-inner-spin-button { + -webkit-appearance: none; + margin: 0; + } + p.lead { margin-bottom: 10px; } @@ -26,35 +40,64 @@
-
{{ fmt_money(doc.bounty_collected, currency="INR") }} - of {{ fmt_money(doc.goal, currency="INR") }} +
{{ fmt_money(doc.bounty_collected, currency="USD") }} + of {{ fmt_money(doc.goal, currency="USD") }}
{{ no_of_backers }} + ( + {% for backer in paid_backers %} + {{ backer.full_name }}, + {% endfor %} + )
{% if doc.github_issue %} {% endif %} -- - - Back this bounty - -
+ +- {{ fmt_money(doc.goal, currency="INR") }} + {{ fmt_money(doc.goal, currency="USD") }} Ends on {{ doc.end_date }} {% if doc.bounty_backer %} diff --git a/foundation/erpnext_foundation/doctype/bounty_backer/bounty_backer.json b/foundation/erpnext_foundation/doctype/bounty_backer/bounty_backer.json index eb559d5e..f4ea096e 100644 --- a/foundation/erpnext_foundation/doctype/bounty_backer/bounty_backer.json +++ b/foundation/erpnext_foundation/doctype/bounty_backer/bounty_backer.json @@ -163,6 +163,37 @@ "search_index": 0, "set_only_once": 0, "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "currency", + "fieldtype": "Link", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Currency", + "length": 0, + "no_copy": 0, + "options": "Currency", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 } ], "has_web_view": 0, @@ -175,8 +206,8 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2017-08-17 17:26:35.968048", - "modified_by": "faris@erpnext.com", + "modified": "2017-08-25 18:41:22.187182", + "modified_by": "Administrator", "module": "ERPNext Foundation", "name": "Bounty Backer", "name_case": "", 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 bf7d7152..45bbc7a2 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-23 18:21:28.733120", + "modified": "2017-08-26 21:13:32.398765", "modified_by": "faris@erpnext.com", "module": "ERPNext Foundation", "name": "back-this-bounty", @@ -27,11 +27,11 @@ "payment_button_label": "Pay now", "payment_gateway": "Razorpay", "published": 1, - "route": "back-this-bounty", - "show_sidebar": 1, + "route": "back-this-bounty-inr", + "show_sidebar": 0, "sidebar_items": [], "success_url": "/bounties", - "title": "Back this bounty", + "title": "Back this bounty - INR", "web_form_fields": [ { "fieldname": "user", @@ -63,6 +63,17 @@ "max_value": 0, "read_only": 0, "reqd": 0 + }, + { + "fieldname": "currency", + "fieldtype": "Data", + "hidden": 0, + "label": "Currency", + "max_length": 0, + "max_value": 0, + "options": "Currency", + "read_only": 1, + "reqd": 0 } ] } \ No newline at end of file diff --git a/foundation/erpnext_foundation/web_form/back_this_bounty_usd/__init__.py b/foundation/erpnext_foundation/web_form/back_this_bounty_usd/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/foundation/erpnext_foundation/web_form/back_this_bounty_usd/back_this_bounty_usd.js b/foundation/erpnext_foundation/web_form/back_this_bounty_usd/back_this_bounty_usd.js new file mode 100644 index 00000000..699703c5 --- /dev/null +++ b/foundation/erpnext_foundation/web_form/back_this_bounty_usd/back_this_bounty_usd.js @@ -0,0 +1,3 @@ +frappe.ready(function() { + // bind events here +}) \ No newline at end of file diff --git a/foundation/erpnext_foundation/web_form/back_this_bounty_usd/back_this_bounty_usd.json b/foundation/erpnext_foundation/web_form/back_this_bounty_usd/back_this_bounty_usd.json new file mode 100644 index 00000000..29339a9f --- /dev/null +++ b/foundation/erpnext_foundation/web_form/back_this_bounty_usd/back_this_bounty_usd.json @@ -0,0 +1,79 @@ +{ + "accept_payment": 1, + "allow_comments": 0, + "allow_delete": 0, + "allow_edit": 0, + "allow_incomplete": 0, + "allow_multiple": 0, + "allow_print": 0, + "amount": 0.0, + "amount_based_on_field": 1, + "amount_field": "amount", + "creation": "2017-08-25 18:11:39.203816", + "currency": "USD", + "doc_type": "Bounty Backer", + "docstatus": 0, + "doctype": "Web Form", + "idx": 0, + "introduction_text": "", + "is_standard": 1, + "login_required": 1, + "max_attachment_size": 0, + "modified": "2017-08-26 21:13:42.065195", + "modified_by": "faris@erpnext.com", + "module": "ERPNext Foundation", + "name": "back-this-bounty-usd", + "owner": "Administrator", + "payment_button_label": "Pay now", + "payment_gateway": "PayPal", + "published": 1, + "route": "back-this-bounty-usd", + "show_sidebar": 0, + "sidebar_items": [], + "success_url": "/bounties", + "title": "Back this bounty - USD", + "web_form_fields": [ + { + "fieldname": "user", + "fieldtype": "Link", + "hidden": 0, + "label": "User", + "max_length": 0, + "max_value": 0, + "options": "User", + "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", + "hidden": 0, + "label": "Amount", + "max_length": 0, + "max_value": 0, + "read_only": 0, + "reqd": 0 + }, + { + "fieldname": "currency", + "fieldtype": "Data", + "hidden": 0, + "label": "Currency", + "max_length": 0, + "max_value": 0, + "options": "Currency", + "read_only": 1, + "reqd": 0 + } + ] +} \ No newline at end of file diff --git a/foundation/erpnext_foundation/web_form/back_this_bounty_usd/back_this_bounty_usd.py b/foundation/erpnext_foundation/web_form/back_this_bounty_usd/back_this_bounty_usd.py new file mode 100644 index 00000000..2334f8b2 --- /dev/null +++ b/foundation/erpnext_foundation/web_form/back_this_bounty_usd/back_this_bounty_usd.py @@ -0,0 +1,7 @@ +from __future__ import unicode_literals + +import frappe + +def get_context(context): + # do your magic here + pass