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

Adds some sanity to the kudos minter #9099

Merged
merged 2 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
15 changes: 13 additions & 2 deletions app/kudos/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class GeneralAdmin(admin.ModelAdmin):
class TokenRequestAdmin(admin.ModelAdmin):
ordering = ['-id']
search_fields = ['profile__handle', 'name']
list_display = ['pk', 'profile', 'network', 'created_on', '__str__']
list_display = ['preview_small', 'pk', 'profile', 'network', 'created_on', '__str__']
raw_id_fields = ['profile']
readonly_fields = ['preview']

Expand All @@ -56,17 +56,28 @@ def response_change(self, request, obj):
try:
obj.rejection_reason = 'n/a'
obj.save()
mint_token_request(obj.id)
mint_token_request(obj.id, num_sync=1)
self.message_user(request, f"Mint/sync submitted to chain")
except Exception as e:
self.message_user(request, str(e))
return redirect('/_administrationkudos/tokenrequest/?approved=f&rejection_reason=')
if "_do_sync_kudos" in request.POST:
from kudos.management.commands.mint_all_kudos import sync_latest
num_sync = int(request.POST.get('num_sync', 5))
for i in range(0, num_sync):
sync_latest(i, network=obj.network)
self.message_user(request, f"Sync'c Kudos")
return redirect('/kudos/marketplace')
return redirect(obj.admin_url)

def preview(self, instance):
html = f"<img style='max-width: 400px;' src='{instance.artwork_url}'>"
return mark_safe(html)

def preview_small(self, instance):
html = f"<a href={instance.admin_url}><img style='max-width: 50px;' src='{instance.artwork_url}'></a>"
return mark_safe(html)


class TransferEnabledForAdmin(admin.ModelAdmin):
ordering = ['-id']
Expand Down
4 changes: 2 additions & 2 deletions app/kudos/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
delay_if_gas_prices_gt_mint = 150

@app.shared_task(bind=True, max_retries=10)
def mint_token_request(self, token_req_id, send_notif_email=True, retry=False):
def mint_token_request(self, token_req_id, send_notif_email=True, num_sync=5, retry=False):
"""
:param self:
:param token_req_id:
Expand All @@ -49,7 +49,7 @@ def mint_token_request(self, token_req_id, send_notif_email=True, retry=False):
if tx_id:
while not has_tx_mined(tx_id, obj.network):
time.sleep(1)
for i in range(0, 5):
for i in range(0, num_sync):
sync_latest(i, network=obj.network)
if send_notif_email:
notify_kudos_minted(obj)
Expand Down
17 changes: 15 additions & 2 deletions app/retail/templates/admin/change_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,23 @@
<input type="submit" value="Notify User of Contribution Failure" name="_notify_contribution_failure" value="1">
{% endif %}
{% elif 'kudos/tokenrequest' in request.build_absolute_uri %}
<input type="submit" value="Change Owner + Mint + Sync Kudos" name="_change_owner_mint_kudos" value="1">
<input type="submit" value="Mint + Sync Kudos" name="_mint_kudos" value="1">
<h4>Approve/Reject</h4>
<input type="submit" value="Mint Kudos" name="_mint_kudos" value="1">
<input type="submit" value="Reject Kudos" name="_reject_kudos" value="1">
<input type="submit" value="Change Owner to Gitcoin" name="_change_owner" value="1">
<br>
<hr>
<br>
<h4>Batch Actions</h4>
<input type="submit" value="Change Owner + Mint" name="_change_owner_mint_kudos" value="1">
<br>
<hr>
<br>
<h4>Sync'er</h4>
Num to Sync:
<input type="number" value="5" name="num_sync">
<input type="submit" value="Sync Kudos" name="_do_sync_kudos" value="1">

{% elif 'quests/quest' in request.build_absolute_uri %}
<input type="submit" value="Approve Request" name="_approve_quest" value="1">
{% elif 'dashboard/hackathonevent/' in request.build_absolute_uri %}
Expand Down