From c5540b5833a099eba2d71371828a3e7bd4bd75ab Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Fri, 18 Aug 2017 11:05:36 +0530 Subject: [PATCH 01/11] first cut --- .../doctype/bounty/__init__.py | 0 .../doctype/bounty/bounty.js | 8 + .../doctype/bounty/bounty.json | 425 ++++++++++++++++++ .../doctype/bounty/bounty.py | 23 + .../doctype/bounty/templates/bounty.html | 27 ++ .../doctype/bounty/templates/bounty_row.html | 11 + .../doctype/bounty/test_bounty.js | 23 + .../doctype/bounty/test_bounty.py | 10 + .../doctype/bounty_backer/__init__.py | 0 .../doctype/bounty_backer/bounty_backer.json | 193 ++++++++ .../doctype/bounty_backer/bounty_backer.py | 22 + .../web_form/back_this_bounty/__init__.py | 0 .../back_this_bounty/back_this_bounty.js | 15 + .../back_this_bounty/back_this_bounty.json | 68 +++ .../back_this_bounty/back_this_bounty.py | 8 + 15 files changed, 833 insertions(+) create mode 100644 foundation/erpnext_foundation/doctype/bounty/__init__.py create mode 100644 foundation/erpnext_foundation/doctype/bounty/bounty.js create mode 100644 foundation/erpnext_foundation/doctype/bounty/bounty.json create mode 100644 foundation/erpnext_foundation/doctype/bounty/bounty.py create mode 100644 foundation/erpnext_foundation/doctype/bounty/templates/bounty.html create mode 100644 foundation/erpnext_foundation/doctype/bounty/templates/bounty_row.html create mode 100644 foundation/erpnext_foundation/doctype/bounty/test_bounty.js create mode 100644 foundation/erpnext_foundation/doctype/bounty/test_bounty.py create mode 100644 foundation/erpnext_foundation/doctype/bounty_backer/__init__.py create mode 100644 foundation/erpnext_foundation/doctype/bounty_backer/bounty_backer.json create mode 100644 foundation/erpnext_foundation/doctype/bounty_backer/bounty_backer.py create mode 100644 foundation/erpnext_foundation/web_form/back_this_bounty/__init__.py create mode 100644 foundation/erpnext_foundation/web_form/back_this_bounty/back_this_bounty.js create mode 100644 foundation/erpnext_foundation/web_form/back_this_bounty/back_this_bounty.json create mode 100644 foundation/erpnext_foundation/web_form/back_this_bounty/back_this_bounty.py diff --git a/foundation/erpnext_foundation/doctype/bounty/__init__.py b/foundation/erpnext_foundation/doctype/bounty/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/foundation/erpnext_foundation/doctype/bounty/bounty.js b/foundation/erpnext_foundation/doctype/bounty/bounty.js new file mode 100644 index 00000000..a0f97067 --- /dev/null +++ b/foundation/erpnext_foundation/doctype/bounty/bounty.js @@ -0,0 +1,8 @@ +// Copyright (c) 2017, EOSSF and contributors +// For license information, please see license.txt + +frappe.ui.form.on('Bounty', { + refresh: function(frm) { + + } +}); diff --git a/foundation/erpnext_foundation/doctype/bounty/bounty.json b/foundation/erpnext_foundation/doctype/bounty/bounty.json new file mode 100644 index 00000000..db9fc002 --- /dev/null +++ b/foundation/erpnext_foundation/doctype/bounty/bounty.json @@ -0,0 +1,425 @@ +{ + "allow_copy": 0, + "allow_guest_to_view": 1, + "allow_import": 0, + "allow_rename": 0, + "autoname": "BOUNTY.#####", + "beta": 1, + "creation": "2017-08-17 14:43:33.903126", + "custom": 0, + "docstatus": 0, + "doctype": "DocType", + "document_type": "", + "editable_grid": 1, + "engine": "InnoDB", + "fields": [ + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 1, + "collapsible": 0, + "columns": 0, + "fieldname": "feature_name", + "fieldtype": "Data", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 1, + "in_list_view": 1, + "in_standard_filter": 0, + "label": "Feature Name", + "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": 1, + "search_index": 0, + "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, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "column_break_3", + "fieldtype": "Column Break", + "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, + "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": "goal", + "fieldtype": "Currency", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 1, + "in_standard_filter": 0, + "label": "Goal", + "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": 1, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "end_date", + "fieldtype": "Date", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 1, + "in_standard_filter": 0, + "label": "End Date", + "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": "section_break_4", + "fieldtype": "Section Break", + "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, + "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": "description", + "fieldtype": "Text Editor", + "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": "Description", + "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": "section_break_6", + "fieldtype": "Section Break", + "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": "Backers", + "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": "bounty_backer", + "fieldtype": "Table", + "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": "Bounty Backer", + "length": 0, + "no_copy": 0, + "options": "Bounty Backer", + "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, + "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, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "bounty_collected", + "fieldtype": "Currency", + "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": "Bounty Collected", + "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 + } + ], + "has_web_view": 1, + "hide_heading": 0, + "hide_toolbar": 0, + "idx": 0, + "image_view": 0, + "in_create": 0, + "is_published_field": "published", + "is_submittable": 0, + "issingle": 0, + "istable": 0, + "max_attachments": 0, + "modified": "2017-08-17 15:47:24.234653", + "modified_by": "Administrator", + "module": "ERPNext Foundation", + "name": "Bounty", + "name_case": "", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "apply_user_permissions": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "if_owner": 0, + "import": 0, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "set_user_permissions": 0, + "share": 1, + "submit": 0, + "write": 1 + } + ], + "quick_entry": 0, + "read_only": 0, + "read_only_onload": 0, + "route": "bounty", + "show_name_in_global_search": 0, + "sort_field": "modified", + "sort_order": "DESC", + "title_field": "feature_name", + "track_changes": 1, + "track_seen": 0 +} \ No newline at end of file diff --git a/foundation/erpnext_foundation/doctype/bounty/bounty.py b/foundation/erpnext_foundation/doctype/bounty/bounty.py new file mode 100644 index 00000000..ada515e1 --- /dev/null +++ b/foundation/erpnext_foundation/doctype/bounty/bounty.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2017, EOSSF and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +import frappe +from frappe.website.website_generator import WebsiteGenerator +from frappe.website.utils import get_comment_list + +class Bounty(WebsiteGenerator): + def get_context(self, context): + context.no_cache = True + + def validate(self): + self.bounty_collected = sum([backer.amount for backer in self.bounty_backer if backer.paid]) + +def get_list_context(context): + context.allow_guest = True + context.no_cache = True + context.title = 'ERPNext Bounties' + context.no_breadcrumbs = True + context.order_by = 'creation desc' + context.introduction = '

