Skip to content

Commit

Permalink
Fixes: gitcoinco#1855, Introduces a function in Bounty Request to cre…
Browse files Browse the repository at this point in the history
…ate Bounty with flag - requested.
  • Loading branch information
Kumar Saket committed Oct 7, 2018
1 parent 99a12e2 commit 6ba6c29
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 4 deletions.
24 changes: 24 additions & 0 deletions app/bounty_requests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@
from django.core.validators import MinValueValidator
from django.db import models

from datetime import date, datetime, timedelta
import pytz

from economy.models import SuperModel

from dashboard.models import Bounty
from dashboard.utils import clean_bounty_url


class BountyQuerySet(models.QuerySet):
"""Define the Bounty Request QuerySet Manager."""
Expand Down Expand Up @@ -64,3 +70,21 @@ class BountyRequest(SuperModel):
def __str__(self):
"""Return the string representation of BountyRequest."""
return f"{self.requested_by.username} / {self.created_on}"

def to_bounty(self, network=None):
"""Creates a bounty with project status as requested. """
print ('self value is {} - {} - Type {}'.format(self.github_url, self.amount, type(self.amount)))
new_bounty = Bounty.objects.create(
github_url=clean_bounty_url(self.github_url),
idx_status='requested',
token_name='USDT',
value_true=float(self.amount),
network=network,
web3_created=datetime.now(tz=pytz.UTC),
expires_date=datetime.now(tz=pytz.UTC) + timedelta(days=90), # Request expire in 3 months.
is_open=False, # By default mark this as False as this will require fund.
raw_data={},
current_bounty=True # By default it would be marked as the current bounty.
)

print ('Bounty is created. ')
3 changes: 3 additions & 0 deletions app/bounty_requests/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
def bounty_request(request):
user = request.user if request.user.is_authenticated else None
profile = request.user.profile if user and hasattr(request.user, 'profile') else None
network = request.GET.get('network', 'rinkeby')

if request.body:
if not user or not profile or not profile.handle:
Expand All @@ -53,6 +54,8 @@ def bounty_request(request):
model = result.save(commit=False)
model.requested_by = profile
model.save()

model.to_bounty(network=network)
new_bounty_request(model)
return JsonResponse({'msg': _('Bounty Request received.')}, status=200)

Expand Down
5 changes: 4 additions & 1 deletion app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ class Bounty(SuperModel):
]

STATUS_CHOICES = (
('requested', 'requested'),
('cancelled', 'cancelled'),
('done', 'done'),
('expired', 'expired'),
Expand All @@ -209,7 +210,7 @@ class Bounty(SuperModel):
('unknown', 'unknown'),
)
FUNDED_STATUSES = ['open', 'started', 'submitted', 'done']
OPEN_STATUSES = ['open', 'started', 'submitted']
OPEN_STATUSES = ['requested', 'open', 'started', 'submitted']
CLOSED_STATUSES = ['expired', 'unknown', 'cancelled', 'done']
TERMINAL_STATUSES = ['done', 'expired', 'cancelled']

Expand Down Expand Up @@ -544,6 +545,8 @@ def status(self):
if not self.is_open:
if self.accepted:
return 'done'
elif self.idx_status=='requested':
return 'requested'
elif self.past_hard_expiration_date:
return 'expired'
has_tips = self.tips.filter(is_for_bounty_fulfiller=False).exclude(txid='').exists()
Expand Down
6 changes: 6 additions & 0 deletions app/dashboard/templates/shared/sidebar_search.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
{% trans "PROJECT STATUS" %} <i class="fas fa-info-circle"></i>
</div>
<div class="col-12 options">
<div class="form__radio option">
<input name="idx_status" id="status_requested" type="radio" value="requested" val-ui='Bounty Requests' />
<label class="filter-label" for=status_requested>{% trans "Bounty Requests" %}</label>
</div>
<hr/>

<div class="form__radio option">
<input name="idx_status" id="status_open" type="radio" value="open" val-ui='Open' checked />
<label class="filter-label" for=status_open>1 {% trans "Open" %}</label>
Expand Down
12 changes: 9 additions & 3 deletions app/dashboard/templates/shared/status_tooltip.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,30 @@
<div class="font-body">
<div class="row">
<div class="col-1 num">1</div>
<div class="col-11">
<strong>{% trans "Bounty Request" %}:</strong> {% trans "Fund a requested bounty here." %}
</div>
</div>
<div class="row">
<div class="col-1 num">2</div>
<div class="col-11">
<strong>{% trans "Open" %}:</strong> {% trans "A funded bounty is available for anyone to work on." %}
</div>
</div>
<div class="row">
<div class="col-1">2</div>
<div class="col-1">3</div>
<div class="col-11">
<strong>{% trans "Work Started" %}:</strong> {% trans "Work has been started by at least one person." %}
</div>
</div>
<div class="row">
<div class="col-1">3</div>
<div class="col-1">4</div>
<div class="col-11">
<strong>{% trans "Work Submitted" %}:</strong> {% trans "Completed work has been submitted by for review." %}
</div>
</div>
<div class="row">
<div class="col-1">4</div>
<div class="col-1">5</div>
<div class="col-11">
<strong>{% trans "Work Done" %}:</strong> {% trans "The submitted project has been accepted and the funds have been paid." %}
</div>
Expand Down

0 comments on commit 6ba6c29

Please sign in to comment.