From 6ba6c29dfcc6f640de5f8ed0079df7615e83f06d Mon Sep 17 00:00:00 2001 From: Kumar Saket Date: Sun, 7 Oct 2018 15:08:52 +0530 Subject: [PATCH] Fixes: https://github.com/gitcoinco/web/issues/1855, Introduces a function in Bounty Request to create Bounty with flag - requested. --- app/bounty_requests/models.py | 24 +++++++++++++++++++ app/bounty_requests/views.py | 3 +++ app/dashboard/models.py | 5 +++- .../templates/shared/sidebar_search.html | 6 +++++ .../templates/shared/status_tooltip.html | 12 +++++++--- 5 files changed, 46 insertions(+), 4 deletions(-) diff --git a/app/bounty_requests/models.py b/app/bounty_requests/models.py index 1b622238a32..5c102fd9922 100644 --- a/app/bounty_requests/models.py +++ b/app/bounty_requests/models.py @@ -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.""" @@ -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. ') diff --git a/app/bounty_requests/views.py b/app/bounty_requests/views.py index c0450d2d10d..c31828a6159 100644 --- a/app/bounty_requests/views.py +++ b/app/bounty_requests/views.py @@ -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: @@ -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) diff --git a/app/dashboard/models.py b/app/dashboard/models.py index 332aa5b3d8d..eb92ba09d18 100644 --- a/app/dashboard/models.py +++ b/app/dashboard/models.py @@ -200,6 +200,7 @@ class Bounty(SuperModel): ] STATUS_CHOICES = ( + ('requested', 'requested'), ('cancelled', 'cancelled'), ('done', 'done'), ('expired', 'expired'), @@ -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'] @@ -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() diff --git a/app/dashboard/templates/shared/sidebar_search.html b/app/dashboard/templates/shared/sidebar_search.html index 71bb54b2288..0c1b4c4421f 100644 --- a/app/dashboard/templates/shared/sidebar_search.html +++ b/app/dashboard/templates/shared/sidebar_search.html @@ -23,6 +23,12 @@ {% trans "PROJECT STATUS" %}
+
+ + +
+
+
diff --git a/app/dashboard/templates/shared/status_tooltip.html b/app/dashboard/templates/shared/status_tooltip.html index 3963cde054b..c121b65ab43 100644 --- a/app/dashboard/templates/shared/status_tooltip.html +++ b/app/dashboard/templates/shared/status_tooltip.html @@ -20,24 +20,30 @@
1
+
+ {% trans "Bounty Request" %}: {% trans "Fund a requested bounty here." %} +
+
+
+
2
{% trans "Open" %}: {% trans "A funded bounty is available for anyone to work on." %}
-
2
+
3
{% trans "Work Started" %}: {% trans "Work has been started by at least one person." %}
-
3
+
4
{% trans "Work Submitted" %}: {% trans "Completed work has been submitted by for review." %}
-
4
+
5
{% trans "Work Done" %}: {% trans "The submitted project has been accepted and the funds have been paid." %}