ERPNext feature requests

' diff --git a/foundation/erpnext_foundation/doctype/bounty/templates/bounty.html b/foundation/erpnext_foundation/doctype/bounty/templates/bounty.html new file mode 100644 index 00000000..975ff35a --- /dev/null +++ b/foundation/erpnext_foundation/doctype/bounty/templates/bounty.html @@ -0,0 +1,27 @@ +{% extends "templates/web.html" %} + +{% block page_content %} +

{{ title }}

+{% 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") }} + +

+

+

{{ doc.end_date }}

+ +Back this bounty + +

Discuss

+{% include 'templates/includes/comments/comments.html' %} + +{% endblock %} + + \ 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 new file mode 100644 index 00000000..c42a7bdf --- /dev/null +++ b/foundation/erpnext_foundation/doctype/bounty/templates/bounty_row.html @@ -0,0 +1,11 @@ +
+ +

{{ doc.feature_name }}

+

+ {{ frappe.format(doc.goal) }} + {{ doc.end_date }} + {{ doc.bounty_backer }} Backers +

+

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

+
+
\ No newline at end of file diff --git a/foundation/erpnext_foundation/doctype/bounty/test_bounty.js b/foundation/erpnext_foundation/doctype/bounty/test_bounty.js new file mode 100644 index 00000000..6b429b96 --- /dev/null +++ b/foundation/erpnext_foundation/doctype/bounty/test_bounty.js @@ -0,0 +1,23 @@ +/* eslint-disable */ +// rename this file from _test_[name] to test_[name] to activate +// and remove above this line + +QUnit.test("test: Bounty", function (assert) { + let done = assert.async(); + + // number of asserts + assert.expect(1); + + frappe.run_serially([ + // insert a new Bounty + () => frappe.tests.make('Bounty', [ + // values to be set + {key: 'value'} + ]), + () => { + assert.equal(cur_frm.doc.key, 'value'); + }, + () => done() + ]); + +}); diff --git a/foundation/erpnext_foundation/doctype/bounty/test_bounty.py b/foundation/erpnext_foundation/doctype/bounty/test_bounty.py new file mode 100644 index 00000000..0f925c53 --- /dev/null +++ b/foundation/erpnext_foundation/doctype/bounty/test_bounty.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2017, EOSSF and Contributors +# See license.txt +from __future__ import unicode_literals + +import frappe +import unittest + +class TestBounty(unittest.TestCase): + pass diff --git a/foundation/erpnext_foundation/doctype/bounty_backer/__init__.py b/foundation/erpnext_foundation/doctype/bounty_backer/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/foundation/erpnext_foundation/doctype/bounty_backer/bounty_backer.json b/foundation/erpnext_foundation/doctype/bounty_backer/bounty_backer.json new file mode 100644 index 00000000..eb559d5e --- /dev/null +++ b/foundation/erpnext_foundation/doctype/bounty_backer/bounty_backer.json @@ -0,0 +1,193 @@ +{ + "allow_copy": 0, + "allow_guest_to_view": 0, + "allow_import": 0, + "allow_rename": 0, + "beta": 0, + "creation": "2017-08-17 14:46:40.983106", + "custom": 0, + "docstatus": 0, + "doctype": "DocType", + "document_type": "", + "editable_grid": 1, + "engine": "InnoDB", + "fields": [ + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "user", + "fieldtype": "Link", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 1, + "in_standard_filter": 0, + "label": "User", + "length": 0, + "no_copy": 0, + "options": "User", + "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": "full_name", + "fieldtype": "Read Only", + "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": "Full Name", + "length": 0, + "no_copy": 0, + "options": "", + "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": "amount", + "fieldtype": "Currency", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 1, + "in_standard_filter": 0, + "label": "Amount", + "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": "paid", + "fieldtype": "Check", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 1, + "in_standard_filter": 0, + "label": "Paid", + "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": "bounty_name", + "fieldtype": "Read Only", + "hidden": 1, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Bounty Name", + "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 + } + ], + "has_web_view": 0, + "hide_heading": 0, + "hide_toolbar": 0, + "idx": 0, + "image_view": 0, + "in_create": 0, + "is_submittable": 0, + "issingle": 0, + "istable": 1, + "max_attachments": 0, + "modified": "2017-08-17 17:26:35.968048", + "modified_by": "faris@erpnext.com", + "module": "ERPNext Foundation", + "name": "Bounty Backer", + "name_case": "", + "owner": "Administrator", + "permissions": [], + "quick_entry": 1, + "read_only": 0, + "read_only_onload": 0, + "show_name_in_global_search": 0, + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1, + "track_seen": 0 +} \ 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 new file mode 100644 index 00000000..526858a8 --- /dev/null +++ b/foundation/erpnext_foundation/doctype/bounty_backer/bounty_backer.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2017, EOSSF and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +import frappe +from frappe.model.document import Document + +class BountyBacker(Document): + def validate(self): + self.parenttype = 'Bounty' + self.parentfield = 'bounty_backer' + self.parent = self.bounty_name + + doc = frappe.get_doc('Bounty', self.bounty_name) + self.idx = len(doc.bounty_backer) + + def on_payment_authorized(self, *args, **kwargs): + self.db_set('paid', 1) + doc = frappe.get_doc('Bounty', self.bounty_name) + doc.save() + diff --git a/foundation/erpnext_foundation/web_form/back_this_bounty/__init__.py b/foundation/erpnext_foundation/web_form/back_this_bounty/__init__.py new file mode 100644 index 00000000..e69de29b 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 new file mode 100644 index 00000000..7373ba61 --- /dev/null +++ b/foundation/erpnext_foundation/web_form/back_this_bounty/back_this_bounty.js @@ -0,0 +1,15 @@ +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 new file mode 100644 index 00000000..0d9907d8 --- /dev/null +++ b/foundation/erpnext_foundation/web_form/back_this_bounty/back_this_bounty.json @@ -0,0 +1,68 @@ +{ + "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-17 16:11:44.935590", + "currency": "INR", + "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-18 08:18:03.166262", + "modified_by": "faris@erpnext.com", + "module": "ERPNext Foundation", + "name": "back-this-bounty", + "owner": "faris@erpnext.com", + "payment_button_label": "Pay now", + "payment_gateway": "Razorpay", + "published": 1, + "route": "bounty/back-this-bounty", + "show_sidebar": 1, + "sidebar_items": [], + "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", + "hidden": 0, + "label": "User", + "max_length": 0, + "max_value": 0, + "options": "User", + "read_only": 1, + "reqd": 0 + }, + { + "fieldname": "amount", + "fieldtype": "Int", + "hidden": 0, + "label": "Amount", + "max_length": 0, + "max_value": 0, + "read_only": 0, + "reqd": 0 + } + ] +} \ No newline at end of file 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 new file mode 100644 index 00000000..d0064bde --- /dev/null +++ b/foundation/erpnext_foundation/web_form/back_this_bounty/back_this_bounty.py @@ -0,0 +1,8 @@ +from __future__ import unicode_literals + +import frappe + +def get_context(context): + print(context) + context.no_breadcrumbs = 1 + context.user = 'faris@erpnext.com' From 91ffcac3cbcde742fd22d25ecd70d4685034708f Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Fri, 18 Aug 2017 15:15:41 +0530 Subject: [PATCH 02/11] Styling --- .../doctype/bounty/bounty.py | 24 ++++++++- .../doctype/bounty/templates/bounty.html | 51 ++++++++++++++++--- .../doctype/bounty/templates/bounty_row.html | 11 +++- .../back_this_bounty/back_this_bounty.js | 12 ----- .../back_this_bounty/back_this_bounty.json | 22 ++++---- .../back_this_bounty/back_this_bounty.py | 5 +- foundation/hooks.py | 1 + 7 files changed, 89 insertions(+), 37 deletions(-) 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}, ], From 39751503dca0d36c211c13f78936f4f34ccec9bd Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Fri, 18 Aug 2017 15:22:51 +0530 Subject: [PATCH 03/11] Add Github Issue link --- .../doctype/bounty/templates/bounty.html | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/foundation/erpnext_foundation/doctype/bounty/templates/bounty.html b/foundation/erpnext_foundation/doctype/bounty/templates/bounty.html index d698d980..4ccf4933 100644 --- a/foundation/erpnext_foundation/doctype/bounty/templates/bounty.html +++ b/foundation/erpnext_foundation/doctype/bounty/templates/bounty.html @@ -10,6 +10,10 @@ width: 200px; margin-bottom: 12px; } + + p.lead { + margin-bottom: 10px; + }
@@ -28,6 +32,11 @@

{{ no_of_backers }}

+ {% if doc.github_issue %} +

+ GitHub Issue +

+ {% endif %}

From f19ee9e9f1a5619d61b7f929456406441adee483 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Mon, 21 Aug 2017 15:39:21 +0530 Subject: [PATCH 04/11] Cleanup, add progress in list view --- .../doctype/bounty/bounty.js | 5 + .../doctype/bounty/bounty.json | 128 +++++++++--------- .../doctype/bounty/bounty.py | 5 +- .../doctype/bounty/templates/bounty_row.html | 13 +- .../doctype/bounty_backer/bounty_backer.py | 1 + 5 files changed, 86 insertions(+), 66 deletions(-) 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 %} \ 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() From bd797b590457c26aab3436466b31b8e92eef42ea Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Mon, 21 Aug 2017 16:37:13 +0530 Subject: [PATCH 05/11] Start a new Bounty is standard --- .../back_this_bounty/back_this_bounty.json | 4 +- .../web_form/start_a_new_bounty/__init__.py | 0 .../start_a_new_bounty/start_a_new_bounty.js | 3 + .../start_a_new_bounty.json | 85 +++++++++++++++++++ .../start_a_new_bounty/start_a_new_bounty.py | 7 ++ 5 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 foundation/erpnext_foundation/web_form/start_a_new_bounty/__init__.py create mode 100644 foundation/erpnext_foundation/web_form/start_a_new_bounty/start_a_new_bounty.js create mode 100644 foundation/erpnext_foundation/web_form/start_a_new_bounty/start_a_new_bounty.json create mode 100644 foundation/erpnext_foundation/web_form/start_a_new_bounty/start_a_new_bounty.py 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 12b1d5c7..fee23bbf 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,8 +19,8 @@ "is_standard": 1, "login_required": 1, "max_attachment_size": 0, - "modified": "2017-08-18 14:41:04.132808", - "modified_by": "faris@erpnext.com", + "modified": "2017-08-21 16:36:33.431742", + "modified_by": "Administrator", "module": "ERPNext Foundation", "name": "back-this-bounty", "owner": "faris@erpnext.com", diff --git a/foundation/erpnext_foundation/web_form/start_a_new_bounty/__init__.py b/foundation/erpnext_foundation/web_form/start_a_new_bounty/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/foundation/erpnext_foundation/web_form/start_a_new_bounty/start_a_new_bounty.js b/foundation/erpnext_foundation/web_form/start_a_new_bounty/start_a_new_bounty.js new file mode 100644 index 00000000..699703c5 --- /dev/null +++ b/foundation/erpnext_foundation/web_form/start_a_new_bounty/start_a_new_bounty.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/start_a_new_bounty/start_a_new_bounty.json b/foundation/erpnext_foundation/web_form/start_a_new_bounty/start_a_new_bounty.json new file mode 100644 index 00000000..763972b4 --- /dev/null +++ b/foundation/erpnext_foundation/web_form/start_a_new_bounty/start_a_new_bounty.json @@ -0,0 +1,85 @@ +{ + "accept_payment": 0, + "allow_comments": 0, + "allow_delete": 0, + "allow_edit": 1, + "allow_incomplete": 0, + "allow_multiple": 1, + "allow_print": 0, + "amount": 0.0, + "amount_based_on_field": 0, + "creation": "2017-08-21 13:28:42.069722", + "currency": "INR", + "doc_type": "Bounty", + "docstatus": 0, + "doctype": "Web Form", + "idx": 0, + "introduction_text": "", + "is_standard": 1, + "login_required": 1, + "max_attachment_size": 0, + "modified": "2017-08-21 16:36:27.918067", + "modified_by": "Administrator", + "module": "ERPNext Foundation", + "name": "start-a-new-bounty", + "owner": "Administrator", + "payment_button_label": "Buy Now", + "published": 1, + "route": "new-bounty", + "show_sidebar": 1, + "sidebar_items": [], + "success_url": "/bounty", + "title": "Start a new Bounty", + "web_form_fields": [ + { + "fieldname": "feature_name", + "fieldtype": "Data", + "hidden": 0, + "label": "Feature Name", + "max_length": 0, + "max_value": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "goal", + "fieldtype": "Data", + "hidden": 0, + "label": "Goal", + "max_length": 0, + "max_value": 0, + "read_only": 0, + "reqd": 1 + }, + { + "fieldname": "end_date", + "fieldtype": "Date", + "hidden": 0, + "label": "End Date", + "max_length": 0, + "max_value": 0, + "read_only": 0, + "reqd": 0 + }, + { + "fieldname": "description", + "fieldtype": "Text Editor", + "hidden": 0, + "label": "Description", + "max_length": 0, + "max_value": 0, + "read_only": 0, + "reqd": 0 + }, + { + "fieldname": "github_issue", + "fieldtype": "Data", + "hidden": 0, + "label": "GitHub Issue", + "max_length": 0, + "max_value": 0, + "read_only": 0, + "reqd": 0 + } + ] +} \ No newline at end of file diff --git a/foundation/erpnext_foundation/web_form/start_a_new_bounty/start_a_new_bounty.py b/foundation/erpnext_foundation/web_form/start_a_new_bounty/start_a_new_bounty.py new file mode 100644 index 00000000..2334f8b2 --- /dev/null +++ b/foundation/erpnext_foundation/web_form/start_a_new_bounty/start_a_new_bounty.py @@ -0,0 +1,7 @@ +from __future__ import unicode_literals + +import frappe + +def get_context(context): + # do your magic here + pass From f05f53a0f0a4f52e7e052ab61f41799ab2b5331b Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Wed, 23 Aug 2017 18:09:39 +0530 Subject: [PATCH 06/11] Change route from bounty to bounties --- foundation/erpnext_foundation/doctype/bounty/bounty.js | 2 +- foundation/erpnext_foundation/doctype/bounty/bounty.json | 6 +++--- foundation/erpnext_foundation/doctype/bounty/bounty.py | 2 +- .../doctype/bounty/templates/bounty_row.html | 2 +- .../web_form/back_this_bounty/back_this_bounty.json | 6 +++--- .../web_form/start_a_new_bounty/start_a_new_bounty.json | 6 +++--- foundation/hooks.py | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/foundation/erpnext_foundation/doctype/bounty/bounty.js b/foundation/erpnext_foundation/doctype/bounty/bounty.js index e8d26cb2..0d90952e 100644 --- a/foundation/erpnext_foundation/doctype/bounty/bounty.js +++ b/foundation/erpnext_foundation/doctype/bounty/bounty.js @@ -7,7 +7,7 @@ frappe.ui.form.on('Bounty', { }, feature_name: function(frm) { if (frm.doc.route) return; - const route = 'bounty/' + frm.doc.feature_name.toLowerCase().replace(/ /g, '-'); + const route = 'bounties/' + 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 4a12c176..4191a7e7 100644 --- a/foundation/erpnext_foundation/doctype/bounty/bounty.json +++ b/foundation/erpnext_foundation/doctype/bounty/bounty.json @@ -384,8 +384,8 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2017-08-21 15:20:13.637175", - "modified_by": "Administrator", + "modified": "2017-08-23 17:58:31.810230", + "modified_by": "faris@erpnext.com", "module": "ERPNext Foundation", "name": "Bounty", "name_case": "", @@ -415,7 +415,7 @@ "quick_entry": 0, "read_only": 0, "read_only_onload": 0, - "route": "bounty", + "route": "bounties", "show_name_in_global_search": 0, "sort_field": "modified", "sort_order": "DESC", diff --git a/foundation/erpnext_foundation/doctype/bounty/bounty.py b/foundation/erpnext_foundation/doctype/bounty/bounty.py index 78766b41..4a9241a5 100644 --- a/foundation/erpnext_foundation/doctype/bounty/bounty.py +++ b/foundation/erpnext_foundation/doctype/bounty/bounty.py @@ -36,7 +36,7 @@ class Bounty(WebsiteGenerator): 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(' ', '-') + self.route = 'bounties/' + self.feature_name.lower().replace(' ', '-') def get_list_context(context): context.allow_guest = True diff --git a/foundation/erpnext_foundation/doctype/bounty/templates/bounty_row.html b/foundation/erpnext_foundation/doctype/bounty/templates/bounty_row.html index 3426ecd1..f4e82142 100644 --- a/foundation/erpnext_foundation/doctype/bounty/templates/bounty_row.html +++ b/foundation/erpnext_foundation/doctype/bounty/templates/bounty_row.html @@ -11,7 +11,7 @@

