diff --git a/scipost_django/organizations/models.py b/scipost_django/organizations/models.py index ec53cb080dfce1dd36f324d74164afd583ef1ed5..22e8d3bd77b9622b1243975069e37f9772172bfb 100644 --- a/scipost_django/organizations/models.py +++ b/scipost_django/organizations/models.py @@ -440,7 +440,7 @@ class Organization(models.Model): total += subsidy.value_in_year(year) return total - def get_total_subsidies_obtained(self, n_years_past=None): + def get_total_subsidies_obtained(self): """ Computes the total amount received by SciPost, in the form of subsidies from this Organization. @@ -451,6 +451,17 @@ class Organization(models.Model): .get("amount__sum", 0) ) + def get_total_subsidies_publicly_shown(self): + """ + Computes the total amount of publicly visible Subsidies. + """ + return ( + self.subsidy_set.obtained() + .filter(amount_publicly_shown=True) + .aggregate(models.Sum("amount")) + .get("amount__sum", 0) + ) + def get_balance_info(self): """ Return a dict containing this Organization's expenditure and support history. diff --git a/scipost_django/organizations/templates/organizations/_organization_card.html b/scipost_django/organizations/templates/organizations/_organization_card.html index 7269ce906a32751d6d9f36ebdc2c6a9fb517a9a1..001fb5e2e40abaf6f9dab8a9fe56d567898ca25d 100644 --- a/scipost_django/organizations/templates/organizations/_organization_card.html +++ b/scipost_django/organizations/templates/organizations/_organization_card.html @@ -231,7 +231,13 @@ {% endfor %} <tr style="border-top: 2px solid black"> <td>Total support obtained:</td> - <td>{% if subsidy.amount_publicly_shown or perms.scipost.can_manage_subsidies or "can_view_org_contacts" in user_org_perms %}€{{ org.get_total_subsidies_obtained }}{% else %}-{% endif %}</td> + <td> + {% with org.get_total_subsidies_publicly_shown as total_subsidies %} + {% if total_subsidies %} + €{{ total_subsidies }} + {% else %}-{% endif %} + {% endwith %} + </td> <td></td> </tr> </tbody>