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

export earnings, txid, token name/value, payee location #5957

Merged
merged 11 commits into from
Apr 25, 2020
28 changes: 28 additions & 0 deletions app/dashboard/migrations/0102_auto_20200422_1452.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 2.2.4 on 2020-04-22 14:52

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('dashboard', '0101_auto_20200420_1427'),
]

operations = [
migrations.AddField(
model_name='earning',
name='token_name',
field=models.CharField(default='', max_length=255),
),
migrations.AddField(
model_name='earning',
name='token_value',
field=models.DecimalField(decimal_places=2, default=0, max_digits=50),
),
migrations.AddField(
model_name='earning',
name='txid',
field=models.CharField(default='', max_length=255),
),
]
10 changes: 10 additions & 0 deletions app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1770,6 +1770,9 @@ def postsave_tip(sender, instance, created, **kwargs):
"value_usd":instance.value_in_usdt_then,
"url":'https://gitcoin.co/tips',
"network":instance.network,
"txid":instance.txid,
"token_name":instance.tokenName,
"token_value":instance.value_true,
}
)

Expand Down Expand Up @@ -1852,6 +1855,9 @@ def psave_bounty_fulfilll(sender, instance, **kwargs):
"value_usd":instance.bounty.value_in_usdt_then,
"url":instance.bounty.url,
"network":instance.bounty.network,
"txid":'',
"token_name":instance.bounty.token_name,
"token_value":instance.bounty.value_in_token,
}
)

Expand Down Expand Up @@ -4741,6 +4747,10 @@ class Earning(SuperModel):
source = GenericForeignKey('source_type', 'source_id')
network = models.CharField(max_length=50, default='')
url = models.CharField(max_length=500, default='')
txid = models.CharField(max_length=255, default='')
token_name = models.CharField(max_length=255, default='')
token_value = models.DecimalField(decimal_places=2, max_digits=50, default=0)
network = models.CharField(max_length=50, default='')

def __str__(self):
return f"{self.from_profile} => {self.to_profile} of ${self.value_usd} on {self.created_on} for {self.source}"
Expand Down
3 changes: 3 additions & 0 deletions app/grants/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,9 @@ def psave_contrib(sender, instance, **kwargs):
"value_usd":instance.subscription.get_converted_amount(False),
"url":instance.subscription.grant.url,
"network":instance.subscription.grant.network,
"txid":instance.subscription.split_tx_id,
"token_name":instance.subscription.token_symbol,
"token_value":instance.subscription.amount_per_period,
}
)
except:
Expand Down
3 changes: 3 additions & 0 deletions app/kudos/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,9 @@ def psave_kt(sender, instance, **kwargs):
"value_usd":instance.value_in_usdt_then,
"url":instance.kudos_token_cloned_from.url,
"network":instance.network,
"txid":instance.txid,
"token_name":'ETH',
"token_value":instance.value_true,
}
)

Expand Down
12 changes: 9 additions & 3 deletions app/marketing/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,18 +534,24 @@ def account_settings(request):
response['Content-Disposition'] = f'attachment; filename="{name}.csv"'

writer = csv.writer(response)
writer.writerow(['id', 'date', 'From', 'To', 'Type', 'Value In USD', 'url'])
writer.writerow(['id', 'date', 'From', 'From Location', 'To', 'To Location', 'Type', 'Value In USD', 'url', 'txid', 'token_name', 'token_value'])
profile = request.user.profile
earnings = profile.earnings if export_type == 'earnings' else profile.sent_earnings
earnings = earnings.all().order_by('-created_on')
earnings = earnings.filter(network='mainnet').order_by('-created_on')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be dynamic to work on local also ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nah it's just for export -> should be fine

for earning in earnings:
writer.writerow([earning.pk,
earning.created_on.strftime("%Y-%m-%dT%H:00:00"),
earning.from_profile.handle if earning.from_profile else '*',
earning.from_profile.data.get('location', 'Unknown') if earning.from_profile else 'Unknown',
earning.to_profile.handle if earning.to_profile else '*',
earning.to_profile.data.get('location', 'Unknown') if earning.to_profile else 'Unknown',
earning.source_type.model_class(),
earning.value_usd,
earning.url])
earning.txid,
earning.token_name,
earning.token_value,
earning.url,
])

return response
elif request.POST.get('disconnect', False):
Expand Down