diff --git a/app/kudos/admin.py b/app/kudos/admin.py index 49419795faa..3abfd0cc17d 100644 --- a/app/kudos/admin.py +++ b/app/kudos/admin.py @@ -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'] @@ -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"" return mark_safe(html) + def preview_small(self, instance): + html = f"" + return mark_safe(html) + class TransferEnabledForAdmin(admin.ModelAdmin): ordering = ['-id'] diff --git a/app/kudos/tasks.py b/app/kudos/tasks.py index 861521ffd9e..fa5bc015610 100644 --- a/app/kudos/tasks.py +++ b/app/kudos/tasks.py @@ -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: @@ -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) diff --git a/app/retail/templates/admin/change_form.html b/app/retail/templates/admin/change_form.html index d0f206618f1..2903f537f65 100644 --- a/app/retail/templates/admin/change_form.html +++ b/app/retail/templates/admin/change_form.html @@ -85,10 +85,23 @@ {% endif %} {% elif 'kudos/tokenrequest' in request.build_absolute_uri %} - - +

Approve/Reject

+ +
+
+
+

Batch Actions

+ +
+
+
+

Sync'er

+ Num to Sync: + + + {% elif 'quests/quest' in request.build_absolute_uri %} {% elif 'dashboard/hackathonevent/' in request.build_absolute_uri %}