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

Conversation

darkdarkdragon
Copy link
Contributor

Description

Allow funder to turn off auto approvals at bounty creation

Checklist
  • linter status: 100% pass
  • changes don't break existing behavior
Testing

Tested manually

Refers/Fixes

Fixes #1807

@@ -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,

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
Copy link

codecov bot commented Aug 5, 2018

Codecov Report

Merging #1945 into master will decrease coverage by <.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
app/dashboard/router.py 28.26% <ø> (ø) ⬆️
app/dashboard/helpers.py 16.98% <0%> (-0.06%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aec34fb...4e97e68. Read the comment docs.

@PixelantDesign
Copy link
Contributor

@darkdarkdragon are you able to provide screenshots? Thanks!

@darkdarkdragon
Copy link
Contributor Author

@PixelantDesign I've prepared them, but forgot to upload :(
will prepare new ones in couple of hours

@darkdarkdragon
Copy link
Contributor Author

image

@darkdarkdragon
Copy link
Contributor Author

image

@@ -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,

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

@darkdarkdragon
Copy link
Contributor Author

image

@@ -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,

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

@darkdarkdragon darkdarkdragon force-pushed the 1807_allow_auto_approve_off branch from 8d538da to 3b75809 Compare August 6, 2018 23:31
@thelostone-mc
Copy link
Member

Should we display auto approval option only if the logged in user is the funder ?

@PixelantDesign
Copy link
Contributor

PixelantDesign commented Aug 7, 2018

@darkdragon could we update the checkbox language to

  • Auto approve worker after 72 hours.

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
I think we should display for anyone that wants to fund....I don't feel strongly about that logic.

@owocki @mbeacom @saptak?

@darkdarkdragon
Copy link
Contributor Author

@PixelantDesign fixed checkbox's text
checkbox is already checked by default

@PixelantDesign
Copy link
Contributor

Great!

@PixelantDesign
Copy link
Contributor

@darkdarkdragon will you look at the above conflicts?

@darkdarkdragon darkdarkdragon force-pushed the 1807_allow_auto_approve_off branch from eeccce5 to 90f5749 Compare August 9, 2018 14:08
@darkdarkdragon
Copy link
Contributor Author

@PixelantDesign I've resolved conflicts.
But, btw, it is problem - I'm creating pr, it sits there without getting merged -> new commits to master -> my pr getting conflicts -> I'm resolving them -> it sits there -> rinse, repeat till starts are aligned in proper they and my pr finally merged.
It's pretty frustrating experience :(

@thelostone-mc
Copy link
Member

@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.
By the time you get to it , we end up merging commits from other contributors as well as core contributors which may end up in conflict resolution.

Sorry about the merge conflicts. It's something which is kinda occasionally impossible to avoid 😅

@@ -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)
Copy link
Contributor

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?

@@ -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)
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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

@frankchen07
Copy link
Contributor

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?

@darkdarkdragon
Copy link
Contributor Author

@frankchen07 oops, somehow missed that change request. Will do it after we settle with mbeacom on this topic

@darkdarkdragon darkdarkdragon force-pushed the 1807_allow_auto_approve_off branch 2 times, most recently from 2b89996 to 03812a5 Compare August 24, 2018 00:20
@thelostone-mc
Copy link
Member

@darkdarkdragon rebase whenever it's ready to be reviewed

@darkdarkdragon darkdarkdragon force-pushed the 1807_allow_auto_approve_off branch from eaeb99c to a0bb203 Compare September 9, 2018 23:04
@stickler-ci
Copy link

Your configuration file uses an unknown linter. The eslint linter is not a supported linter.

@darkdarkdragon
Copy link
Contributor Author

@thelostone-mc @mbeacom this ready to be reviewed

thelostone-mc
thelostone-mc previously approved these changes Sep 10, 2018
Copy link
Member

@thelostone-mc thelostone-mc left a 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 ?

mbeacom
mbeacom previously approved these changes Sep 24, 2018
@PixelantDesign
Copy link
Contributor

yay! @mbeacom can we see this on staging?

@mbeacom
Copy link
Contributor

mbeacom commented Sep 24, 2018

@PixelantDesign This is on staging.
@darkdarkdragon Thanks for the contribution! Once we get this signed off, we'll merge it! 😄

@mbeacom
Copy link
Contributor

mbeacom commented Sep 24, 2018

screenshot 2018-09-24 10 02 14

Copy link
Contributor

@SaptakS SaptakS left a 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') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use === instead of ==

$('select[name=permission_type]').change(function() {
var val = $('select[name=permission_type] option:selected').val();

if (val == 'approval') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use === instead of ==

@@ -105,6 +105,15 @@ $(document).ready(function() {
waitforWeb3(function() {
promptForAuth();
});
$('select[name=permission_type]').change(function() {
Copy link
Contributor

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
Copy link
Contributor

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 %}

@darkdarkdragon darkdarkdragon force-pushed the 1807_allow_auto_approve_off branch from 4dccb0d to 4e97e68 Compare October 2, 2018 07:59
@darkdarkdragon
Copy link
Contributor Author

@SaptakS @mbeacom done

Copy link
Contributor

@pinkiebell pinkiebell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything else lgtm 👍

@PixelantDesign
Copy link
Contributor

PixelantDesign commented Oct 18, 2018

Yay! Can we merge?

Copy link
Contributor

@mbeacom mbeacom left a 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.

@mbeacom mbeacom merged commit 184d4d0 into gitcoinco:master Nov 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants