def handle(self, *args, **options): # setup handle = 'igorbarinov' token_addr = '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359' contributor_address = '0x34aa3f359a9d614239015126635ce7732c18fdf3' token_symbol = 'DAI' network = 'mainnet' from dashboard.models import Profile from grants.models import Grant, Contribution, Subscription from grants.views import record_subscription_activity_helper items = [[ 114, 10000, '0x51d9e5b1667b716ccd3c3247b14eec03b92beb91d57c1708e7700a01cebfb4ee' ]] for item in items: grant_id = item[0] amount = item[1] tx_id = item[2] print(grant_id) grant = Grant.objects.get(pk=grant_id) profile = Profile.objects.get(handle=handle) subscription = Subscription() subscription.active = False subscription.contributor_address = contributor_address subscription.amount_per_period = amount subscription.real_period_seconds = 0 subscription.frequency = 1 subscription.frequency_unit = 'days' subscription.token_address = token_addr subscription.token_symbol = token_symbol subscription.gas_price = 1 subscription.new_approve_tx_id = '0x0' subscription.num_tx_approved = 1 subscription.network = network subscription.contributor_profile = profile subscription.grant = grant subscription.save() subscription.successful_contribution(tx_id) subscription.error = True #cancel subs so it doesnt try to bill again subscription.subminer_comments = "skipping subminer bc this is a 1 and done subscription, and tokens were alredy sent" subscription.save() record_subscription_activity_helper('new_grant_contribution', subscription, profile)
def process_grant_contribution(self, grant_id, grant_slug, profile_id, package, retry: bool = True) -> None: """ :param self: :param grant_id: :param grant_slug: :param profile_id: :param package: :return: """ grant = Grant.objects.get(pk=grant_id) profile = Profile.objects.get(pk=profile_id) if 'contributor_address' in package: subscription = Subscription() if grant.negative_voting_enabled: #is_postive_vote = True if package.get('is_postive_vote', 1) else False is_postive_vote = package.get('match_direction', '+') == '+' else: is_postive_vote = True subscription.is_postive_vote = is_postive_vote fee_pct = float(package.get('gitcoin-grant-input-amount', 0)) subscription.active = False subscription.contributor_address = package.get('contributor_address', '') subscription.amount_per_period = package.get('amount_per_period', 0) subscription.real_period_seconds = package.get('real_period_seconds', 2592000) subscription.frequency = package.get('frequency', 30) subscription.frequency_unit = package.get('frequency_unit', 'days') subscription.token_address = package.get('token_address', '') subscription.token_symbol = package.get('token_symbol', '') subscription.gas_price = (float(subscription.amount_per_period) * (fee_pct / 100)) subscription.new_approve_tx_id = package.get('sub_new_approve_tx_id', '0x0') subscription.split_tx_id = package.get('split_tx_id', '0x0') subscription.num_tx_approved = package.get('num_tx_approved', 1) subscription.network = package.get('network', '') subscription.contributor_profile = profile subscription.grant = grant subscription.comments = package.get('comment', '') subscription.save() # one time payments activity = None if int(subscription.num_tx_approved) == 1: subscription.successful_contribution( subscription.new_approve_tx_id) subscription.error = True #cancel subs so it doesnt try to bill again subscription.subminer_comments = "skipping subminer bc this is a 1 and done subscription, and tokens were alredy sent" subscription.save() activity = record_subscription_activity_helper( 'new_grant_contribution', subscription, profile) else: activity = record_subscription_activity_helper( 'new_grant_subscription', subscription, profile) if 'comment' in package: _profile = profile comment = package.get('comment') if comment and activity: if subscription and subscription.negative: _profile = Profile.objects.filter( handle='gitcoinbot').first() comment = f"Comment from contributor: {comment}" comment = Comment.objects.create(profile=_profile, activity=activity, comment=comment) if 'hide_wallet_address' in package: profile.hide_wallet_address = bool( package.get('hide_wallet_address', False)) profile.save() new_supporter(grant, subscription) thank_you_for_supporting(grant, subscription) update_grant_metadata.delay(grant_id)
def process_grant_contribution(self, grant_id, grant_slug, profile_id, package, send_supporter_mail: bool = True, retry: bool = True): """ :param self: :param grant_id: :param grant_slug: :param profile_id: :param package: :param send_supporter_mail: :return: """ from grants.views import record_subscription_activity_helper grant = Grant.objects.get(pk=grant_id) profile = Profile.objects.get(pk=profile_id) if 'contributor_address' in package: subscription = Subscription() if grant.negative_voting_enabled: #is_postive_vote = True if package.get('is_postive_vote', 1) else False is_postive_vote = package.get('match_direction', '+') == '+' else: is_postive_vote = True subscription.is_postive_vote = is_postive_vote fee_pct = float(package.get('gitcoin-grant-input-amount', 0)) subscription.active = False subscription.contributor_address = package.get('contributor_address', '') subscription.amount_per_period = package.get('amount_per_period', 0) subscription.real_period_seconds = package.get('real_period_seconds', 2592000) subscription.frequency = package.get('frequency', 30) subscription.frequency_unit = package.get('frequency_unit', 'days') subscription.token_address = package.get('token_address', '') subscription.token_symbol = package.get('token_symbol', '') subscription.gas_price = (float(subscription.amount_per_period) * (fee_pct / 100)) subscription.new_approve_tx_id = package.get('sub_new_approve_tx_id', '0x0') subscription.split_tx_id = package.get('split_tx_id', '0x0') subscription.num_tx_approved = package.get('num_tx_approved', 1) subscription.network = package.get('network', '') subscription.visitorId = package.get('visitorId', '') if subscription.network == 'undefined': # we unfortunately cannot trust the frontend to give us a valid network name # so this handles that case. more details are available at # https://gitcoincore.slack.com/archives/C01FQV4FX4J/p1607980714026400 if not settings.DEBUG: subscription.network = 'mainnet' subscription.contributor_profile = profile subscription.grant = grant subscription.comments = package.get('comment', '') subscription.save() value_usdt = subscription.get_converted_amount(True) include_for_clr = package.get('include_for_clr') if value_usdt < 1 or subscription.contributor_profile.shadowbanned: include_for_clr = False subscription.successful_contribution(subscription.new_approve_tx_id, include_for_clr, checkout_type=package.get( 'checkout_type', None)) # one time payments activity = None subscription.error = True #cancel subs so it doesnt try to bill again subscription.subminer_comments = "skipping subminer bc this is a 1 and done subscription, and tokens were alredy sent" subscription.save() if 'hide_wallet_address' in package: profile.hide_wallet_address = bool( package.get('hide_wallet_address', False)) profile.save() if 'anonymize_gitcoin_grants_contributions' in package: profile.anonymize_gitcoin_grants_contributions = package.get( 'anonymize_gitcoin_grants_contributions') profile.save() activity_profile = profile if not profile.anonymize_gitcoin_grants_contributions else Profile.objects.get( handle='gitcoinbot') activity = record_subscription_activity_helper( 'new_grant_contribution', subscription, activity_profile) if 'comment' in package: _profile = profile comment = package.get('comment') if value_usdt >= 1 and comment and activity: if profile.anonymize_gitcoin_grants_contributions: _profile = Profile.objects.filter( handle='gitcoinbot').first() comment = f"Comment from contributor: {comment}" comment = Comment.objects.create(profile=_profile, activity=activity, comment=comment) # emails to contributor if value_usdt >= 1 and send_supporter_mail: grants_with_subscription = [{ 'grant': grant, 'subscription': subscription }] try: thank_you_for_supporting(grants_with_subscription) except Exception as e: logger.exception(e) update_grant_metadata.delay(grant_id) return grant, subscription
def handle(self, *args, **options): # setup handle = 'gitcoinbot' token_addr = '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359' contributor_address = '0x620a3981f796346df02be83fd929758a88078e3c' token_symbol = 'DAI' network = 'mainnet' from dashboard.models import Profile from grants.models import Grant, Contribution, Subscription from grants.views import record_subscription_activity_helper items = [ [ 82, 13548, '0x37059e9ef5463d73b74641ae2bb1664b42e90b908aceff2871715390794d60e8' ], [ 89, 11728, '0xa4ce2dffcaef66bf0d8ba884a71f12a65752137b06ab4f6722c76cef493b223a' ], [ 24, 3499, '0x79c0160f59766c42095fd06f3d43453fe6d8cd253892e93ad3fd378d04427a44' ], [ 39, 3450, '0x37059e9ef5463d73b74641ae2bb1664b42e90b908aceff2871715390794d60e8' ], [ 80, 2762, '0x532d4f821ebab104a3923af0507cdbe09dabd2ff7f70b5a557fdd3abc2a4dbdf' ], [ 48, 2346, '0xb9abbb52df9decbae56f24b236987c4a31444ed00297a87471ef5192c233628f' ], [ 25, 2085, '0x532d4f821ebab104a3923af0507cdbe09dabd2ff7f70b5a557fdd3abc2a4dbdf' ], [ 20, 1428, '0x37059e9ef5463d73b74641ae2bb1664b42e90b908aceff2871715390794d60e8' ], [ 13, 1245, '0x79c0160f59766c42095fd06f3d43453fe6d8cd253892e93ad3fd378d04427a44' ], [ 36, 910, '0x79c0160f59766c42095fd06f3d43453fe6d8cd253892e93ad3fd378d04427a44' ], [ 37, 868, '0x532d4f821ebab104a3923af0507cdbe09dabd2ff7f70b5a557fdd3abc2a4dbdf' ], [ 40, 774, '0x3e03360481585dfc7ae3bdd5bb18a439126ba84f390a5bff96e8f6a6292d5e13' ], [ 49, 725, '0x37059e9ef5463d73b74641ae2bb1664b42e90b908aceff2871715390794d60e8' ], [ 85, 725, '0x37059e9ef5463d73b74641ae2bb1664b42e90b908aceff2871715390794d60e8' ], [21, 720, ''], [ 12, 530, '0x9ec5d4b9db048ebdec6951b9b856531e13f73fe215acd7aafa8bd59d75070b44' ], [ 32, 527, '0x79c0160f59766c42095fd06f3d43453fe6d8cd253892e93ad3fd378d04427a44' ], [ 30, 354, '0x37059e9ef5463d73b74641ae2bb1664b42e90b908aceff2871715390794d60e8' ], [ 29, 301, '0x37059e9ef5463d73b74641ae2bb1664b42e90b908aceff2871715390794d60e8' ], [ 16, 265, '0x37059e9ef5463d73b74641ae2bb1664b42e90b908aceff2871715390794d60e8' ], [ 86, 261, '0x5e3e271ba1329a267ebb8e717650a0420179477abd6f0badfaddfdfe151899ac' ], [ 38, 158, '0x37059e9ef5463d73b74641ae2bb1664b42e90b908aceff2871715390794d60e8' ], [ 65, 157, '0xa4ce2dffcaef66bf0d8ba884a71f12a65752137b06ab4f6722c76cef493b223a' ], [ 17, 150, '0x532d4f821ebab104a3923af0507cdbe09dabd2ff7f70b5a557fdd3abc2a4dbdf' ], [ 47, 119, '0x4a66b9da1b98d1b0f9d749fd7379b56cc0b4c3ca45823dff52e54bd203553b3a' ], [ 81, 100, '0xa4ce2dffcaef66bf0d8ba884a71f12a65752137b06ab4f6722c76cef493b223a' ], [ 99, 59, '0x37059e9ef5463d73b74641ae2bb1664b42e90b908aceff2871715390794d60e8' ], [ 23, 56, '0x074c6edbd446cf45fd0431e8c6cc7aa8e40a1f8c0c180367259e80b305a24be1' ], [ 35, 28, '0x532d4f821ebab104a3923af0507cdbe09dabd2ff7f70b5a557fdd3abc2a4dbdf' ], [ 62, 24, '0x532d4f821ebab104a3923af0507cdbe09dabd2ff7f70b5a557fdd3abc2a4dbdf' ], [ 41, 16, '0x37059e9ef5463d73b74641ae2bb1664b42e90b908aceff2871715390794d60e8' ], [ 50, 15, '0xa4ce2dffcaef66bf0d8ba884a71f12a65752137b06ab4f6722c76cef493b223a' ], [ 43, 13, '0x3e03360481585dfc7ae3bdd5bb18a439126ba84f390a5bff96e8f6a6292d5e13' ], [ 31, 10, '0xfc1ca568c041944ecfa5864d9b3cf911fcec73cea0288330e48dc89b2c9a4458' ], [ 74, 0, '0x37059e9ef5463d73b74641ae2bb1664b42e90b908aceff2871715390794d60e8' ], [ 76, 0, '0x37059e9ef5463d73b74641ae2bb1664b42e90b908aceff2871715390794d60e8' ], [ 26, 0, '0x298585812a7890dde47304249044955487c0c1d11b38c579bbd2228fdcd5c62d' ], [ 87, 0, '0x37059e9ef5463d73b74641ae2bb1664b42e90b908aceff2871715390794d60e8' ], [ 15, 0, '0x6f971c2320439d5d618eb1682cc46afabc96021bc01a00929a89adfc01dd6d21' ], [ 73, 0, '0x532d4f821ebab104a3923af0507cdbe09dabd2ff7f70b5a557fdd3abc2a4dbdf' ], [ 63, 0, '0x37059e9ef5463d73b74641ae2bb1664b42e90b908aceff2871715390794d60e8' ], [ 79, 0, '0x532d4f821ebab104a3923af0507cdbe09dabd2ff7f70b5a557fdd3abc2a4dbdf' ], [ 66, 0, '0x532d4f821ebab104a3923af0507cdbe09dabd2ff7f70b5a557fdd3abc2a4dbdf' ], [ 72, 0, '0x532d4f821ebab104a3923af0507cdbe09dabd2ff7f70b5a557fdd3abc2a4dbdf' ], [ 92, 0, '0x532d4f821ebab104a3923af0507cdbe09dabd2ff7f70b5a557fdd3abc2a4dbdf' ], [83, 0, ''] ] for item in items: grant_id = item[0] amount = item[1] tx_id = item[2] print(grant_id) grant = Grant.objects.get(pk=grant_id) profile = Profile.objects.get(handle=handle) subscription = Subscription() subscription.active = False subscription.contributor_address = contributor_address subscription.amount_per_period = amount subscription.real_period_seconds = 0 subscription.frequency = 1 subscription.frequency_unit = 'days' subscription.token_address = token_addr subscription.token_symbol = token_symbol subscription.gas_price = 1 subscription.new_approve_tx_id = '0x0' subscription.num_tx_approved = 1 subscription.network = network subscription.contributor_profile = profile subscription.grant = grant subscription.save() subscription.successful_contribution(tx_id) subscription.error = True #cancel subs so it doesnt try to bill again subscription.subminer_comments = "skipping subminer bc this is a 1 and done subscription, and tokens were alredy sent" subscription.save() record_subscription_activity_helper('new_grant_contribution', subscription, profile)