Skip to content

Commit

Permalink
Merge pull request #1923 from T-CAIREM/au/event/feature/show_inactive…
Browse files Browse the repository at this point in the history
…_participants

Events: show inactive participants to host and Admin
  • Loading branch information
tompollard authored Nov 16, 2023
2 parents 80e589a + 35952ff commit bdfa393
Show file tree
Hide file tree
Showing 7 changed files with 287 additions and 100 deletions.
34 changes: 23 additions & 11 deletions physionet-django/console/templates/console/event_management.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,42 +38,54 @@ <h1>{{ event.title }}</h1>
{% endif %}
</div>
</div>

{% for info in applicant_info %}
<div class="row mb-1">
<div class="col-md-3">Total participants:</div>
<div class="col-md-3">{{ info.title }}</div>
<div class="col-md-9">
<div class="row mb-1">
<div class="col-md-1">{{ event.participants.count }}</div>
<div class="col-md-1">{{ info.count }}</div>
<div class="col-md-11">
<button class="btn btn-sm btn-primary"
data-toggle="modal"
data-target="#view-participants">View participants</button>
data-target="#{{ info.id }}">View</button>
</div>
</div>
</div>
</div>
{% endfor %}

<div class="row mb-1">
<div class="col-md-3">Description:</div>
<div class="col-md-9">{{ event.description }}</div>
</div>

</div>
</div>
{% include 'console/event_management_manage_dataset.html' %}

{% for info in applicant_info %}
<div class="modal fade"
id="view-participants"
tabindex="-1"
role="dialog"
aria-labelledby="view-participants-modal"
aria-hidden="true">
id="{{ info.id }}"
tabindex="-1"
role="dialog"
aria-labelledby="view-{{ info.id }}-modal"
aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Participants</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<h5 class="modal-title">{{ info.title }}</h5>
<button type="button"
class="close"
data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
{% include 'events/event_entries.html' %}
{% include 'events/event_applications.html' %}
</div>
</div>
</div>
{% endfor %}

{% endblock %}
83 changes: 65 additions & 18 deletions physionet-django/console/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from django.utils import timezone
from django.core.exceptions import PermissionDenied
from events.forms import EventAgreementForm, EventDatasetForm
from events.models import Event, EventAgreement, EventDataset
from events.models import Event, EventAgreement, EventDataset, EventApplication
from notification.models import News
from physionet.forms import set_saved_fields_cookie
from physionet.middleware.maintenance import ServiceUnavailable
Expand Down Expand Up @@ -2976,7 +2976,7 @@ def event_archive(request):
})


