mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-09-27 20:08:19 +02:00
Allow to view activity entries on Activity tab
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{% comment %}
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
{% endcomment %}
|
||||
{% load i18n perms pretty_money %}
|
||||
{% load i18n perms pretty_money dict_get %}
|
||||
{% url 'activity:activity_detail' activity.pk as activity_detail_url %}
|
||||
|
||||
<div id="activity_info" class="card bg-light shadow mb-3">
|
||||
@@ -53,6 +53,12 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
<dt class="col-xl-6">{% trans 'opened'|capfirst %}</dt>
|
||||
<dd class="col-xl-6">{{ activity.open|yesno }}</dd>
|
||||
</dl>
|
||||
{% if show_entries|dict_get:activity %}
|
||||
<h2 class="text-center">
|
||||
{{ entries_count|dict_get:activity }}
|
||||
{% if entries_count|dict_get:activity >= 2 %}{% trans "entries" %}{% else %}{% trans "entry" %}{% endif %}
|
||||
</h2>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="card-footer text-center">
|
||||
|
0
apps/activity/templatetags/__init__.py
Normal file
0
apps/activity/templatetags/__init__.py
Normal file
12
apps/activity/templatetags/dict_get.py
Normal file
12
apps/activity/templatetags/dict_get.py
Normal file
@@ -0,0 +1,12 @@
|
||||
# Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from django import template
|
||||
|
||||
|
||||
def dict_get(d, key):
|
||||
return d.get(key)
|
||||
|
||||
|
||||
register = template.Library()
|
||||
register.filter('dict_get', dict_get)
|
@@ -93,6 +93,17 @@ class ActivityListView(ProtectQuerysetMixin, LoginRequiredMixin, MultiTableMixin
|
||||
started_activities = self.get_queryset().filter(open=True, valid=True).distinct().all()
|
||||
context["started_activities"] = started_activities
|
||||
|
||||
entries_count = {}
|
||||
show_entries = {}
|
||||
for activity in started_activities:
|
||||
if activity.activity_type.manage_entries:
|
||||
entries = Entry.objects.filter(activity=activity)
|
||||
entries_count[activity] = entries.count()
|
||||
|
||||
show_entries[activity] = True
|
||||
context["entries_count"] = entries_count
|
||||
context["show_entries"] = show_entries
|
||||
|
||||
return context
|
||||
|
||||
|
||||
@@ -137,6 +148,14 @@ class ActivityDetailView(ProtectQuerysetMixin, LoginRequiredMixin, MultiTableMix
|
||||
"placeholder": ""
|
||||
}
|
||||
}
|
||||
if self.object.activity_type.manage_entries:
|
||||
entries = Entry.objects.filter(activity=self.object)
|
||||
context["entries_count"] = {self.object: entries.count()}
|
||||
|
||||
context["show_entries"] = {self.object: timezone.now() > timezone.localtime(self.object.date_start)}
|
||||
else:
|
||||
context["entries_count"] = {self.object: 0}
|
||||
context["show_entries"] = {self.object: False}
|
||||
|
||||
return context
|
||||
|
||||
|
@@ -4430,6 +4430,22 @@
|
||||
"description": "Modifier le type de caution de mon inscription WEI tant qu'elle n'est pas validée"
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "permission.permission",
|
||||
"pk": 298,
|
||||
"fields": {
|
||||
"model": [
|
||||
"wei",
|
||||
"bus"
|
||||
],
|
||||
"query": "{\"pk\": [\"membership\", \"weimembership\", \"bus\", \"pk\"], \"wei__date_end__gte\": [\"today\"]}",
|
||||
"type": "change",
|
||||
"mask": 2,
|
||||
"field": "information_json",
|
||||
"permanent": false,
|
||||
"description": "Modifier les informations du bus"
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "permission.permission",
|
||||
"pk": 311,
|
||||
|
Reference in New Issue
Block a user