Show Protocoin total circulation

This commit is contained in:
Tanner Collin 2022-08-24 23:12:02 +00:00
parent 118a99aedd
commit 590b37c085
2 changed files with 8 additions and 0 deletions

View File

@ -214,6 +214,7 @@ class MemberSerializer(serializers.ModelSerializer):
email = fields.UserEmailField(serializers.EmailField)
phone = serializers.CharField()
protocoin = serializers.SerializerMethodField()
total_protocoin = serializers.SerializerMethodField()
class Meta:
model = models.Member
@ -257,6 +258,11 @@ class MemberSerializer(serializers.ModelSerializer):
total = transactions.aggregate(Sum('protocoin'))['protocoin__sum'] or 0
return total
def get_total_protocoin(self, obj):
transactions = models.Transaction.objects
total = transactions.aggregate(Sum('protocoin'))['protocoin__sum'] or 0
return total
def update(self, instance, validated_data):
instance.user.email = validated_data.get('email', instance.user.email)
instance.user.save()

View File

@ -94,6 +94,8 @@ export function Paymaster(props) {
<p>Current balance: &thinsp;{user.member.protocoin.toFixed(2)}</p>
<p>Total circulation: &thinsp;{user.member.total_protocoin.toFixed(2)}</p>
<Grid stackable padded columns={2}>
<Grid.Column width={5}>
Buy any amount of Protocoin: