Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Omkom test #476

Merged
merged 2 commits into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions chemie/customprofile/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ def get_third_most_bought_item(self):
def get_all_refill_sum(cls):
return cls.objects.aggregate(Sum("balance"))["balance__sum"]

@classmethod
def get_balance_sum_for_first_to_fifth_grades(cls):
return cls.objects.filter(grade__in=[1, 2, 3, 4, 5]).aggregate(Sum("balance"))["balance__sum"]



class Membership(models.Model):
start_date = models.DateTimeField(auto_now=False, auto_now_add=True)
Expand Down
28 changes: 21 additions & 7 deletions chemie/shop/templates/shop/all_refills.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,28 @@
</div>
</div>
</div>
<div class="d-flex justify-content-center flex-column" style="box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.24); margin:1rem; padding: 1rem">
<h5 style="text-align: center">Totalt antall HC-coins i omløp hos brukere</h5>
<div class="d-flex flex-row justify-content-center">
<div class="p-2">
<h5>{{refill_sum}}</h5>
<div class="d-flex justify-content-center flex-column" style="box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.24); margin: 1rem; padding: 1rem;">
<div style="text-align: center;">
<h5>Totalt antall HC-coins i omløp hos brukere</h5>
</div>

<div class="row justify-content-center">
<!-- Column for refill_sum_total -->
<div class="col-md-6">
<h6 style="text-align: center;">Totalt antall HC-coins</h6>
<div class="d-flex align-items-center justify-content-center">
<h5>{{ refill_sum_total }}</h5>
<img src="{% static "images/HC_coin.png" %}" alt="HC Coin" style="width: 1.8rem;">
</div>
</div>
<div class="p-2">
<img type="image/png" src="{% static "images/HC_coin.png" %}" style="width:1.8rem">

<!-- Column for refill_sum_active -->
<div class="col-md-6">
<h6 style="text-align: center;">Aktive HC-coins (1. til 5. klasse)</h6>
<div class="d-flex align-items-center justify-content-center">
<h5>{{ refill_sum_active }}</h5>
<img src="{% static "images/HC_coin.png" %}" alt="HC Coin" style="width: 1.8rem;">
</div>
</div>
</div>
</div>
Expand Down
6 changes: 4 additions & 2 deletions chemie/shop/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,10 @@ def view_all_refills(request):
context["refill_receipts"] = refill_receipts
except ObjectDoesNotExist:
pass
refill_sum = Profile.get_all_refill_sum()
context["refill_sum"] = refill_sum
refill_sum_active = Profile.get_balance_sum_for_first_to_fifth_grades()
context["refill_sum_active"] = refill_sum_active
refill_sum_total = Profile.get_all_refill_sum()
context["refill_sum_total"] = refill_sum_total
return render(request, "shop/all_refills.html", context)


Expand Down
Loading