@permission_required('user.view_all_events', raise_exception=True)
@permission_required("user.view_all_events", raise_exception=True)
def event_management(request, event_slug):
"""
Admin page for managing an individual Event.
Expand All @@ -2985,41 +2985,88 @@ def event_management(request, event_slug):

# handle the add dataset form(s)
if request.method == "POST":
if 'add-event-dataset' in request.POST.keys():
if "add-event-dataset" in request.POST.keys():
event_dataset_form = EventDatasetForm(request.POST)
if event_dataset_form.is_valid():
if selected_event.datasets.filter(
dataset=event_dataset_form.cleaned_data['dataset'],
access_type=event_dataset_form.cleaned_data['access_type'],
is_active=True).count() == 0:
active_datasets = selected_event.datasets.filter(
dataset=event_dataset_form.cleaned_data["dataset"],
access_type=event_dataset_form.cleaned_data["access_type"],
is_active=True)
if active_datasets.count() == 0:
event_dataset_form.instance.event = selected_event
event_dataset_form.save()
messages.success(request, "The dataset has been added to the event.")
messages.success(
request, "The dataset has been added to the event."
)
else:
messages.error(request, "The dataset has already been added to the event.")
messages.error(
request, "The dataset has already been added to the event."
)
else:
messages.error(request, event_dataset_form.errors)

return redirect('event_management', event_slug=event_slug)
elif 'remove-event-dataset' in request.POST.keys():
event_dataset_id = request.POST['remove-event-dataset']
return redirect("event_management", event_slug=event_slug)
elif "remove-event-dataset" in request.POST.keys():
event_dataset_id = request.POST["remove-event-dataset"]
event_dataset = get_object_or_404(EventDataset, pk=event_dataset_id)
event_dataset.revoke_dataset_access()
messages.success(request, "The dataset has been removed from the event.")

return redirect('event_management', event_slug=event_slug)
return redirect("event_management", event_slug=event_slug)
else:
event_dataset_form = EventDatasetForm()

participants = selected_event.participants.all()
pending_applications = selected_event.applications.filter(
status=EventApplication.EventApplicationStatus.WAITLISTED
)
rejected_applications = selected_event.applications.filter(
status=EventApplication.EventApplicationStatus.NOT_APPROVED
)
withdrawn_applications = selected_event.applications.filter(
status=EventApplication.EventApplicationStatus.WITHDRAWN
)

event_datasets = selected_event.datasets.filter(is_active=True)
applicant_info = [
{
"id": "participants",
"title": "Total participants:",
"count": len(participants),
"objects": participants,
},
{
"id": "pending_applications",
"title": "Pending applications:",
"count": len(pending_applications),
"objects": pending_applications,
},
{
"id": "rejected_applications",
"title": "Rejected applications:",
"count": len(rejected_applications),
"objects": rejected_applications,
},
{
"id": "withdrawn_applications",
"title": "Withdrawn applications:",
"count": len(withdrawn_applications),
"objects": withdrawn_applications,
},
]

return render(
request,
'console/event_management.html',
"console/event_management.html",
{
'event': selected_event,
'event_dataset_form': event_dataset_form,
'event_datasets': event_datasets,
})
"event": selected_event,
"event_dataset_form": event_dataset_form,
"event_datasets": event_datasets,
"applicant_info": applicant_info,
"participants": participants,
},
)



@permission_required('events.add_eventagreement', raise_exception=True)
Expand Down
36 changes: 36 additions & 0 deletions physionet-django/events/templates/events/event_applications.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{% load participation_status %}
<div class="tab-content" id="nav-tabContent">
<div class="tab-pane fade show active" id="{{ info.id }}" role="tabpanel" aria-labelledby="{{ option.id }}-tab">
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th>Username</th>
<th>Full name</th>
<th>Email</th>
<th>Credentialed</th>
<th>Cohost</th>
</tr>
</thead>
<tbody>
{% for object in info.objects %}
<tr>
<td>{{ object.user.username }}</td>
<td>{{ object.user.get_full_name }}</td>
<td>{{ object.user.email }}</td>
<td>{{ object.comment_to_applicant }}</td>
<td>{{ object.decision_datetime | date }}</td>
<td>
{% if object.is_cohost %}
<input type="checkbox" name="toggle-cohost-status" event-slug="{{ event.slug }}" value="{{ object.id }}" disabled checked>
{% else %}
<input type="checkbox" name="toggle-cohost-status" event-slug="{{ event.slug }}" value="{{ object.id }}" disabled>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
65 changes: 35 additions & 30 deletions physionet-django/events/templates/events/event_entries.html
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th>Username</th>
<th>Full name</th>
<th>Email</th>
<th>Credentialed</th>
<th>Cohost</th>
</tr>
</thead>
<tbody>
{% for participant in event.participants.all %}
<tr>
<td>{{ participant.user.username }}</td>
<td>{{ participant.user.get_full_name }}</td>
<td>{{ participant.user.email }}</td>
<td>{{ participant.user.get_credentialing_status }}</td>
<td>
{% if participant.is_cohost %}
<input type="checkbox" name="toggle-cohost-status" event-slug="{{ event.slug }}" value="{{ participant.id }}" disabled checked>
{% else %}
<input type="checkbox" name="toggle-cohost-status" event-slug="{{ event.slug }}" value="{{ participant.id }}" disabled>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% load participation_status %}
<div class="tab-content" id="nav-tabContent">
<div class="tab-pane fade show active" id="active-participant" role="tabpanel" aria-labelledby="active-participant-tab">
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th>Username</th>
<th>Full name</th>
<th>Email</th>
<th>Credentialed</th>
<th>Cohost</th>
</tr>
</thead>
<tbody>
{% for participant in event.participants.all %}
<tr>
<td>{{ participant.user.username }}</td>
<td>{{ participant.user.get_full_name }}</td>
<td>{{ participant.user.email }}</td>
<td>{{ participant.user.is_credentialed }}</td>
<td>
{% if participant.is_cohost %}
<input type="checkbox" name="toggle-cohost-status" event-slug="{{ event.slug }}" value="{{ participant.id }}" disabled checked>
{% else %}
<input type="checkbox" name="toggle-cohost-status" event-slug="{{ event.slug }}" value="{{ participant.id }}" disabled>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
26 changes: 17 additions & 9 deletions physionet-django/events/templates/events/event_home.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ <h3>{{ event.title }}</h3>
{% if event.host == user %}
<small>Share the class code: {{ url_prefix }}{% url 'event_detail' event.slug %} </small><br>
</p>
<button class="btn btn-sm btn-primary" data-toggle ="modal" data-target="#add-participant-modal-{{ event.id }}">View participants</button>
<button class="btn btn-sm btn-primary" data-toggle ="modal" data-target="#participants-modal-{{ event.id }}">View participants</button>
<button class="btn btn-sm btn-primary" data-toggle ="modal" data-target="#pending_applications-modal-{{ event.id }}">Pending Applications</button>
<button class="btn btn-sm btn-primary" data-toggle ="modal" data-target="#rejected_applications-modal-{{ event.id }}">Rejected Applications</button>
<button class="btn btn-sm btn-primary" data-toggle ="modal" data-target="#withdrawn_applications-modal-{{ event.id }}">Withdrawn Applications</button>
<a class="btn btn-sm btn-secondary" href="{% url 'update_event' event.slug %}" data-form-url="{% url 'update_event' event.slug %}" >Edit Event</a>
{% endif %}

Expand All @@ -100,22 +103,25 @@ <h3>{{ event.title }}</h3>
</div>
<br>
{% if events_active %}
{% for event in events_active %}
<div class="modal fade" id="add-participant-modal-{{ event.id }}" tabindex="-1" role="dialog" aria-labelledby="add-participant-modal" aria-hidden="true">
{% for event in events_active %}
{% for info in event_details|get_applicant_info:event.id %}
<div class="modal fade" id="{{ info.id }}-modal-{{ event.id }}" tabindex="-1" role="dialog" aria-labelledby="{{ info.id }}-modal" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Participants</h5>
<h5 class="modal-title">{{ info.title }}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
{% include 'events/event_entries.html' %}
{% include 'events/event_applications.html' %}
</div>
</div>
</div>
{% endfor %}
{% endfor %}
{% endif %}


<!-- Past events -->

Expand Down Expand Up @@ -153,7 +159,7 @@ <h3>{{ event.title }}</h3>
{% if event.host == user %}
<small>Share the class code: {{ url_prefix }}{% url 'event_detail' event.slug %} </small><br>
</p>
<button class="btn btn-sm btn-primary" data-toggle ="modal" data-target="#add-participant-modal-{{ event.id }}">View participants</button>
<button class="btn btn-sm btn-primary" data-toggle ="modal" data-target="#participants-modal-{{ event.id }}">View participants</button>
<a class="btn btn-sm btn-secondary" href="{% url 'update_event' event.slug %}" data-form-url="{% url 'update_event' event.slug %}" >Edit Event</a>
{% endif %}

Expand All @@ -169,20 +175,22 @@ <h3>{{ event.title }}</h3>
<br>
{% if events_past %}
{% for event in events_past %}
<div class="modal fade" id="add-participant-modal-{{ event.id }}" tabindex="-1" role="dialog" aria-labelledby="add-participant-modal" aria-hidden="true">
{% for info in event_details|get_applicant_info:event.id %}
<div class="modal fade" id="{{ info.id }}-modal-{{ event.id }}" tabindex="-1" role="dialog" aria-labelledby="{{ info.id }}-modal" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Participants</h5>
<h5 class="modal-title">{{ info.title }}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
{% include 'events/event_entries.html' %}
{% include 'events/event_applications.html' %}
</div>
</div>
</div>
{% endfor %}
{% endfor %}
{% endif %}
</div>
{% endblock %}
Expand Down
Loading

0 comments on commit bdfa393

Please sign in to comment.