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

small time-saving operational tweaks for faucet request management #5029

Merged
merged 4 commits into from
Aug 20, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
Empty file.
36 changes: 36 additions & 0 deletions app/faucet/management/commands/process_faucet_requests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'''
Copyright (C) 2019 Gitcoin Core

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

'''
from django.core.management.base import BaseCommand

from faucet.models import FaucetRequest
from marketing.mails import reject_faucet_request


class Command(BaseCommand):

help = 'processes easy to process faucet requests so that admins dont have to.'

def handle(self, *args, **options):
reject_comments = "Please tell us what you're planning on using these funds for in the comments section! Thanks."
requests = FaucetRequest.objects.filter(rejected=False, fulfilled=False)
danlipert marked this conversation as resolved.
Show resolved Hide resolved
for faucet_request in requests:
faucet_request.comment_admin = reject_comments
faucet_request.rejected = True
faucet_request.save()
reject_faucet_request(faucet_request)
print(faucet_request.pk)
14 changes: 8 additions & 6 deletions app/faucet/templates/process_faucet_request.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ <h1>{% trans "Process Faucet Request" %} {{obj.pk}}</h1>

<div>
<h1>Reject Faucet Request For {{obj.github_username}}</h1>
<form method=POST id="reject_faucet_form">
{% csrf_token %}
<textarea style="width: 500px; height: 200px;" name="reject_comments">{% trans "Please tell us what you're planning on using these funds for in the comments section! Thanks." %}</textarea>
<br>
<input type="submit" name="rejectFaucet" id="rejectFaucet" value="Submit">
</form>
{% for rejection_reason in common_rejection_reasons %}
<form method=POST class="reject_faucet_form">
{% csrf_token %}
<textarea style="width: 200px; height: 50px;" name="reject_comments">{{rejection_reason}}</textarea>
<br>
<input type="submit" name="rejectFaucet" id="rejectFaucet" value="Submit">
</form>
{% endfor %}

</div>

Expand Down
17 changes: 13 additions & 4 deletions app/faucet/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,16 @@ def process_faucet_request(request, pk):
except FaucetRequest.DoesNotExist:
raise Http404

redir_link = '/_administrationfaucet/faucetrequest/?fulfilled=f&rejected=f'
faucet_amount = float(settings.FAUCET_AMOUNT) * float(recommend_min_gas_price_to_confirm_in_time(5))

if faucet_request.fulfilled:
messages.info(request, 'already fulfilled')
return redirect(reverse('admin:index'))
return redirect(redir_link)

if faucet_request.rejected:
messages.info(request, 'already rejected')
return redirect(reverse('admin:index'))
return redirect(redir_link)

reject_comments = request.POST.get('reject_comments')
if reject_comments:
Expand All @@ -121,7 +122,7 @@ def process_faucet_request(request, pk):
faucet_request.save()
reject_faucet_request(faucet_request)
messages.success(request, 'rejected')
return redirect(reverse('admin:index'))
return redirect(redir_link)

if request.POST.get('destinationAccount'):
faucet_request.fulfilled = True
Expand All @@ -130,12 +131,20 @@ def process_faucet_request(request, pk):
faucet_request.save()
processed_faucet_request(faucet_request)
messages.success(request, 'sent')
return redirect(reverse('admin:index'))
return redirect(redir_link)

common_rejection_reasons = [
"Please tell us what you're planning on using these funds for in the comments section! Thanks.",
"This is a faucet for Gitcoin-specific functionality (like posting Bounties or fulfilling Bounties). Please re-submit your request if you need to do something Gitcoin specific.",
"You don't need ETH to start work on a bounty. Please submit another request if you finish your work and need to submit work.",
"",
]

context = {
'obj': faucet_request,
'faucet_amount': faucet_amount,
'recommend_gas_price': round(recommend_min_gas_price_to_confirm_in_time(1), 1),
'common_rejection_reasons': common_rejection_reasons,
}

return TemplateResponse(request, 'process_faucet_request.html', context)
2 changes: 1 addition & 1 deletion app/retail/templates/admin/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ <h2>{% trans 'Debugging Tasks' %}</h2>
<h2>{% trans 'Administrative Tasks' %}</h2>

<ul>
<a href="/_administrationfaucet/faucetrequest/">Process Faucet Requests</a>
<a href="/_administrationfaucet/faucetrequest/?fulfilled=f&rejected=f">Process Faucet Requests</a>
</ul>
<ul>
<a href="/_administrationtdi/whitepaperaccessrequest/">Process Whitepaper Requests</a>
Expand Down
1 change: 1 addition & 0 deletions scripts/crontab
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/us
10 * * * * cd gitcoin/coin; bash scripts/run_management_command.bash post_to_craigslist 1 >> /var/log/gitcoin/post_to_craigslist.log 2>&1
10 1 * * * cd gitcoin/coin; bash scripts/run_management_command.bash output_gas_viz >> /var/log/gitcoin/output_gas_viz.log 2>&1
*/15 * * * * cd gitcoin/coin; bash scripts/run_management_command.bash check_gh_ratelimit >> /var/log/gitcoin/gh_ratelimit.log 2>&1
1 * * * * cd gitcoin/coin; bash scripts/run_management_command.bash process_faucet_requests >> /var/log/gitcoin/process_faucet_requests.log 2>&1


## USERS
Expand Down