Skip to content

Commit

Permalink
Added extra shares counting.
Browse files Browse the repository at this point in the history
  • Loading branch information
Theophile-Madet committed Sep 12, 2023
1 parent 3796311 commit 8d11225
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
18 changes: 14 additions & 4 deletions tapir/statistics/templates/statistics/main_statistics.html
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,18 @@ <h5 class="card-header">{% translate "Co-purchasers" %}</h5>
<div class="col-xl-6">
<div class="card mb-2">
<h5 class="card-header">{{ campaigns.0.name }}</h5>
{% for campaign in campaigns %}
<ul class="list-group list-group-flush">
<ul class="list-group list-group-flush">
<li class="list-group-item">
<p>
{% blocktranslate with extra_shares=extra_shares %}
Since the 12.09.23, {{ extra_shares }} extra shares have been bought. An extra
share is any share that is bought beyond the first compulsory share,
independently of whether the person became a member before or after the
12.09.2023.
{% endblocktranslate %}
</p>
</li>
{% for campaign in campaigns %}
<li class="list-group-item">
<p>
<span class="{% tapir_button_link %}"
Expand All @@ -200,8 +210,8 @@ <h5 class="card-header">{{ campaigns.0.name }}</h5>
style="display: none;"></canvas>
</p>
</li>
</ul>
{% endfor %}
{% endfor %}
</ul>
</div>
</div>
{% endif %}
Expand Down
18 changes: 18 additions & 0 deletions tapir/statistics/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,26 @@ def get_context_data(self, **kwargs):
] = FrozenMembersJsonView.get_relevant_members().count()
context_data["campaigns"] = FinancingCampaign.objects.active_temporal()

context_data["extra_shares"] = self.get_extra_shares_count()

return context_data

@staticmethod
def get_extra_shares_count():
threshold_date = datetime.date(day=12, month=9, year=2023)
first_shares = [
share_owner.get_oldest_active_share_ownership().id
for share_owner in ShareOwner.objects.all()
if share_owner.get_oldest_active_share_ownership() is not None
]

return (
ShareOwnership.objects.filter(start_date__gte=threshold_date)
.exclude(id__in=first_shares)
.active_temporal()
.count()
)


class CacheDatesFromFirstShareToTodayMixin:
def __init__(self):
Expand Down

0 comments on commit 8d11225

Please sign in to comment.