-
-
Notifications
You must be signed in to change notification settings - Fork 775
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
allow funder to turn off auto approvals at bounty creation #1945
Conversation
app/dashboard/helpers.py
Outdated
@@ -407,6 +407,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=bounty_payload.get('schemes', {}).get('auto_approve_workers', 1) if not latest_old_bounty else latest_old_bounty.auto_approve_workers, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E501 line too long (171 > 120 characters)
Codecov Report
@@ Coverage Diff @@
## master #1945 +/- ##
==========================================
- Coverage 27.78% 27.77% -0.01%
==========================================
Files 145 145
Lines 11627 11628 +1
Branches 1570 1570
==========================================
Hits 3230 3230
- Misses 8285 8286 +1
Partials 112 112
Continue to review full report at Codecov.
|
@darkdarkdragon are you able to provide screenshots? Thanks! |
@PixelantDesign I've prepared them, but forgot to upload :( |
app/dashboard/helpers.py
Outdated
@@ -407,6 +407,8 @@ 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=bounty_payload.get('schemes', {}). | |||
get('auto_approve_workers', 1) if not latest_old_bounty else latest_old_bounty.auto_approve_workers, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E131 continuation line unaligned for hanging indent
app/dashboard/helpers.py
Outdated
@@ -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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E251 unexpected spaces around keyword / parameter equals
8d538da
to
3b75809
Compare
Should we display auto approval option only if the logged in user is the funder ? |
@darkdragon could we update the checkbox language to
Let's do checked by default so that there aren't a bunch of issues held up from issues not being checked. For the Issue Details looks good for this iteration. @thelostone-mc |
@PixelantDesign fixed checkbox's text |
Great! |
@darkdarkdragon will you look at the above conflicts? |
eeccce5
to
90f5749
Compare
@PixelantDesign I've resolved conflicts. |
@darkdarkdragon Ah I know it can get frustrating but usually what happens is -> when a PR is shot out & the triggered build fails -> we can't merge it in just the logic works. Sorry about the merge conflicts. It's something which is kinda occasionally impossible to avoid 😅 |
app/dashboard/helpers.py
Outdated
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we be more explicit with this variable name?
app/dashboard/models.py
Outdated
@@ -260,6 +260,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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we simply reuse the Bounty.admin_override_suspend_auto_approval
field for this? If we're worried about the naming convention, rename and migrate the field?
Then you could simply update the JS to display this button if staff OR funder and display Suspend
or Enable
based on the current state?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can. I've added new field because this two have slightly different meaning, and I was not sure I can merge them. Also, we was planning to add check to the bounty details page so funder can turn it off/on at any time, and in that case, if we merge those two fields, admin will not be able to override it in a way so that funder will not be able to flip it back. I was not sure if this is acceptable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mbeacom your thoughts on that one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@darkdarkdragon I don't think we're too concerned with staff not being able to forcibly disable/enable auto approval and ensure persistence here. In an effort to increase maintainability moving forward, maybe we could rename the field, but simply use one field to handle this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mbeacom ok, no problem, I'll remove extra field
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@frankchen07 either way. If somebody point me to relevant example how to do it, I'll do it, but if someone else can do it faster that's fine too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@darkdarkdragon make migrations
will generate the automatic migrations. make migrate
migrates your local DB with the new migration changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@darkdarkdragon What I was recommending was to delete your new migrations and field and simply use the original field for this. If you are unsure of how to migrate a field to a new field name (not entirely required at the moment), please just delete your migrations in this branch, remove your new field, leave the original field and use that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simply switch back to using admin_override_suspend_auto_approval
instead of auto_approve_workers
for the time being.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, will do it tomorrw
hey @darkdarkdragon - I'm helping @PixelantDesign do some check-ins on our August bountied milestones. Have you gotten a chance to look at @mbeacom's change requests? |
@frankchen07 oops, somehow missed that change request. Will do it after we settle with mbeacom on this topic |
2b89996
to
03812a5
Compare
@darkdarkdragon rebase whenever it's ready to be reviewed |
eaeb99c
to
a0bb203
Compare
Your configuration file uses an unknown linter. The |
@thelostone-mc @mbeacom this ready to be reviewed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. works fine on local 👍
@mbeacom should we test this out on staging too ?
yay! @mbeacom can we see this on staging? |
@PixelantDesign This is on staging. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments. Please check.
@@ -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') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use ===
instead of ==
app/assets/v2/js/pages/new_bounty.js
Outdated
$('select[name=permission_type]').change(function() { | ||
var val = $('select[name=permission_type] option:selected').val(); | ||
|
||
if (val == 'approval') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use ===
instead of ==
app/assets/v2/js/pages/new_bounty.js
Outdated
@@ -105,6 +105,15 @@ $(document).ready(function() { | |||
waitforWeb3(function() { | |||
promptForAuth(); | |||
}); | |||
$('select[name=permission_type]').change(function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use .on('change', function(){})
. .change
, .click
and similar action listeners functions have been deprecated by jQuery.
<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;">{% blocktrans %}Worker will be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use {% trans "" %}
instead of {% blocktrans %}
c3cc11b
to
4dccb0d
Compare
4dccb0d
to
4e97e68
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything else lgtm 👍
Yay! Can we merge? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤷♂️ - we can adjust the remaining comments after it's been merged.
Description
Allow funder to turn off auto approvals at bounty creation
Checklist
Testing
Tested manually
Refers/Fixes
Fixes #1807