Merge pull request #34 from netchampfaris/bounty-system

Bounty system
This commit is contained in:
Faris Ansari
2017-08-28 16:54:51 +05:30
committed by GitHub
24 changed files with 1208 additions and 0 deletions

View File

@@ -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);
}
});

View File

@@ -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
}

View File

@@ -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 = '<a href="new-bounty" class="btn btn-primary">Start a new Bounty</a>'
context.fmt_money = fmt_money

View File

@@ -0,0 +1,118 @@
{% extends "templates/web.html" %}
{% block page_content %}
<style>
.main {
margin-bottom: 50px;
}
.bounty-amount {
width: 200px;
margin-bottom: 12px;
}
.bounty-amount .dropdown-menu {
min-width: 100px;
}
.bounty-amount .dropdown-toggle {
border: 1px solid #d1d8dd;
}
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
p.lead {
margin-bottom: 10px;
}
</style>
<div class="main">
<h1>
{{ title }}
{% if doc.owner == frappe.session.user %}
<a href="/new-bounty?name={{doc.name}}" class="btn btn-default btn-xs">Edit</a>
{% endif %}
<span style="font-size: 14px; line-height: 44px;" class="pull-right small">{{days_to_go}} days to go</span>
</h1>
{% set bounty_progress = ((doc.bounty_collected/doc.goal)*100) %}
<div class="progress" style="height: 12px;">
<div class="progress-bar progress-bar-success" role="progressbar"
aria-valuenow="{{bounty_progress}}" aria-valuemin="0" aria-valuemax="100" style="width: {{bounty_progress}}%">
<span class="sr-only">{{ doc.bounty_collected }} of {{ doc.goal }}</span>
</div>
</div>
<p>
<p class="lead">{{ fmt_money(doc.bounty_collected, currency="USD") }}
<span class="text-muted small"> of {{ fmt_money(doc.goal, currency="USD") }}</span>
</p>
<p class="lead">
<span>{{ no_of_backers }}</span>
{% if paid_backers %}
<span class="small">({{ paid_backers }})</span>
{% endif %}
</p>
{% if doc.github_issue %}
<p>
<a href="{{doc.github_issue}}" target="_blank">GitHub Issue</a>
</p>
{% endif %}
<div class="input-group bounty-amount">
<input type="number" data-field="amount"
class="form-control" aria-label="Bounty Amount"
placeholder="{{fmt_money(bounty_left)}}">
<div class="input-group-btn">
<button type="button" class="btn btn-default dropdown-toggle"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="bounty-currency">USD</span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu dropdown-menu-right">
<li><a data-currency="USD">USD</a></li>
<li><a data-currency="INR">INR</a></li>
</ul>
</div>
</div>
<a data-action="primary" class="btn btn-primary">
Back this bounty
</a>
</p>
<script>
frappe.ready(function() {
const $bounty_amount = $('.bounty-amount');
$('[data-action="primary"]').click(function() {
const currency = $bounty_amount.find('.bounty-currency').text();
let url = `/back-this-bounty-${currency.toLowerCase()}`;
url += `?bounty_name={{doc.name}}&user=${frappe.session.user}&currency=${currency}`;
let amount = $('[data-field="amount"]').val();
if(amount > 0) {
url += '&amount=' + amount;
}
window.location.href = url;
});
$bounty_amount.on('click', '[data-currency]', function() {
const currency = $(this).attr('data-currency');
$bounty_amount.find('.bounty-currency').text(currency);
});
});
</script>
</div>
<p>
<h6 class="text-muted uppercase">About this feature</h6>
<p>{{doc.description}}</p>
</p>
<hr style="margin: 50px 0;">
<h3>Discuss</h3>
{% include 'templates/includes/comments/comments.html' %}
{% endblock %}
<!-- this is a sample default web page template -->

View File

@@ -0,0 +1,29 @@
{% if doc.published %}
<div style="margin-bottom: 30px; max-width: 600px" class="with-border clickable">
<a href={{ route }}>
<h3>{{ doc.feature_name }}</h3>
{% set bounty_progress = ((doc.bounty_collected/doc.goal)*100) %}
<div class="progress" style="height: 6px;">
<div class="progress-bar progress-bar-success" role="progressbar"
aria-valuenow="{{bounty_progress}}" aria-valuemin="0" aria-valuemax="100" style="width: {{bounty_progress}}%">
<span class="sr-only">{{ doc.bounty_collected }} of {{ doc.goal }}</span>
</div>
</div>
<p>
<span class="label">{{ fmt_money(doc.goal, currency="USD") }}</span>
<span class="label">Ends on {{ doc.end_date }}</span>
{% if doc.bounty_backer %}
<span class="label">
{{ doc.bounty_backer|len }}
{% if doc.bounty_backer|len > 1 %}
Backers
{% else %}
Backer
{% endif %}
</span>
{% endif %}
</p>
<p>{{ html2text(doc.description[:200]) }}{% if doc.description|len > 200 %}...{% endif %}</p>
</a>
</div>
{% endif %}

View File

@@ -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()
]);
});

View File

@@ -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

View File

@@ -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
}

View File

@@ -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'

View File

@@ -0,0 +1,7 @@
frappe.ready(function() {
setTimeout(() => {
if ($('select[name=user]').val() === "") {
window.location.href = '/bounties';
}
}, 1000);
})

View File

@@ -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
}
]
}

View File

@@ -0,0 +1,7 @@
from __future__ import unicode_literals
import frappe
def get_context(context):
# do your magic here
pass

View File

@@ -0,0 +1,7 @@
frappe.ready(function() {
setTimeout(() => {
if ($('select[name=user]').val() === "") {
window.location.href = '/bounties';
}
}, 1000);
})

View File

@@ -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
}
]
}

View File

@@ -0,0 +1,7 @@
from __future__ import unicode_literals
import frappe
def get_context(context):
# do your magic here
pass

View File

@@ -0,0 +1,3 @@
frappe.ready(function() {
// bind events here
})

View File

@@ -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
}
]
}

View File

@@ -0,0 +1,7 @@
from __future__ import unicode_literals
import frappe
def get_context(context):
# do your magic here
pass

View File

@@ -47,6 +47,7 @@ website_context = {
{"label": "Services", "url": "/service-providers", "right": 1}, {"label": "Services", "url": "/service-providers", "right": 1},
{"label": "Jobs", "url": "/erpnext-jobs", "right": 1}, {"label": "Jobs", "url": "/erpnext-jobs", "right": 1},
{"label": "Chapters", "url": "/chapters", "right": 1}, {"label": "Chapters", "url": "/chapters", "right": 1},
{"label": "Bounties", "url": "/bounties", "right": 1},
{"label": '<span class="indicator blue">Conference</span>', "url": "/conf/2017", "right": 1}, {"label": '<span class="indicator blue">Conference</span>', "url": "/conf/2017", "right": 1},
{"label": "About", "url": "/about", "right": 1}, {"label": "About", "url": "/about", "right": 1},
], ],