Пример #1
0
 def amount_donated(self):
     from bluebottle.funding.states import DonationStateMachine
     from bluebottle.funding.models import Donation
     from bluebottle.funding.utils import calculate_total
     donations = self.contribution_set.instance_of(Donation).filter(
         status=DonationStateMachine.succeeded.value)
     return calculate_total(donations)
Пример #2
0
    def amount_pledged(self):
        """
        The sum of all contributions (donations) converted to the targets currency
        """
        from .states import DonationStateMachine
        from bluebottle.funding.utils import calculate_total
        donations = self.donations.filter(
            status__in=(
                DonationStateMachine.succeeded.value,
                DonationStateMachine.activity_refunded.value,
            ),
            donation__payment__pledgepayment__isnull=False)
        if self.target and self.target.currency:
            total = calculate_total(donations, self.target.currency)
        else:
            total = calculate_total(donations, properties.DEFAULT_CURRENCY)

        return total
Пример #3
0
 def amount_donated(self):
     """
     The sum of all contributions (donations) converted to the targets currency
     """
     from .states import DonationStateMachine
     from bluebottle.funding.utils import calculate_total
     cache_key = '{}.{}.amount_donated'.format(
         connection.tenant.schema_name, self.id)
     total = cache.get(cache_key)
     if not total:
         donations = self.donations.filter(status__in=(
             DonationStateMachine.succeeded.value,
             DonationStateMachine.activity_refunded.value,
         ))
         if self.target and self.target.currency:
             total = calculate_total(donations, self.target.currency)
         else:
             total = calculate_total(donations, properties.DEFAULT_CURRENCY)
         cache.set(cache_key, total)
     return total