def response_change(self, request, obj): from django.shortcuts import redirect if "_reject_kudos" in request.POST: from marketing.mails import notify_kudos_rejected notify_kudos_rejected(obj) self.message_user(request, f"Notified user of rejection") return redirect( '/_administrationkudos/tokenrequest/?approved=f&rejection_reason=' ) if "_change_owner" in request.POST or request.POST.get( '_change_owner_mint_kudos', False): obj.to_address = '0x6239FF1040E412491557a7a02b2CBcC5aE85dc8F' obj.save() self.message_user(request, f"Changed owner to gitcoin") if "_mint_kudos" in request.POST or request.POST.get( '_change_owner_mint_kudos', False): from kudos.tasks import mint_token_request try: obj.rejection_reason = 'n/a' obj.save() 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 handle(self, *args, **options): # config counter = 0 trs = TokenRequest.objects.filter(approved=True, network='mainnet') print(trs.count()) for token in trs: try: already_xdaid = TokenRequest.objects.filter(network='xdai', name=token.name) if not already_xdaid: token.pk = None token.network = 'xdai' token.save() print(f'-/- {token.pk}') mint_token_request(token.pk, send_notif_email=False) delete_town_square_posts() except Exception as e: print(e) for token in Token.objects.filter(contract__network='mainnet'): if token.gen == 1 and not token.on_xdai: try: tr = TokenRequest.objects.create( network='xdai', name=token.name, description=token.description, priceFinney=token.price_finney, artist=token.artist if token.artist else '', platform=token.platform if token.platform else '', to_address=token.owner_address, numClonesAllowed=token.num_clones_allowed, artwork_url=token.image, metadata=token.metadata, tags=token.tags.split(','), approved=True, profile=Profile.objects.get(handle='gitcoinbot'), processed=True, ) print(f'*/* {tr.pk}') mint_token_request(tr.pk, send_notif_email=False) # post - minting hooks; like transfering over info or deleting townsquare posts delete_town_square_posts() if token.on_xdai: ku = token.on_xdai if ku.on_mainnet: if ku.on_mainnet.preview_img_mode == 'svg': if ku.preview_img_mode == 'png': ku.preview_img_mode = ku.on_mainnet.preview_img_mode print(ku.id) ku.save() except Exception as e: print(e)
import warnings from django.conf import settings from django.core.management.base import BaseCommand from dashboard.models import Profile from kudos.models import Token, TokenRequest from kudos.tasks import mint_token_request token = Token.objects.filter(contract__network='mainnet', name=name, num_clones_allowed__gt=1).first() print(token) tr = TokenRequest.objects.create( network='xdai', name=token.name, description=token.description, priceFinney=token.price_finney, artist=token.artist, platform=token.platform, to_address=token.owner_address, numClonesAllowed=token.num_clones_allowed, metadata=token.metadata, tags=token.tags.split(','), artwork_url=token.image, approved=True, profile=Profile.objects.get(handle='gitcoinbot'), processed=True, ) print(f'*/* {tr.pk}') mint_token_request(tr.pk, send_notif_email=False)