Skip to content

Commit a3d578c

Browse files
authored
Use pagination for participants and registration requests (#4557)
Closes #4555
1 parent 50bb244 commit a3d578c

9 files changed

Lines changed: 247 additions & 186 deletions

File tree

Lines changed: 62 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
{% extends 'auth/user_list.html' %}
1+
{% extends 'pages/challenge_settings_base.html' %}
22
{% load url %}
3+
{% load profiles %}
34

45
{% block title %}
56
Admins - {% firstof challenge.title challenge.short_name %} - {{ block.super }}
@@ -17,7 +18,8 @@
1718
</ol>
1819
{% endblock %}
1920

20-
{% block content_title %}
21+
{% block content %}
22+
2123
<h2>Admins for {{ challenge.short_name }}</h2>
2224

2325
<p>
@@ -26,26 +28,62 @@ <h2>Admins for {{ challenge.short_name }}</h2>
2628
<i class="fas fa-plus"></i> Add another admin
2729
</a>
2830
</p>
29-
{% endblock %}
3031

31-
{% block tableExtraHeaders %}
32-
<th class="nonSortable">Remove</th>
33-
{% endblock tableExtraHeaders %}
34-
35-
{% block tableExtraBody %}
36-
<td>
37-
{% if user != request.user %}
38-
<form method="post"
39-
action="{% url 'admins:update' challenge_short_name=challenge.short_name %}">
40-
{% csrf_token %}
41-
<input name="user" type="hidden" value="{{ user.pk }}">
42-
<input name="action" type="hidden"
43-
value="{{ admin_remove_action }}">
44-
<button type="submit"
45-
class="btn btn-xs btn-danger">
46-
Remove Admin
47-
</button>
48-
</form>
49-
{% endif %}
50-
</td>
51-
{% endblock tableExtraBody %}
32+
<div class="table-responsive">
33+
<table
34+
data-data-table
35+
data-page-length="10"
36+
class="table table-hover table-borderless table-sm w-100"
37+
>
38+
<thead class="thead-light">
39+
<tr>
40+
<th>Username</th>
41+
<th>Info</th>
42+
<th>Website</th>
43+
<th class="nonSortable">Remove</th>
44+
</tr>
45+
</thead>
46+
<tbody>
47+
48+
{% for user in object_list %}
49+
50+
<tr>
51+
<td>
52+
{{ user|user_profile_link }}
53+
</td>
54+
<td>
55+
{{ user.user_profile.user_info }}
56+
</td>
57+
<td>
58+
{% if user.user_profile.website %}
59+
<a href="{{ user.user_profile.website }}"
60+
target="_blank"
61+
title="Users Website {{ user.user_profile.website }}">
62+
<i class="fas fa-link"></i>
63+
</a>
64+
{% endif %}
65+
</td>
66+
<td>
67+
{% if user != request.user %}
68+
<form method="post"
69+
action="{% url 'admins:update' challenge_short_name=challenge.short_name %}">
70+
{% csrf_token %}
71+
<input name="user" type="hidden" value="{{ user.pk }}">
72+
<input name="action" type="hidden"
73+
value="{{ admin_remove_action }}">
74+
<button type="submit"
75+
class="btn btn-xs btn-danger">
76+
Remove Admin
77+
</button>
78+
</form>
79+
{% endif %}
80+
</td>
81+
</tr>
82+
83+
{% endfor %}
84+
85+
</tbody>
86+
87+
</table>
88+
</div>
89+
{% endblock %}

app/grandchallenge/participants/templates/auth/user_list.html

Lines changed: 0 additions & 57 deletions
This file was deleted.
Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
{% extends 'auth/user_list.html' %}
1+
{% extends 'datatables/list_challenge_settings_base.html' %}
22
{% load url %}
33

44
{% block title %}
55
Participants - {% firstof challenge.title challenge.short_name %} - {{ request.site.name }}
66
{% endblock %}
77

8-
{% block content_title %}
9-
<h2>Participants for {{ challenge.short_name }}</h2>
10-
{% endblock %}
11-
128
{% block breadcrumbs %}
139
<ol class="breadcrumb">
1410
<li class="breadcrumb-item"><a
@@ -21,26 +17,8 @@ <h2>Participants for {{ challenge.short_name }}</h2>
2117
</ol>
2218
{% endblock %}
2319

24-
{% block tableExtraHeaders %}
25-
<th class="nonSortable">Message</th>
26-
{% endblock tableExtraHeaders %}
20+
{% block content %}
21+
<h2>Participants for {{ challenge.short_name }}</h2>
2722

28-
{% block tableExtraBody %}
29-
<td>
30-
{% if user != request.user %}
31-
<form method="post"
32-
action="{% url 'direct_messages:conversation-create' username=user.username %}">
33-
{% csrf_token %}
34-
<button class="btn btn btn-primary"
35-
type="submit"
36-
{% if not challenge.is_active %}
37-
disabled
38-
title="This action cannot be performed as the challenge is inactive. Please contact support."
39-
{% endif %}
40-
>
41-
<i class="far fa-comment"></i>&nbsp;Message User
42-
</button>
43-
</form>
44-
{% endif %}
45-
</td>
46-
{% endblock tableExtraBody %}
23+
{{ block.super }}
24+
{% endblock %}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{% load profiles %}
2+
{% load url %}
3+
4+
{{ object|user_profile_link }}
5+
6+
<split></split>
7+
8+
{{ object.user_profile.user_info }}
9+
10+
<split></split>
11+
12+
{% if object.user_profile.website %}
13+
<a href="{{ object.user_profile.website }}"
14+
target="_blank"
15+
title="Users Website {{ object.user_profile.website }}">
16+
<i class="fas fa-link"></i>
17+
</a>
18+
{% endif %}
19+
20+
<split></split>
21+
22+
{% if object != request.user %}
23+
<form method="post"
24+
action="{% url 'direct_messages:conversation-create' username=object.username %}">
25+
{% csrf_token %}
26+
<button class="btn btn btn-primary"
27+
type="submit"
28+
{% if not challenge.is_active %}
29+
disabled
30+
title="This action cannot be performed as the challenge is inactive. Please contact support."
31+
{% endif %}
32+
>
33+
<i class="far fa-comment"></i>&nbsp;Message User
34+
</button>
35+
</form>
36+
{% endif %}
37+
38+
<split></split>
Lines changed: 2 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% extends "pages/challenge_settings_base.html" %}
1+
{% extends "datatables/list_challenge_settings_base.html" %}
22
{% load user_profile_link from profiles %}
33
{% load url %}
44
{% load static %}
@@ -24,68 +24,5 @@
2424

