-
-
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
Reserve bounty improvements #5066
Merged
octavioamu
merged 6 commits into
gitcoinco:master
from
vince0656:reserve-bounty-improvements
Sep 19, 2019
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
35c5141
3544 - Reserve bounty improvements
vince0656 d5d79d2
Merge branch 'master' into reserve-bounty-improvements
octavioamu ba017f5
redid migrations
thelostone-mc 03f9e65
Merge remote-tracking branch 'upstream/master' into reserve-bounty-im…
thelostone-mc 08252d2
recreated migration
thelostone-mc 1957752
Merge branch 'master' into reserve-bounty-improvements
octavioamu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -601,12 +601,18 @@ def merge_bounty(latest_old_bounty, new_bounty, metadata, bounty_details, verbos | |
for activity in latest_old_bounty.activities.all().nocache(): | ||
new_bounty.activities.add(activity) | ||
|
||
|
||
bounty_reserved_for_user = metadata.get('reservedFor', '') | ||
if bounty_reserved_for_user: | ||
release_to_public_after = metadata.get('releaseAfter', '') | ||
if bounty_reserved_for_user and release_to_public_after: | ||
new_bounty.reserved_for_user_from = timezone.now() | ||
if release_to_public_after == "3-days": | ||
new_bounty.reserved_for_user_expiration = new_bounty.reserved_for_user_from + timezone.timedelta(days=3) | ||
elif release_to_public_after == "1-week": | ||
new_bounty.reserved_for_user_expiration = new_bounty.reserved_for_user_from + timezone.timedelta(weeks=1) | ||
|
||
new_bounty.reserved_for_user_handle = bounty_reserved_for_user | ||
new_bounty.save() | ||
if new_bounty.bounty_reserved_for_user: | ||
if new_bounty.bounty_reserved_for_user and new_bounty.status == 'reserved': | ||
# notify a user that a bounty has been reserved for them | ||
new_reserved_issue('[email protected]', new_bounty.bounty_reserved_for_user, new_bounty) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Generated by Django 2.2.4 on 2019-09-19 14:45 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('dashboard', '0051_profile_gitcoin_discord_username'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='bounty', | ||
name='reserved_for_user_expiration', | ||
field=models.DateTimeField(blank=True, null=True), | ||
), | ||
migrations.AddField( | ||
model_name='bounty', | ||
name='reserved_for_user_from', | ||
field=models.DateTimeField(blank=True, null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='bounty', | ||
name='idx_status', | ||
field=models.CharField(choices=[('cancelled', 'cancelled'), ('done', 'done'), ('expired', 'expired'), ('reserved', 'reserved'), ('open', 'open'), ('started', 'started'), ('submitted', 'submitted'), ('unknown', 'unknown')], db_index=True, default='open', max_length=9), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is there a simpler way we can humanize the timedelta? https://anandnalya.com/2009/05/humanizing-the-time-difference-in-django/
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.
Hey Dan. I'm not sure what you mean? I've had a look at the link you sent and we would still need to do calcs for hours. Additionally, the humanised timedelta outputs seem different compared to the current requirement of allowing a funder to reserve for '3 days', '1 week' or 'Keep reserved'. I tried to make the code as scalable as possible and struggled to find easier ways of doing this. It's a shame the timedelta object doesn't have an hours getter attribute or even a weeks one which is strange as you can construct a timedelta with weeks, days, hours, minutes etc.
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.
@danlipert
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.
@danlipert any thoughts on my comment?