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..0d90952e --- /dev/null +++ b/foundation/erpnext_foundation/doctype/bounty/bounty.js @@ -0,0 +1,13 @@ +// Copyright (c) 2017, EOSSF and contributors +// For license information, please see license.txt + +frappe.ui.form.on('Bounty', { + refresh: function(frm) { + + }, + feature_name: function(frm) { + if (frm.doc.route) return; + 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 new file mode 100644 index 00000000..4191a7e7 --- /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": "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": "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": "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": "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": "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": "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": 1, + "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-23 17:58:31.810230", + "modified_by": "faris@erpnext.com", + "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": "bounties", + "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..24fd2d33 --- /dev/null +++ b/foundation/erpnext_foundation/doctype/bounty/bounty.py @@ -0,0 +1,58 @@ +# -*- 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 +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): + 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 = 'Be the first to back this bounty' + elif no_of_backers == 1: + no_of_backers = str(no_of_backers) + ' backer' + else: + no_of_backers = str(no_of_backers) + ' backers' + + 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.no_breadcrumbs = False + context.days_to_go = date_diff(self.end_date, nowdate()) + 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 + 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 + context.title = 'ERPNext Bounties' + context.no_breadcrumbs = True + context.order_by = 'creation desc' + 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.html b/foundation/erpnext_foundation/doctype/bounty/templates/bounty.html new file mode 100644 index 00000000..98dc311d --- /dev/null +++ b/foundation/erpnext_foundation/doctype/bounty/templates/bounty.html @@ -0,0 +1,118 @@ +{% extends "templates/web.html" %} + +{% block page_content %} + + +
+

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

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

+

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

+

+ {{ no_of_backers }} + {% if paid_backers %} + ({{ paid_backers }}) + {% endif %} +

+ {% if doc.github_issue %} +

+ GitHub Issue +

+ {% endif %} + +
+ + +
+ + +
+
+ + Back this bounty + +

+ + +
+

+

About this feature
+

{{doc.description}}

+

+
+

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..f4e82142 --- /dev/null +++ b/foundation/erpnext_foundation/doctype/bounty/templates/bounty_row.html @@ -0,0 +1,29 @@ +{% 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") }} + Ends on {{ doc.end_date }} + {% if doc.bounty_backer %} + + {{ doc.bounty_backer|len }} + {% if doc.bounty_backer|len > 1 %} + Backers + {% else %} + Backer + {% endif %} + + {% endif %} +

+

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

+
+
+{% 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..f4ea096e --- /dev/null +++ b/foundation/erpnext_foundation/doctype/bounty_backer/bounty_backer.json @@ -0,0 +1,224 @@ +{ + "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 + }, + { + "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, + "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-25 18:41:22.187182", + "modified_by": "Administrator", + "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..49e80ade --- /dev/null +++ b/foundation/erpnext_foundation/doctype/bounty_backer/bounty_backer.py @@ -0,0 +1,26 @@ +# -*- 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, status_changed_to=None): + if status_changed_to in ("Completed", "Authorized"): + self.db_set('paid', 1) + # to trigger form events of Bounty doctype + doc = frappe.get_doc('Bounty', self.bounty_name) + doc.save() + return '/' + doc.route + return '/bounties' + 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..2385473f --- /dev/null +++ b/foundation/erpnext_foundation/web_form/back_this_bounty/back_this_bounty.js @@ -0,0 +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/back_this_bounty.json b/foundation/erpnext_foundation/web_form/back_this_bounty/back_this_bounty.json new file mode 100644 index 00000000..45bbc7a2 --- /dev/null +++ b/foundation/erpnext_foundation/web_form/back_this_bounty/back_this_bounty.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-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-26 21:13:32.398765", + "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": "back-this-bounty-inr", + "show_sidebar": 0, + "sidebar_items": [], + "success_url": "/bounties", + "title": "Back this bounty - INR", + "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/back_this_bounty.py b/foundation/erpnext_foundation/web_form/back_this_bounty/back_this_bounty.py new file mode 100644 index 00000000..2334f8b2 --- /dev/null +++ b/foundation/erpnext_foundation/web_form/back_this_bounty/back_this_bounty.py @@ -0,0 +1,7 @@ +from __future__ import unicode_literals + +import frappe + +def get_context(context): + # do your magic here + pass 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..2385473f --- /dev/null +++ b/foundation/erpnext_foundation/web_form/back_this_bounty_usd/back_this_bounty_usd.js @@ -0,0 +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.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 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..227756fc --- /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-23 18:04:50.092049", + "modified_by": "faris@erpnext.com", + "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": "/bounties", + "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 diff --git a/foundation/hooks.py b/foundation/hooks.py index dc08c7e4..6741c2fd 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": "/bounties", "right": 1}, {"label": 'Conference', "url": "/conf/2017", "right": 1}, {"label": "About", "url": "/about", "right": 1}, ],