# Path: website/models.py
# class Payment(models.Model):
#     issue = models.ForeignKey(Issue, on_delete=models.CASCADE)
#     solution = models.ForeignKey(Solution, on_delete=models.CASCADE)
#     user = models.ForeignKey(User, on_delete=models.CASCADE)
#     amount = models.DecimalField(max_digits=10, decimal_places=0)
#     txn_id = models.CharField(max_length=255, blank=True, null=True)
#     created = models.DateTimeField()
#     updated = models.DateTimeField()


from django import template
from website.models import Payment
from django.db.models import Sum

register = template.Library()


@register.simple_tag
def bounty_total():

# Path: website/models.py
# class Payment(models.Model):
#     issue = models.ForeignKey(Issue, on_delete=models.CASCADE)
#     solution = models.ForeignKey(Solution, on_delete=models.CASCADE)
#     user = models.ForeignKey(User, on_delete=models.CASCADE)
#     amount = models.DecimalField(max_digits=10, decimal_places=0)
#     txn_id = models.CharField(max_length=255, blank=True, null=True)
#     created = models.DateTimeField()
#     updated = models.DateTimeField()


# Path: website/templatetags/total.py
from django import template
from website.models import Payment
from django.db.models import Sum


register = template.Library()


@register.simple_tag
def bounty_total():

    _total = Payment.objects.aggregate(Sum('amount'))['amount__sum']