#83: Show total number and percent value of filtered participants.
This commit is contained in:
parent
a8fcba0f69
commit
95bf4c1cc8
@ -49,7 +49,11 @@
|
||||
</select>
|
||||
</form>
|
||||
</p>
|
||||
{{ users|length }} {% trans "Participant" %}
|
||||
{% if users|length == allusers|length %}
|
||||
{{ users|length }} {% trans "Participants" %}
|
||||
{% else %}
|
||||
{{ users|length }} {% trans "of" %} {{ allusers|length }} {% trans "Participants" %} (= {{ percent }} %)
|
||||
{% endif %}
|
||||
<table>
|
||||
<tr>
|
||||
<th><a href="?sort=first_name&reverse={% if 'first_name' in sortfilter.sort and 'reverse' not in sortfilter %}1{% else %}---{%endif%}">{%trans "First Name" %}</a></th>
|
||||
|
@ -91,6 +91,7 @@ def get_overview(request):
|
||||
if 'reverse' in sortfilter:
|
||||
query = query.reverse()
|
||||
|
||||
# list of filtered users (with profile)
|
||||
userlist = query.all()
|
||||
users = []
|
||||
for user in userlist:
|
||||
@ -99,10 +100,27 @@ def get_overview(request):
|
||||
users.append(user)
|
||||
except Profile.DoesNotExist:
|
||||
pass
|
||||
# list of all existing users (with profile)
|
||||
allusers = []
|
||||
for user in User.objects.all():
|
||||
try:
|
||||
user.get_profile()
|
||||
allusers.append(user)
|
||||
except Profile.DoesNotExist:
|
||||
pass
|
||||
# quotient of selected users and all users
|
||||
if len(allusers) > 0:
|
||||
percent = float(len(users)) * 100 / float(len(allusers))
|
||||
else:
|
||||
percent = 0
|
||||
# list of all existing groups
|
||||
groups = [p['group'] for p in Profile.objects.values('group').exclude(group='').distinct()]
|
||||
# list of all existing committees
|
||||
committees = [p['committee'] for p in Profile.objects.values('committee').exclude(committee='').distinct()]
|
||||
return {
|
||||
'users': users,
|
||||
'allusers': allusers,
|
||||
'percent': round(percent, 1),
|
||||
'groups': groups,
|
||||
'committees': committees,
|
||||
'cookie': ['participant_sortfilter', urlencode(decodedict(sortfilter), doseq=True)],
|
||||
|
Loading…
Reference in New Issue
Block a user