{{ fmt_money(doc.goal, currency="USD") }} - {{ doc.end_date }} + Ends on {{ doc.end_date }} {% if doc.bounty_backer %} {{ doc.bounty_backer|len }} 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 fee23bbf..cd25f895 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,8 +19,8 @@ "is_standard": 1, "login_required": 1, "max_attachment_size": 0, - "modified": "2017-08-21 16:36:33.431742", - "modified_by": "Administrator", + "modified": "2017-08-23 18:05:50.695856", + "modified_by": "faris@erpnext.com", "module": "ERPNext Foundation", "name": "back-this-bounty", "owner": "faris@erpnext.com", @@ -30,7 +30,7 @@ "route": "bounty/back-this-bounty", "show_sidebar": 1, "sidebar_items": [], - "success_url": "/bounty", + "success_url": "/bounties", "title": "Back this bounty", "web_form_fields": [ { diff --git a/foundation/erpnext_foundation/web_form/start_a_new_bounty/start_a_new_bounty.json b/foundation/erpnext_foundation/web_form/start_a_new_bounty/start_a_new_bounty.json index 763972b4..227756fc 100644 --- a/foundation/erpnext_foundation/web_form/start_a_new_bounty/start_a_new_bounty.json +++ b/foundation/erpnext_foundation/web_form/start_a_new_bounty/start_a_new_bounty.json @@ -18,8 +18,8 @@ "is_standard": 1, "login_required": 1, "max_attachment_size": 0, - "modified": "2017-08-21 16:36:27.918067", - "modified_by": "Administrator", + "modified": "2017-08-23 18:04:50.092049", + "modified_by": "faris@erpnext.com", "module": "ERPNext Foundation", "name": "start-a-new-bounty", "owner": "Administrator", @@ -28,7 +28,7 @@ "route": "new-bounty", "show_sidebar": 1, "sidebar_items": [], - "success_url": "/bounty", + "success_url": "/bounties", "title": "Start a new Bounty", "web_form_fields": [ { diff --git a/foundation/hooks.py b/foundation/hooks.py index 6dda8aec..6741c2fd 100644 --- a/foundation/hooks.py +++ b/foundation/hooks.py @@ -47,7 +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": "Bounties", "url": "/bounties", "right": 1}, {"label": 'Conference', "url": "/conf/2017", "right": 1}, {"label": "About", "url": "/about", "right": 1}, ], From 841ddbd06427875e75e6c4a9173317f5fc42f210 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Wed, 23 Aug 2017 19:20:28 +0530 Subject: [PATCH 07/11] Fix success url --- .../doctype/bounty/templates/bounty.html | 2 +- .../doctype/bounty_backer/bounty_backer.py | 13 ++++++++----- .../web_form/back_this_bounty/back_this_bounty.json | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/foundation/erpnext_foundation/doctype/bounty/templates/bounty.html b/foundation/erpnext_foundation/doctype/bounty/templates/bounty.html index 4ccf4933..5518ee08 100644 --- a/foundation/erpnext_foundation/doctype/bounty/templates/bounty.html +++ b/foundation/erpnext_foundation/doctype/bounty/templates/bounty.html @@ -47,7 +47,7 @@ diff --git a/foundation/erpnext_foundation/doctype/bounty/templates/bounty_row.html b/foundation/erpnext_foundation/doctype/bounty/templates/bounty_row.html index 3b20b9cf..f4e82142 100644 --- a/foundation/erpnext_foundation/doctype/bounty/templates/bounty_row.html +++ b/foundation/erpnext_foundation/doctype/bounty/templates/bounty_row.html @@ -10,7 +10,7 @@

- {{ 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 From cbe8d2d9d98cd3ace0eb9212e9401db64ab42de7 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Sun, 27 Aug 2017 14:10:34 +0530 Subject: [PATCH 10/11] minor --- foundation/erpnext_foundation/doctype/bounty/bounty.py | 3 ++- .../doctype/bounty/templates/bounty.html | 8 +++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/foundation/erpnext_foundation/doctype/bounty/bounty.py b/foundation/erpnext_foundation/doctype/bounty/bounty.py index 97c13221..203634e2 100644 --- a/foundation/erpnext_foundation/doctype/bounty/bounty.py +++ b/foundation/erpnext_foundation/doctype/bounty/bounty.py @@ -25,8 +25,9 @@ class Bounty(WebsiteGenerator): bounty_left = self.goal * 0.1 context.no_cache = True + context.no_breadcrumbs = False context.days_to_go = date_diff(self.end_date, nowdate()) - context.paid_backers = paid_backers + context.paid_backers = ", ".join([backer.full_name or backer.user for backer in paid_backers]) context.no_of_backers = no_of_backers context.fmt_money = fmt_money context.bounty_left = bounty_left diff --git a/foundation/erpnext_foundation/doctype/bounty/templates/bounty.html b/foundation/erpnext_foundation/doctype/bounty/templates/bounty.html index 64428bdf..1f78a014 100644 --- a/foundation/erpnext_foundation/doctype/bounty/templates/bounty.html +++ b/foundation/erpnext_foundation/doctype/bounty/templates/bounty.html @@ -45,11 +45,9 @@

{{ no_of_backers }} - ( - {% for backer in paid_backers %} - {{ backer.full_name }}, - {% endfor %} - ) + {% if paid_backers %} + ({{ paid_backers }}) + {% endif %}

{% if doc.github_issue %}

From 398bac512a0dd6e0e8dc7df4214d0f7e33ff07d0 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Mon, 28 Aug 2017 15:49:33 +0530 Subject: [PATCH 11/11] Add edit button --- foundation/erpnext_foundation/doctype/bounty/bounty.py | 2 +- .../doctype/bounty/templates/bounty.html | 10 ++++++++-- .../web_form/back_this_bounty/back_this_bounty.js | 6 +++++- .../back_this_bounty_usd/back_this_bounty_usd.js | 6 +++++- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/foundation/erpnext_foundation/doctype/bounty/bounty.py b/foundation/erpnext_foundation/doctype/bounty/bounty.py index 203634e2..24fd2d33 100644 --- a/foundation/erpnext_foundation/doctype/bounty/bounty.py +++ b/foundation/erpnext_foundation/doctype/bounty/bounty.py @@ -14,7 +14,7 @@ class Bounty(WebsiteGenerator): 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' + no_of_backers = 'Be the first to back this bounty' elif no_of_backers == 1: no_of_backers = str(no_of_backers) + ' backer' else: diff --git a/foundation/erpnext_foundation/doctype/bounty/templates/bounty.html b/foundation/erpnext_foundation/doctype/bounty/templates/bounty.html index 1f78a014..98dc311d 100644 --- a/foundation/erpnext_foundation/doctype/bounty/templates/bounty.html +++ b/foundation/erpnext_foundation/doctype/bounty/templates/bounty.html @@ -31,7 +31,13 @@

-

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

+

+ {{ title }} + {% if doc.owner == frappe.session.user %} + Edit + {% endif %} + {{days_to_go}} days to go +

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

-

About this feature

+
About this feature

{{doc.description}}


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 8d110a16..2385473f 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,3 +1,7 @@ frappe.ready(function() { - + setTimeout(() => { + if ($('select[name=user]').val() === "") { + window.location.href = '/bounties'; + } + }, 1000); }) \ No newline at end of file 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 index 699703c5..2385473f 100644 --- 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 @@ -1,3 +1,7 @@ frappe.ready(function() { - // bind events here + setTimeout(() => { + if ($('select[name=user]').val() === "") { + window.location.href = '/bounties'; + } + }, 1000); }) \ No newline at end of file