2525
<h2>Participation Requests for {{ challenge.short_name }}</h2>
2626

27-
<div class="table-responsive">
28-
<table
29-
data-data-table
30-
data-order='[[0, "desc"]]'
31-
data-page-length="10"
32-
class="table table-hover table-borderless table-sm w-100"
33-
>
34-
<thead class="thead-light">
35-
<tr>
36-
<th>Created</th>
37-
<th>Updated</th>
38-
<th>Username</th>
39-
<th>Profile Info</th>
40-
{% if viewable_registration_questions %}
41-
<th>Answers to questions</th>
42-
{% endif %}
43-
<th>Status</th>
44-
<th class="nonSortable">Accept / Reject</th>
45-
</tr>
46-
</thead>
47-
<tbody>
48-
49-
{% for regrequest in object_list %}
50-
51-
<tr>
52-
<td data-order="{{ regrequest.created|date:"c" }}">
53-
{{ regrequest.created }}
54-
</td>
55-
<td data-order="{{ regrequest.changed|date:"c" }}">
56-
{{ regrequest.changed }}
57-
</td>
58-
<td>
59-
{{ regrequest.user|user_profile_link }}
60-
</td>
61-
<td>
62-
{{ regrequest.user.user_profile.user_info }}
63-
</td>
64-
65-
{% if viewable_registration_questions %}
66-
<td>
67-
{% include "participants/partials/registration_question_modal.html" with challenge=challenge regrequest=regrequest viewable_registration_questions=viewable_registration_questions csrf_token=csrf_token only %}
68-
</td>
69-
{% endif %}
70-
<td data-order="{{ regrequest.status }}">
71-
{% if regrequest.status == regrequest.PENDING %}
72-
<i class="far fa-hourglass text-muted" title="Pending"></i>
73-
{% elif regrequest.status == regrequest.ACCEPTED %}
74-
<i class="fas fa-fw fa-check-circle text-success"
75-
title="Accepted"></i>
76-
{% elif regrequest.status == regrequest.REJECTED %}
77-
<i class="fas fa-fw fa-times-circle text-danger"
78-
title="Rejected"></i>
79-
{% endif %}
80-
</td>
81-
<td>
82-
{% include "participants/partials/request_accept_reject.html" with challenge=challenge regrequest=regrequest csrf_token=csrf_token only %}
83-
</td>
84-
</tr>
85-
{% endfor %}
86-
87-
</tbody>
88-
89-
</table>
90-
</div>
27+
{{ block.super }}
9128
{% endblock %}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{% load profiles %}
2+
3+
{{ object.created }}
4+
5+
<split></split>
6+
7+
{{ object.changed }}
8+
9+
<split></split>
10+
11+
{{ object.user|user_profile_link }}
12+
<br/>
13+
{{ object.user.user_profile.user_info }}
14+
15+
<split></split>
16+
17+
{% if viewable_registration_questions %}
18+
{% include "participants/partials/registration_question_modal.html" with challenge=challenge regrequest=object viewable_registration_questions=viewable_registration_questions csrf_token=csrf_token only %}
19+
<split></split>
20+
{% endif %}
21+
22+
23+
{% if object.status == object.PENDING %}
24+
<i class="far fa-hourglass text-muted" title="Pending"></i>
25+
{% elif object.status == object.ACCEPTED %}
26+
<i class="fas fa-fw fa-check-circle text-success"
27+
title="Accepted"></i>
28+
{% elif object.status == object.REJECTED %}
29+
<i class="fas fa-fw fa-times-circle text-danger"
30+
title="Rejected"></i>
31+
{% endif %}
32+
33+
<split></split>
34+
35+
{% include "participants/partials/request_accept_reject.html" with challenge=challenge regrequest=object csrf_token=csrf_token only %}
36+
37+
<split></split>

0 commit comments

Comments
 (0)