Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow funder to turn off auto approvals at bounty creation #1945

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions app/assets/v2/js/pages/bounty_details.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ var rows = [
'submitted_owners_username',
'fulfilled_owners_username',
'fulfillment_accepted_on',
'additional_funding_summary'
'additional_funding_summary',
'admin_override_suspend_auto_approval'
];

var heads = {
Expand Down Expand Up @@ -178,6 +179,14 @@ var callbacks = {
'project_type': function(key, val, result) {
return [ 'project_type', ucwords(result.project_type) ];
},
'admin_override_suspend_auto_approval': function(key, val, result) {
if (result['permission_type'] === 'approval') {
$('#auto_approve_workers_wrapper').show();
} else {
$('#auto_approve_workers_wrapper').hide();
}
return [ 'admin_override_suspend_auto_approval', val ? 'off' : 'on' ];
},
'issue_keywords': function(key, val, result) {
if (!result.keywords || result.keywords.length == 0)
return [ 'issue_keywords', null ];
Expand Down Expand Up @@ -814,7 +823,8 @@ var do_actions = function(result) {
let show_payout = !is_status_expired && !is_status_done && isBountyOwner(result);
let show_extend_deadline = isBountyOwner(result) && !is_status_expired && !is_status_done;
let show_invoice = isBountyOwner(result);
const show_suspend_auto_approval = currentProfile.isStaff && result['permission_type'] == 'approval';

const show_suspend_auto_approval = currentProfile.isStaff && result['permission_type'] == 'approval' && !result['admin_override_suspend_auto_approval'];
const show_admin_methods = currentProfile.isStaff;
const show_moderator_methods = currentProfile.isModerator;
const show_change_bounty = is_still_on_happy_path && (isBountyOwner(result) || show_admin_methods);
Expand Down
12 changes: 11 additions & 1 deletion app/assets/v2/js/pages/new_bounty.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ $(document).ready(function() {
waitforWeb3(function() {
promptForAuth();
});
$('select[name=permission_type]').on('change', function() {
var val = $('select[name=permission_type] option:selected').val();

if (val === 'approval') {
$('#auto_approve_workers_container').show();
} else {
$('#auto_approve_workers_container').hide();
}
});

// revision action buttons
$('#subtractAction').on('click', function() {
Expand Down Expand Up @@ -251,7 +260,8 @@ $(document).ready(function() {
},
schemes: {
project_type: data.project_type,
permission_type: data.permission_type
permission_type: data.permission_type,
auto_approve_workers: !!data.auto_approve_workers
},
hiring: {
hiringRightNow: data.hiringRightNow,
Expand Down
6 changes: 4 additions & 2 deletions app/dashboard/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ def create_new_bounty(old_bounties, bounty_payload, bounty_details, bounty_id):
'value_in_token': bounty_details.get('fulfillmentAmount', Decimal(1.0))
}
if not latest_old_bounty:
schemes = bounty_payload.get('schemes', {})
bounty_kwargs.update({
# info to xfr over from latest_old_bounty as override fields (this is because sometimes
# ppl dont login when they first submit issue and it needs to be overridden)
Expand All @@ -417,13 +418,14 @@ def create_new_bounty(old_bounties, bounty_payload, bounty_details, bounty_id):
'funding_organisation': metadata.get('fundingOrganisation', ''),
'project_length': metadata.get('projectLength', ''),
'experience_level': metadata.get('experienceLevel', ''),
'project_type': bounty_payload.get('schemes', {}).get('project_type', 'traditional'),
'permission_type': bounty_payload.get('schemes', {}).get('permission_type', 'permissionless'),
'project_type': schemes.get('project_type', 'traditional'),
'permission_type': schemes.get('permission_type', 'permissionless'),
'attached_job_description': bounty_payload.get('hiring', {}).get('jobDescription', None),
'bounty_owner_github_username': bounty_issuer.get('githubUsername', ''),
'bounty_owner_address': bounty_issuer.get('address', ''),
'bounty_owner_email': bounty_issuer.get('email', ''),
'bounty_owner_name': bounty_issuer.get('name', ''),
'admin_override_suspend_auto_approval': not schemes.get('auto_approve_workers', True),
})
else:
latest_old_bounty_dict = latest_old_bounty.to_standard_dict(
Expand Down
2 changes: 1 addition & 1 deletion app/dashboard/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class Meta:
'github_org_name', 'github_repo_name', 'idx_status', 'token_value_time_peg', 'fulfillment_accepted_on',
'fulfillment_submitted_on', 'fulfillment_started_on', 'canceled_on', 'action_urls', 'project_type',
'permission_type', 'attached_job_description', 'needs_review', 'github_issue_state', 'is_issue_closed',
'additional_funding_summary', 'funding_organisation', 'paid',
'additional_funding_summary', 'funding_organisation', 'paid', 'admin_override_suspend_auto_approval',
)

def create(self, validated_data):
Expand Down
7 changes: 6 additions & 1 deletion app/dashboard/templates/bounty/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,14 @@ <h4 id="title" class="font-title"></h4>

<div>
<span class="bounty-info-heading" title='{% include "shared/permissions_type_tooltip.html" %}'>{% trans "Permissions" %}</span>
<span class="bounty-info-text" id="permission_type" title='{% include "shared/permissions_type_tooltip.html" %}'>></span>
<span class="bounty-info-text" id="permission_type" title='{% include "shared/permissions_type_tooltip.html" %}'></span>
<i class="fas fa-info-circle" title='{% include "shared/permissions_type_tooltip.html" %}'></i>
</div>

<div id="auto_approve_workers_wrapper">
<span class="bounty-info-heading">{% trans "Workers Auto Approve" %} </span>
<span class="bounty-info-text" id="admin_override_suspend_auto_approval"></span>
</div>
</div>
</div>
</div>
Expand Down
7 changes: 7 additions & 0 deletions app/dashboard/templates/shared/issue_details.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ <h5 class="font-subheader">{% trans "Details" %}</h5>
<option value="approval" selected>{% trans "Approval Required - I will approve bounty hunters." %}</option>
</select>
</div>
<div class="w-100 mt-2" id="auto_approve_workers_container">
<div class="form__checkbox">
<input name="admin_override_suspend_auto_approval" id="admin_override_suspend_auto_approval" type="checkbox" value="1" checked />
<label class="form__label" for="admin_override_suspend_auto_approval" style="display: flex;">{% trans "Worker will be
mbeacom marked this conversation as resolved.
Show resolved Hide resolved
auto-approved after 72 hours." %}</label>
</div>
</div>
<div>
<label class="form__label">{% trans "Issue Details" %}</label>
</div>
Expand Down