From 448854a7d947da1343f894cf389c6e847cc7592f Mon Sep 17 00:00:00 2001 From: Owocki Date: Wed, 25 Apr 2018 15:12:19 -0600 Subject: [PATCH 01/13] moves action url links server side --- app/assets/v2/js/pages/bounty_details.js | 10 +++++----- app/dashboard/models.py | 17 +++++++++++++++++ app/dashboard/router.py | 2 +- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/app/assets/v2/js/pages/bounty_details.js b/app/assets/v2/js/pages/bounty_details.js index 47ac055141b..d00e9155a61 100644 --- a/app/assets/v2/js/pages/bounty_details.js +++ b/app/assets/v2/js/pages/bounty_details.js @@ -491,7 +491,7 @@ var do_actions = function(result) { var enabled = submit_work_enabled; var _entry = { enabled: enabled, - href: '/funding/fulfill?source=' + result['github_url'], + href: result['action_urls']['fulfill'], text: gettext('Submit Work'), parent: 'right_actions', title: gettext('Submit work for the funder to review'), @@ -506,7 +506,7 @@ var do_actions = function(result) { var enabled = start_stop_work_enabled; var interest_entry = { enabled: enabled, - href: is_interested ? '/uninterested' : '/interested', + href: is_interested ? result['action_urls']['stop_work'] : result['action_urls']['start_work'], text: is_interested ? gettext('Stop Work') : gettext('Start Work'), parent: 'right_actions', title: is_interested ? gettext('Notify the funder that you will not be working on this project') : gettext('Notify the funder that you would like to take on this project'), @@ -521,7 +521,7 @@ var do_actions = function(result) { var enabled = kill_bounty_enabled; var _entry = { enabled: enabled, - href: '/funding/kill?source=' + result['github_url'], + href: result['action_urls']['kill'], text: gettext('Cancel Bounty'), parent: 'right_actions', title: gettext('Cancel bounty and reclaim funds for this issue') @@ -536,7 +536,7 @@ var do_actions = function(result) { var enabled = show_accept_submission; var _entry = { enabled: enabled, - href: '/funding/process?source=' + result['github_url'], + href: result['action_urls']['process'], text: gettext('Accept Submission'), title: gettext('This will payout the bounty to the submitter.'), parent: 'right_actions', @@ -550,7 +550,7 @@ var do_actions = function(result) { var enabled = increase_bounty_enabled; var _entry = { enabled: enabled, - href: '/funding/increase?source=' + result['github_url'], + href: result['action_urls']['increase'], text: gettext('Add Contribution'), parent: 'right_actions', title: gettext('Increase the funding for this issue'), diff --git a/app/dashboard/models.py b/app/dashboard/models.py index 479f4633ee1..5063e766108 100644 --- a/app/dashboard/models.py +++ b/app/dashboard/models.py @@ -600,6 +600,23 @@ def fetch_issue_comments(self, save=True): self.save() return comments + @property + def action_urls(self): + """ + + Returns: + dict - a dictionary of action URLS for this bounty + + """ + return { + 'fulfill': f"/funding/fulfill?source={self.github_url}", + 'increase': f"/funding/increase?source={self.github_url}", + 'process': f"/funding/process?source={self.github_url}", + 'cancel': f"/funding/kill?source={self.github_url}", + 'start_work': f"/interested", + 'stop_work': f"/uninterested", + } + class BountyFulfillmentQuerySet(models.QuerySet): """Handle the manager queryset for BountyFulfillments.""" diff --git a/app/dashboard/router.py b/app/dashboard/router.py index c5252de8aa1..aa02202857e 100644 --- a/app/dashboard/router.py +++ b/app/dashboard/router.py @@ -75,7 +75,7 @@ class Meta: 'standard_bounties_id', 'web3_type', 'can_submit_after_expiration_date', 'github_issue_number', 'github_org_name', 'github_repo_name', 'idx_status', 'token_value_time_peg', 'fulfillment_accepted_on', 'fulfillment_submitted_on', - 'fulfillment_started_on', 'canceled_on', + 'fulfillment_started_on', 'canceled_on', 'action_urls', ) def create(self, validated_data): From 8937bc707a5ee76c7af492e59f20af44233fc21e Mon Sep 17 00:00:00 2001 From: Owocki Date: Wed, 25 Apr 2018 15:13:12 -0600 Subject: [PATCH 02/13] removes legacy urls --- app/legacy/urls.py | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/app/legacy/urls.py b/app/legacy/urls.py index 36a6326183b..abbd969d041 100644 --- a/app/legacy/urls.py +++ b/app/legacy/urls.py @@ -20,24 +20,9 @@ from django.urls import re_path -from dashboard.views import bounty_details, fulfill_bounty, kill_bounty, process_bounty, sync_web3 +from dashboard.views import bounty_details app_name = 'legacy' urlpatterns = [ - # Path changed during migration to standard bounties. - re_path(r'^bounty/claim/?', fulfill_bounty, name='legacy_claim_bounty'), - re_path(r'^funding/claim/?', fulfill_bounty, name='legacy_claim_funding'), - re_path(r'^funding/fulfill/?', fulfill_bounty, name='legacy_claim_funding1'), - re_path(r'^bounty/fulfill/?', fulfill_bounty, name='legacy_claim_funding2'), - re_path(r'^funding/clawback/?', kill_bounty, name='legacy_clawback_expired_bounty'), - - # Endpoints that need to support old logic. - # Bounties - re_path(r'^bounty/process/?', process_bounty, name='legacy_process_bounty'), - re_path(r'^funding/process/?', process_bounty, name='legacy_process_funding'), - re_path(r'^bounty/details/?', bounty_details, name='legacy_bounty_details'), - re_path(r'^funding/details/?', bounty_details, name='legacy_funding_details'), re_path(r'^issue/(?P.*)/(?P.*)/(?P.*)', bounty_details, name='legacy_issue_details_new2'), - # sync methods - re_path(r'^sync/web3', sync_web3, name='legacy_sync_web3'), ] From 3fe03720a407631535e5d6f23abdf429c5d0f932 Mon Sep 17 00:00:00 2001 From: Owocki Date: Wed, 25 Apr 2018 15:52:34 -0600 Subject: [PATCH 03/13] end to end integration --- app/app/urls.py | 31 ++++--- app/assets/v2/js/pages/bounty_details.js | 6 +- app/assets/v2/js/pages/fulfill_bounty.js | 3 +- app/assets/v2/js/pages/increase_bounty.js | 2 + app/assets/v2/js/pages/kill_bounty.js | 3 +- app/assets/v2/js/pages/process_bounty.js | 4 +- app/assets/v2/js/shared.js | 12 +++ app/dashboard/models.py | 10 +-- app/dashboard/templates/fulfill_bounty.html | 3 +- app/dashboard/templates/increase_bounty.html | 11 +-- app/dashboard/templates/kill_bounty.html | 3 +- app/dashboard/templates/process_bounty.html | 3 +- .../shared/bounty_actions_hidden_vars.html | 19 +++++ app/dashboard/templates/submit_bounty.html | 3 +- app/dashboard/views.py | 84 +++++++++++-------- docs/API.md | 1 + 16 files changed, 128 insertions(+), 70 deletions(-) create mode 100644 app/dashboard/templates/shared/bounty_actions_hidden_vars.html diff --git a/app/app/urls.py b/app/app/urls.py index 4129e71fd88..3707570d0bd 100644 --- a/app/app/urls.py +++ b/app/app/urls.py @@ -66,28 +66,37 @@ url(r'^dashboard/?', dashboard.views.dashboard, name='dashboard'), url(r'^explorer/?', dashboard.views.dashboard, name='explorer'), + + # action URLs url(r'^bounty/new/?', dashboard.views.new_bounty, name='new_bounty'), url(r'^funding/new/?', dashboard.views.new_bounty, name='new_funding'), url(r'^new/?', dashboard.views.new_bounty, name='new_funding_short'), + url(r'^issue/fulfill/(?P.*)?', dashboard.views.fulfill_bounty, name='fulfill_bounty'), + url(r'^issue/accept/(?P.*)?', dashboard.views.accept_bounty, name='process_funding'), + url(r'^issue/increase/(?P.*)?', dashboard.views.increase_bounty, name='increase_bounty'), + url(r'^issue/cancel/(?P.*)?', dashboard.views.cancel_bounty, name='kill_bounty'), + + # Interests + path('actions/bounty//interest/new/', dashboard.views.new_interest, name='express-interest'), + path('actions/bounty//interest/remove/', dashboard.views.remove_interest, name='remove-interest'), + path('actions/bounty//interest//uninterested/', dashboard.views.uninterested, name='uninterested'), - url(r'^bounty/fulfill/?', dashboard.views.fulfill_bounty, name='fulfill_bounty'), - url(r'^funding/fulfill/?', dashboard.views.fulfill_bounty, name='fulfill_funding'), - url(r'^bounty/process/?', dashboard.views.process_bounty, name='process_bounty'), - url(r'^funding/process/?', dashboard.views.process_bounty, name='process_funding'), + # View Bounty url(r'^bounty/details/(?P.*)/(?P.*)/(?P.*)', dashboard.views.bounty_details, name='bounty_details_new'), url(r'^funding/details/(?P.*)/(?P.*)/(?P.*)', dashboard.views.bounty_details, name='funding_details_new'), url(r'^issue/(?P.*)/(?P.*)/(?P.*)/(?P.*)', dashboard.views.bounty_details, name='issue_details_new3'), url(r'^issue/(?P.*)/(?P.*)/(?P.*)', dashboard.views.bounty_details, name='issue_details_new2'), url(r'^bounty/details/?', dashboard.views.bounty_details, name='bounty_details'), url(r'^funding/details/?', dashboard.views.bounty_details, name='funding_details'), - url(r'^legacy/funding/details/?', dashboard.views.bounty_details, name='legacy_funding_details'), - url(r'^funding/increase/?', dashboard.views.increase_bounty, name='increase_bounty'), - url(r'^funding/kill/?', dashboard.views.kill_bounty, name='kill_bounty'), + + # Tips url(r'^tip/receive/?', dashboard.views.receive_tip, name='receive_tip'), url(r'^tip/send/2/?', dashboard.views.send_tip_2, name='send_tip_2'), url(r'^tip/send/?', dashboard.views.send_tip, name='send_tip'), url(r'^send/?', dashboard.views.send_tip, name='tip'), url(r'^tip/?', dashboard.views.send_tip, name='tip'), + + # Legal url(r'^legal/?', dashboard.views.terms, name='legal'), url(r'^terms/?', dashboard.views.terms, name='_terms'), url(r'^legal/terms/?', dashboard.views.terms, name='terms'), @@ -95,6 +104,8 @@ url(r'^legal/cookie/?', dashboard.views.cookie, name='cookie'), url(r'^legal/prirp/?', dashboard.views.prirp, name='prirp'), url(r'^legal/apitos/?', dashboard.views.apitos, name='apitos'), + + # Alpha functionality url(r'^profile/(.*)?', dashboard.views.profile, name='profile'), url(r'^toolbox/?', dashboard.views.toolbox, name='toolbox'), path('actions/tool//voteUp', dashboard.views.vote_tool_up, name='vote_tool_up'), @@ -113,6 +124,7 @@ url(r'^sync/get_amount?', dashboard.helpers.amount, name='helpers_amount'), url(r'^sync/get_issue_details?', dashboard.helpers.issue_details, name='helpers_issue_details'), url(r'^sync/search_save?', dashboard.views.save_search, name='save_search'), + # brochureware views url(r'^about/?', retail.views.about, name='about'), url(r'^mission/?', retail.views.mission, name='mission'), @@ -128,6 +140,7 @@ url(r'^extension/chrome?', retail.views.browser_extension_chrome, name='browser_extension_chrome'), url(r'^extension/firefox?', retail.views.browser_extension_firefox, name='browser_extension_firefox'), url(r'^extension/?', retail.views.browser_extension_chrome, name='browser_extension'), + # basic redirect retail views url(r'^press/?', retail.views.presskit, name='press'), url(r'^presskit/?', retail.views.presskit, name='presskit'), @@ -200,10 +213,6 @@ # for robots url(r'^robots.txt/?', retail.views.robotstxt, name='robotstxt'), url(r'^sitemap\.xml$', sitemap, {'sitemaps': sitemaps}, name='django.contrib.sitemaps.views.sitemap'), - # Interests - path('actions/bounty//interest/new/', dashboard.views.new_interest, name='express-interest'), - path('actions/bounty//interest/remove/', dashboard.views.remove_interest, name='remove-interest'), - path('actions/bounty//interest//uninterested/', dashboard.views.uninterested, name='uninterested'), # Legacy Support path('legacy/', include('legacy.urls', namespace='legacy')), re_path(r'^logout/$', auth_views.logout, name='logout'), diff --git a/app/assets/v2/js/pages/bounty_details.js b/app/assets/v2/js/pages/bounty_details.js index d00e9155a61..833fd9040dd 100644 --- a/app/assets/v2/js/pages/bounty_details.js +++ b/app/assets/v2/js/pages/bounty_details.js @@ -506,7 +506,7 @@ var do_actions = function(result) { var enabled = start_stop_work_enabled; var interest_entry = { enabled: enabled, - href: is_interested ? result['action_urls']['stop_work'] : result['action_urls']['start_work'], + href: is_interested ? '/uninterested' : '/interested', text: is_interested ? gettext('Stop Work') : gettext('Start Work'), parent: 'right_actions', title: is_interested ? gettext('Notify the funder that you will not be working on this project') : gettext('Notify the funder that you would like to take on this project'), @@ -521,7 +521,7 @@ var do_actions = function(result) { var enabled = kill_bounty_enabled; var _entry = { enabled: enabled, - href: result['action_urls']['kill'], + href: result['action_urls']['cancel'], text: gettext('Cancel Bounty'), parent: 'right_actions', title: gettext('Cancel bounty and reclaim funds for this issue') @@ -536,7 +536,7 @@ var do_actions = function(result) { var enabled = show_accept_submission; var _entry = { enabled: enabled, - href: result['action_urls']['process'], + href: result['action_urls']['accept'], text: gettext('Accept Submission'), title: gettext('This will payout the bounty to the submitter.'), parent: 'right_actions', diff --git a/app/assets/v2/js/pages/fulfill_bounty.js b/app/assets/v2/js/pages/fulfill_bounty.js index 1a82894f307..7894c259e98 100644 --- a/app/assets/v2/js/pages/fulfill_bounty.js +++ b/app/assets/v2/js/pages/fulfill_bounty.js @@ -2,6 +2,7 @@ window.onload = function() { // a little time for web3 injection setTimeout(function() { + waitforWeb3(actions_page_warn_if_not_on_same_network); var account = web3.eth.accounts[0]; if (typeof localStorage['githubUsername'] != 'undefined') { @@ -137,7 +138,7 @@ window.onload = function() { }; // Get bountyId from the database - var uri = '/api/v0.1/bounties/?github_url=' + issueURL + '&network=' + document.web3network; + var uri = '/api/v0.1/bounties/?github_url=' + issueURL + '&network=' + $('input[name=network]').val() + '&standard_bounties_id=' + $('input[name=standard_bounties_id]').val(); $.get(uri, function(results, status) { results = sanitizeAPIResults(results); diff --git a/app/assets/v2/js/pages/increase_bounty.js b/app/assets/v2/js/pages/increase_bounty.js index 82625e57ffe..6bcf62d8a48 100644 --- a/app/assets/v2/js/pages/increase_bounty.js +++ b/app/assets/v2/js/pages/increase_bounty.js @@ -2,6 +2,8 @@ load_tokens(); // Wait until page is loaded, then run the function $(document).ready(function() { + waitforWeb3(actions_page_warn_if_not_on_same_network); + $('input[name=amount]').keyup(setUsdAmount); $('input[name=amount]').blur(setUsdAmount); $('select[name=deonomination]').change(setUsdAmount); diff --git a/app/assets/v2/js/pages/kill_bounty.js b/app/assets/v2/js/pages/kill_bounty.js index 052e628c6de..4a763b0a2cb 100644 --- a/app/assets/v2/js/pages/kill_bounty.js +++ b/app/assets/v2/js/pages/kill_bounty.js @@ -2,6 +2,7 @@ window.onload = function() { // a little time for web3 injection setTimeout(function() { + waitforWeb3(actions_page_warn_if_not_on_same_network); var account = web3.eth.accounts[0]; if ( @@ -116,7 +117,7 @@ window.onload = function() { }; // Get bountyId from the database - var uri = '/api/v0.1/bounties/?github_url=' + issueURL + '&network=' + document.web3network; + var uri = '/api/v0.1/bounties/?github_url=' + issueURL + '&network=' + $('input[name=network]').val() + '&standard_bounties_id=' + $('input[name=standard_bounties_id]').val(); $.get(uri, apiCallback); } diff --git a/app/assets/v2/js/pages/process_bounty.js b/app/assets/v2/js/pages/process_bounty.js index 65d4dfc47d6..7fcb9674cbe 100644 --- a/app/assets/v2/js/pages/process_bounty.js +++ b/app/assets/v2/js/pages/process_bounty.js @@ -2,6 +2,7 @@ window.onload = function() { // a little time for web3 injection setTimeout(function() { + waitforWeb3(actions_page_warn_if_not_on_same_network); var account = web3.eth.accounts[0]; if (getParam('source')) { @@ -167,9 +168,8 @@ window.onload = function() { }; // Get bountyId from the database - waitforWeb3(function() { - var uri = '/api/v0.1/bounties/?github_url=' + issueURL + '&network=' + document.web3network; + var uri = '/api/v0.1/bounties/?github_url=' + issueURL + '&network=' + $('input[name=network]').val() + '&standard_bounties_id=' + $('input[name=standard_bounties_id]').val(); $.get(uri, apiCallback); }); diff --git a/app/assets/v2/js/shared.js b/app/assets/v2/js/shared.js index 0226aae0f2e..d130561fa31 100644 --- a/app/assets/v2/js/shared.js +++ b/app/assets/v2/js/shared.js @@ -706,6 +706,18 @@ var listen_for_web3_changes = function() { } }; +var actions_page_warn_if_not_on_same_network = function(){ + var user_network = document.web3network; + if (typeof user_network == 'undefined'){ + user_network = 'no network' + } + var bounty_network = $('input[name=network]').val(); + if(bounty_network != user_network){ + var msg = "Warning: You are on "+user_network+" and this bounty is on the "+bounty_network+" network. Please change your network to the "+bounty_network+" network." + _alert({message: gettext(msg)}, 'error'); + } +} + $(document).ready(function() { sidebar_redirect_triggers(); attach_change_element_type(); diff --git a/app/dashboard/models.py b/app/dashboard/models.py index 5063e766108..9aae7ef1d8b 100644 --- a/app/dashboard/models.py +++ b/app/dashboard/models.py @@ -609,12 +609,10 @@ def action_urls(self): """ return { - 'fulfill': f"/funding/fulfill?source={self.github_url}", - 'increase': f"/funding/increase?source={self.github_url}", - 'process': f"/funding/process?source={self.github_url}", - 'cancel': f"/funding/kill?source={self.github_url}", - 'start_work': f"/interested", - 'stop_work': f"/uninterested", + 'fulfill': f"/issue/fulfill/{self.pk}", + 'increase': f"/issue/increase/{self.pk}", + 'accept': f"/issue/accept/{self.pk}", + 'cancel': f"/issue/cancel/{self.pk}", } diff --git a/app/dashboard/templates/fulfill_bounty.html b/app/dashboard/templates/fulfill_bounty.html index 9468feeac2c..56b39aa9c60 100644 --- a/app/dashboard/templates/fulfill_bounty.html +++ b/app/dashboard/templates/fulfill_bounty.html @@ -45,7 +45,7 @@

{% trans "Submit Work" %}

- +
{% include 'shared/github_username.html' %} {% include 'shared/notification_email.html' %} @@ -57,6 +57,7 @@

{% trans "Submit Work" %}

+ {% include 'shared/bounty_actions_hidden_vars.html' %} {% include 'shared/wallet_estimate.html' %}