From 96630c87df871218f09529258b7e287b6caf4018 Mon Sep 17 00:00:00 2001 From: Aditya Anand M C Date: Tue, 29 Jun 2021 23:19:19 +0530 Subject: [PATCH] add txnhash to report endpoint --- app/grants/serializers.py | 11 ++++++++--- app/grants/tasks.py | 4 +++- app/grants/views.py | 4 +++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/grants/serializers.py b/app/grants/serializers.py index 23d49192a4c..51176d262a6 100644 --- a/app/grants/serializers.py +++ b/app/grants/serializers.py @@ -62,6 +62,7 @@ class TransactionsSerializer(serializers.Serializer): amount = serializers.SerializerMethodField() clr_round = serializers.SerializerMethodField() usd_value = serializers.SerializerMethodField() + tx_hash = serializers.SerializerMethodField() def get_amount(self, obj): subscription = obj.subscription @@ -73,11 +74,14 @@ def get_clr_round(self, obj): def get_usd_value(self, obj): subscription = obj.subscription return subscription.get_converted_amount(ignore_gitcoin_fee=False) - + + def get_tx_hash(self, obj): + return obj.tx_id if obj.tx_id else obj.split_tx_id + class Meta: """Define the Transactions serializer metadata.""" - fields = ('asset', 'timestamp', 'amount', 'clr_round', 'usd_value') + fields = ('asset', 'timestamp', 'amount', 'clr_round', 'usd_value', 'tx_hash') class CLRPayoutsSerializer(serializers.Serializer): """Handle serializing CLR Payout information.""" @@ -87,6 +91,7 @@ class CLRPayoutsSerializer(serializers.Serializer): usd_value = serializers.SerializerMethodField() timestamp = serializers.DateTimeField(source='created_on') round = serializers.IntegerField(source='round_number') + tx_hash = serializers.CharField(source='payout_tx') def get_usd_value(self, obj): return get_converted_amount(obj.amount, 'DAI') @@ -94,7 +99,7 @@ def get_usd_value(self, obj): class Meta: """Define the CLRPayout serializer metadata.""" - fields = ('amount', 'asset', 'usd_value', 'timestamp', 'round') + fields = ('amount', 'asset', 'usd_value', 'timestamp', 'round', 'tx_hash') class DonorSerializer(serializers.Serializer): """Handle serializing Donor information.""" diff --git a/app/grants/tasks.py b/app/grants/tasks.py index a49433ac508..3fcdb39c9f3 100644 --- a/app/grants/tasks.py +++ b/app/grants/tasks.py @@ -15,7 +15,9 @@ from dashboard.models import Profile from grants.models import Grant, GrantCollection, Subscription from grants.utils import get_clr_rounds_metadata, save_grant_to_notion -from marketing.mails import new_contributions, new_grant, new_grant_admin, notion_failure_email, thank_you_for_supporting +from marketing.mails import ( + new_contributions, new_grant, new_grant_admin, notion_failure_email, thank_you_for_supporting, +) from marketing.models import Stat from perftools.models import JSONStore from townsquare.models import Comment diff --git a/app/grants/views.py b/app/grants/views.py index 0fb633beac1..4225757e938 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -73,7 +73,9 @@ CartActivity, Contribution, Flag, Grant, GrantAPIKey, GrantBrandingRoutingPolicy, GrantCategory, GrantCLR, GrantCollection, GrantType, MatchPledge, Subscription, ) -from grants.tasks import process_grant_creation_admin_email, process_grant_creation_email, process_notion_db_write, update_grant_metadata +from grants.tasks import ( + process_grant_creation_admin_email, process_grant_creation_email, process_notion_db_write, update_grant_metadata, +) from grants.utils import ( emoji_codes, generate_collection_thumbnail, generate_img_thumbnail_helper, get_clr_rounds_metadata, get_user_code, is_grant_team_member, sync_payout,