diff --git a/app/assets/v2/js/pages/bounty_details.js b/app/assets/v2/js/pages/bounty_details.js index 737f65b8dbb..b65f48db804 100644 --- a/app/assets/v2/js/pages/bounty_details.js +++ b/app/assets/v2/js/pages/bounty_details.js @@ -89,7 +89,8 @@ var rows = [ 'submitted_owners_username', 'fulfilled_owners_username', 'fulfillment_accepted_on', - 'additional_funding_summary' + 'additional_funding_summary', + 'auto_approve_workers' ]; var heads = { @@ -168,6 +169,14 @@ var callbacks = { 'project_type': function(key, val, result) { return [ 'project_type', ucwords(result.project_type) ]; }, + 'auto_approve_workers': function(key, val, result) { + if (result['permission_type'] == 'approval') { + $('#auto_approve_workers_wrapper').show(); + } else { + $('#auto_approve_workers_wrapper').hide(); + } + return [ 'auto_approve_workers', val ? 'on' : 'off' ]; + }, 'issue_keywords': function(key, val, result) { if (!result.keywords || result.keywords.length == 0) return [ 'issue_keywords', null ]; @@ -674,7 +683,7 @@ var do_actions = function(result) { const increase_bounty_enabled = isBountyOwner(result); let show_accept_submission = isBountyOwner(result) && !is_status_expired && !is_status_done; let show_advanced_payout = isBountyOwner(result) && !is_status_expired && !is_status_done; - const show_suspend_auto_approval = document.isStaff && result['permission_type'] == 'approval'; + const show_suspend_auto_approval = document.isStaff && result['permission_type'] == 'approval' && result['auto_approve_workers']; const show_admin_methods = document.isStaff; const show_moderator_methods = document.isModerator; diff --git a/app/assets/v2/js/pages/new_bounty.js b/app/assets/v2/js/pages/new_bounty.js index 993262cc5c8..db28de01afa 100644 --- a/app/assets/v2/js/pages/new_bounty.js +++ b/app/assets/v2/js/pages/new_bounty.js @@ -108,6 +108,15 @@ $(document).ready(function() { waitforWeb3(function() { promptForAuth(); }); + $('select[name=permission_type]').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() { @@ -253,7 +262,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 || '0' }, hiring: { hiringRightNow: data.hiringRightNow, diff --git a/app/dashboard/helpers.py b/app/dashboard/helpers.py index 755e0457a4c..a866cb507c9 100644 --- a/app/dashboard/helpers.py +++ b/app/dashboard/helpers.py @@ -374,6 +374,7 @@ def create_new_bounty(old_bounties, bounty_payload, bounty_details, bounty_id): old_bounty.save() latest_old_bounty = old_bounty try: + aaw = bounty_payload.get('schemes', {}).get('auto_approve_workers', 1) new_bounty = Bounty.objects.create( is_open=True if (bounty_details.get('bountyStage') == 1 and not accepted) else False, raw_data=bounty_details, @@ -407,6 +408,7 @@ def create_new_bounty(old_bounties, bounty_payload, bounty_details, bounty_id): experience_level=metadata.get('experienceLevel', '') if not latest_old_bounty else latest_old_bounty.experience_level, project_type=bounty_payload.get('schemes', {}).get('project_type', 'traditional') if not latest_old_bounty else latest_old_bounty.project_type, permission_type=bounty_payload.get('schemes', {}).get('permission_type', 'permissionless') if not latest_old_bounty else latest_old_bounty.permission_type, + auto_approve_workers=aaw if not latest_old_bounty else latest_old_bounty.auto_approve_workers, attached_job_description=bounty_payload.get('hiring', {}).get('jobDescription', None) if not latest_old_bounty else latest_old_bounty.attached_job_description, bounty_owner_github_username=bounty_issuer.get('githubUsername', '') if not latest_old_bounty else latest_old_bounty.bounty_owner_github_username, bounty_owner_address=bounty_issuer.get('address', '') if not latest_old_bounty else latest_old_bounty.bounty_owner_address, diff --git a/app/dashboard/migrations/0105_bounty_auto_approve_workers.py b/app/dashboard/migrations/0105_bounty_auto_approve_workers.py new file mode 100644 index 00000000000..c63e68674c0 --- /dev/null +++ b/app/dashboard/migrations/0105_bounty_auto_approve_workers.py @@ -0,0 +1,18 @@ +# Generated by Django 2.0.7 on 2018-08-05 17:05 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('dashboard', '0104_auto_20180802_1804'), + ] + + operations = [ + migrations.AddField( + model_name='bounty', + name='auto_approve_workers', + field=models.BooleanField(default=True), + ), + ] diff --git a/app/dashboard/models.py b/app/dashboard/models.py index 7a5cad6cb0e..2f96b188fef 100644 --- a/app/dashboard/models.py +++ b/app/dashboard/models.py @@ -254,6 +254,7 @@ class Bounty(SuperModel): project_type = models.CharField(max_length=50, choices=PROJECT_TYPES, default='traditional') permission_type = models.CharField(max_length=50, choices=PERMISSION_TYPES, default='permissionless') snooze_warnings_for_days = models.IntegerField(default=0) + auto_approve_workers = models.BooleanField(default=True) token_value_time_peg = models.DateTimeField(blank=True, null=True) token_value_in_usdt = models.DecimalField(default=0, decimal_places=2, max_digits=50, blank=True, null=True) diff --git a/app/dashboard/router.py b/app/dashboard/router.py index 46f23f24196..19e628910a2 100644 --- a/app/dashboard/router.py +++ b/app/dashboard/router.py @@ -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', + 'additional_funding_summary', 'auto_approve_workers', ) def create(self, validated_data): diff --git a/app/dashboard/templates/bounty_details.html b/app/dashboard/templates/bounty_details.html index 813cb02cff1..527e70b911c 100644 --- a/app/dashboard/templates/bounty_details.html +++ b/app/dashboard/templates/bounty_details.html @@ -96,9 +96,14 @@