diff --git a/app/assets/v2/js/pages/bounty_details.js b/app/assets/v2/js/pages/bounty_details.js index 95f76333cff..135a7cc4337 100644 --- a/app/assets/v2/js/pages/bounty_details.js +++ b/app/assets/v2/js/pages/bounty_details.js @@ -863,6 +863,51 @@ var show_extend_deadline_modal = function() { }); }; +const appendGithubSyncButton = function(result) { + if (isBountyOwner(result) || currentProfile.isStaff) { + const title = gettext('Sync Issue'); + + $('#github_actions').append(''); + + $('#github_actions [sync-github-issue]').on('click', function(e) { + const bountyId = result.pk; + + e.preventDefault(); + + $.get( + '/sync/get_issue_details?url=' + encodeURIComponent(result['github_url']) + '&token=' + currentProfile.githubToken + ).then(function(result) { + const payload = JSON.stringify({ + issue_description: result.description + }); + + return $.post('/bounty/change/' + bountyId, payload).then( + function(result) { + result = sanitizeAPIResults(result); + _alert({ message: result.msg }, 'success'); + + if (result.url) { + setTimeout(function() { + document.location.href = result.url; + }, 1000); + } + } + ).fail( + function(result) { + const alertMsg = result && result.responseJSON ? result.responseJSON.error : gettext('Failed to sync issue. Please reload the page and try again.'); + + _alert({ message: alertMsg }, 'error'); + } + ); + }).fail(function(result) { + const alertMsg = result && result.responseJSON ? result.responseJSON.error : gettext('Failed to sync issue. Please reload the page and try again.'); + + _alert({ message: alertMsg }, 'error'); + }); + }); + } +}; + var build_detail_page = function(result) { // setup @@ -937,6 +982,7 @@ var build_detail_page = function(result) { }); $('#bounty_details #issue_description code').parent().addClass('code-snippet'); + appendGithubSyncButton(result); }; const is_current_user_interested = function(result) { @@ -1032,7 +1078,7 @@ var do_actions = function(result) { enabled: enabled, href: result['action_urls']['fulfill'], text: gettext('Submit Work'), - parent: 'right_actions', + parent: 'bounty_actions', title: gettext('Submit work for the funder to review'), work_started: is_interested, id: 'submit' @@ -1048,7 +1094,7 @@ var do_actions = function(result) { enabled: enabled, href: '#', text: gettext('Send Payment Reminder'), - parent: 'right_actions', + parent: 'bounty_actions', title: gettext('Send Payment Reminder'), id: 'notifyFunder', clickhandler: show_modal_handler(url), @@ -1071,7 +1117,7 @@ var do_actions = function(result) { enabled: enabled, href: is_interested ? '/uninterested' : '/interested', text: text, - parent: 'right_actions', + parent: 'bounty_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'), color: is_interested ? '' : '', id: 'interest' @@ -1086,7 +1132,7 @@ var do_actions = function(result) { enabled: enabled, href: result['action_urls']['cancel'], text: gettext('Cancel Bounty'), - parent: 'right_actions', + parent: 'bounty_actions', title: gettext('Cancel bounty and reclaim funds for this issue'), buttonclass: 'button--warning' }; @@ -1101,7 +1147,7 @@ var do_actions = function(result) { href: result['action_urls']['payout'], text: gettext('Payout Bounty'), title: gettext('Payout the bounty to one or more submitters.'), - parent: 'right_actions' + parent: 'bounty_actions' }; actions.push(_entry); @@ -1114,7 +1160,7 @@ var do_actions = function(result) { enabled: enabled, href: result['action_urls']['contribute'], text: gettext('Contribute'), - parent: 'right_actions', + parent: 'bounty_actions', title: gettext('Help by funding or promoting this issue') }; @@ -1127,7 +1173,7 @@ var do_actions = function(result) { enabled: enabled, href: '/extend-deadlines', text: gettext('Extend Expiration'), - parent: 'right_actions', + parent: 'bounty_actions', title: gettext('Extend deadline of an issue') }; @@ -1139,7 +1185,7 @@ var do_actions = function(result) { enabled: true, href: result['action_urls']['invoice'], text: gettext('Show Invoice'), - parent: 'right_actions', + parent: 'bounty_actions', title: gettext('View an Invoice for this Issue') }; @@ -1152,16 +1198,9 @@ var do_actions = function(result) { enabled: true, href: '/bounty/change/' + result['pk'], text: gettext('Edit Issue Details'), - parent: 'right_actions', + parent: 'bounty_actions', title: gettext('Update your Bounty Settings to get the right Crowd') - }// , - // { - // enabled: true, - // href: '/issue/refund_request?pk=' + result['pk'], - // text: gettext('Request Fee Refund'), - // parent: 'right_actions', - // title: gettext('Raise a request if you believe you need your fee refunded') - // } + } ]; actions.push(..._entry); @@ -1178,9 +1217,9 @@ var do_actions = function(result) { enabled: true, href: github_url, text: (result['repo_type'] === 'private' ? ' ' + - gettext('Private Repo') : gettext('View On Github')) + - (result['is_issue_closed'] ? gettext(' (Issue is closed)') : ''), - parent: 'right_actions', + gettext('Private Repo') : gettext('View On Github')) + + (result['is_issue_closed'] ? gettext(' (Issue is closed)') : ''), + parent: 'github_actions', title: gettext('View issue details and comments on Github'), comments: result['github_comments'], color: 'white' @@ -1196,7 +1235,7 @@ var do_actions = function(result) { enabled: true, href: job_url, text: gettext('View Attached Job Description'), - parent: 'right_actions', + parent: 'bounty_actions', title: gettext('This bounty funder is hiring for a full time, part time, or contract role and has attached that to this bounty.'), color: 'white' }; diff --git a/app/dashboard/templates/bounty/details.html b/app/dashboard/templates/bounty/details.html index cfb627832e0..4dd1139a209 100644 --- a/app/dashboard/templates/bounty/details.html +++ b/app/dashboard/templates/bounty/details.html @@ -142,6 +142,8 @@
+ + diff --git a/app/dashboard/views.py b/app/dashboard/views.py index e0cb01ea1b8..b04c68f8635 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -2598,7 +2598,7 @@ def change_bounty(request, bounty_id): else: raise Http404 - keys = ['experience_level', 'project_length', 'bounty_type', 'featuring_date', 'bounty_categories', + keys = ['experience_level', 'project_length', 'bounty_type', 'featuring_date', 'bounty_categories', 'issue_description', 'permission_type', 'project_type', 'reserved_for_user_handle', 'is_featured', 'admin_override_suspend_auto_approval'] if request.body: @@ -2625,18 +2625,19 @@ def change_bounty(request, bounty_id): new_reservation = False for key in keys: value = params.get(key, 0) - if key == 'featuring_date': - value = timezone.make_aware( - timezone.datetime.fromtimestamp(int(value)), - timezone=UTC) - if key == 'bounty_categories': - value = value.split(',') - old_value = getattr(bounty, key) - if value != old_value: - setattr(bounty, key, value) - bounty_changed = True - if key == 'reserved_for_user_handle' and value: - new_reservation = True + if value != 0: + if key == 'featuring_date': + value = timezone.make_aware( + timezone.datetime.fromtimestamp(int(value)), + timezone=UTC) + if key == 'bounty_categories': + value = value.split(',') + old_value = getattr(bounty, key) + if value != old_value: + setattr(bounty, key, value) + bounty_changed = True + if key == 'reserved_for_user_handle' and value: + new_reservation = True if not bounty_changed: return JsonResponse({