diff --git a/foundation/erpnext_foundation/doctype/bounty/bounty.js b/foundation/erpnext_foundation/doctype/bounty/bounty.js index a0f97067..e8d26cb2 100644 --- a/foundation/erpnext_foundation/doctype/bounty/bounty.js +++ b/foundation/erpnext_foundation/doctype/bounty/bounty.js @@ -4,5 +4,10 @@ frappe.ui.form.on('Bounty', { refresh: function(frm) { + }, + feature_name: function(frm) { + if (frm.doc.route) return; + const route = 'bounty/' + frm.doc.feature_name.toLowerCase().replace(/ /g, '-'); + frm.set_value('route', route); } }); diff --git a/foundation/erpnext_foundation/doctype/bounty/bounty.json b/foundation/erpnext_foundation/doctype/bounty/bounty.json index db9fc002..4a12c176 100644 --- a/foundation/erpnext_foundation/doctype/bounty/bounty.json +++ b/foundation/erpnext_foundation/doctype/bounty/bounty.json @@ -49,7 +49,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "github_issue", + "fieldname": "route", "fieldtype": "Data", "hidden": 0, "ignore_user_permissions": 0, @@ -58,7 +58,37 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "GitHub Issue", + "label": "Route", + "length": 0, + "no_copy": 0, + "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 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "published", + "fieldtype": "Check", + "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": "Published", "length": 0, "no_copy": 0, "permlevel": 0, @@ -162,6 +192,36 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "github_issue", + "fieldtype": "Data", + "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": "GitHub Issue", + "length": 0, + "no_copy": 0, + "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 + }, { "allow_bulk_edit": 0, "allow_on_submit": 0, @@ -282,66 +342,6 @@ "set_only_once": 0, "unique": 0 }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "published", - "fieldtype": "Check", - "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": "Published", - "length": 0, - "no_copy": 0, - "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 - }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "route", - "fieldtype": "Data", - "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": "Route", - "length": 0, - "no_copy": 0, - "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 - }, { "allow_bulk_edit": 0, "allow_on_submit": 0, @@ -364,7 +364,7 @@ "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, - "read_only": 0, + "read_only": 1, "remember_last_selected_value": 0, "report_hide": 0, "reqd": 0, @@ -384,7 +384,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2017-08-17 15:47:24.234653", + "modified": "2017-08-21 15:20:13.637175", "modified_by": "Administrator", "module": "ERPNext Foundation", "name": "Bounty", diff --git a/foundation/erpnext_foundation/doctype/bounty/bounty.py b/foundation/erpnext_foundation/doctype/bounty/bounty.py index 44297508..78766b41 100644 --- a/foundation/erpnext_foundation/doctype/bounty/bounty.py +++ b/foundation/erpnext_foundation/doctype/bounty/bounty.py @@ -34,6 +34,9 @@ class Bounty(WebsiteGenerator): def validate(self): self.bounty_collected = sum([backer.amount for backer in self.bounty_backer if backer.paid]) + if not self.route: + self.published = 1 + self.route = 'bounty/' + self.feature_name.lower().replace(' ', '-') def get_list_context(context): context.allow_guest = True @@ -41,5 +44,5 @@ def get_list_context(context): context.title = 'ERPNext Bounties' context.no_breadcrumbs = True context.order_by = 'creation desc' - context.introduction = '

List of all ERPNext bounties

' + context.introduction = 'Start a new Bounty' context.fmt_money = fmt_money \ No newline at end of file diff --git a/foundation/erpnext_foundation/doctype/bounty/templates/bounty_row.html b/foundation/erpnext_foundation/doctype/bounty/templates/bounty_row.html index 632f974c..3426ecd1 100644 --- a/foundation/erpnext_foundation/doctype/bounty/templates/bounty_row.html +++ b/foundation/erpnext_foundation/doctype/bounty/templates/bounty_row.html @@ -1,9 +1,18 @@ +{% if doc.published %}

{{ doc.feature_name }}

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

{{ fmt_money(doc.goal, currency="USD") }} {{ doc.end_date }} + {% if doc.bounty_backer %} {{ doc.bounty_backer|len }} {% if doc.bounty_backer|len > 1 %} @@ -12,7 +21,9 @@ Backer {% endif %} + {% endif %}

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

-
\ No newline at end of file + +{% endif %} \ No newline at end of file diff --git a/foundation/erpnext_foundation/doctype/bounty_backer/bounty_backer.py b/foundation/erpnext_foundation/doctype/bounty_backer/bounty_backer.py index 526858a8..d2950e5d 100644 --- a/foundation/erpnext_foundation/doctype/bounty_backer/bounty_backer.py +++ b/foundation/erpnext_foundation/doctype/bounty_backer/bounty_backer.py @@ -17,6 +17,7 @@ class BountyBacker(Document): def on_payment_authorized(self, *args, **kwargs): self.db_set('paid', 1) + # to trigger form events of Bounty doctype doc = frappe.get_doc('Bounty', self.bounty_name) doc.save()