Skip to content

Commit

Permalink
Refactored option & status_options to info & applicant_info
Browse files Browse the repository at this point in the history
  • Loading branch information
Rutvikrj26 committed Nov 1, 2023
1 parent da3cee0 commit 0e6ca6a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 25 deletions.
16 changes: 8 additions & 8 deletions physionet-django/console/templates/console/event_management.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ <h1>{{ event.title }}</h1>
</div>
</div>

{% for option in status_options %}
{% for info in applicant_info %}
<div class="row mb-1">
<div class="col-md-3">{{ option.title }}</div>
<div class="col-md-3">{{ info.title }}</div>
<div class="col-md-9">
<div class="row mb-1">
<div class="col-md-1">{{ option.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="#{{ option.id }}">View</button>
data-target="#{{ info.id }}">View</button>
</div>
</div>
</div>
Expand All @@ -64,17 +64,17 @@ <h1>{{ event.title }}</h1>
</div>
{% include 'console/event_management_manage_dataset.html' %}

{% for option in status_options %}
{% for info in applicant_info %}
<div class="modal fade"
id="{{ option.id }}"
id="{{ info.id }}"
tabindex="-1"
role="dialog"
aria-labelledby="view-{{ option.id }}-modal"
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">{{ option.title }}</h5>
<h5 class="modal-title">{{ info.title }}</h5>
<button type="button"
class="close"
data-dismiss="modal"
Expand Down
4 changes: 2 additions & 2 deletions physionet-django/console/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3632,7 +3632,7 @@ def event_management(request, event_slug):
)

event_datasets = selected_event.datasets.filter(is_active=True)
status_options = [
applicant_info = [
{
"id": "participants",
"title": "Total participants:",
Expand Down Expand Up @@ -3666,7 +3666,7 @@ def event_management(request, event_slug):
"event": selected_event,
"event_dataset_form": event_dataset_form,
"event_datasets": event_datasets,
"status_options": status_options,
"applicant_info": applicant_info,
"participants": participants,
},
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% load participation_status %}
<div class="tab-content" id="nav-tabContent">
<div class="tab-pane fade show active" id="{{ option.id }}" role="tabpanel" aria-labelledby="{{ option.id }}-tab">
<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>
Expand All @@ -13,7 +13,7 @@
</tr>
</thead>
<tbody>
{% for object in option.objects %}
{% for object in info.objects %}
<tr>
<td>{{ object.user.username }}</td>
<td>{{ object.user.get_full_name }}</td>
Expand Down
12 changes: 6 additions & 6 deletions physionet-django/events/templates/events/event_home.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ <h3>{{ event.title }}</h3>
<br>
{% if events_active %}
{% for event in events_active %}
{% for option in event_details|get_status_options:event.id %}
<div class="modal fade" id="{{ option.id }}-modal-{{ event.id }}" tabindex="-1" role="dialog" aria-labelledby="{{ option.id }}-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">{{ option.title }}</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>
Expand Down Expand Up @@ -175,12 +175,12 @@ <h3>{{ event.title }}</h3>
<br>
{% if events_past %}
{% for event in events_past %}
{% for option in event_details|get_status_options:event.id %}
<div class="modal fade" id="{{ option.id }}-modal-{{ event.id }}" tabindex="-1" role="dialog" aria-labelledby="{{ option.id }}-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">{{ option.title }}</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>
Expand Down
16 changes: 9 additions & 7 deletions physionet-django/events/templatetags/participation_status.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
from django import template

from events.models import EventApplication
from project.authorization.events import has_access_to_event_dataset as has_access_to_event_dataset_func
from project.authorization.events import (
has_access_to_event_dataset as has_access_to_event_dataset_func,
)

register = template.Library()


@register.filter(name='is_participant')
@register.filter(name="is_participant")
def is_participant(user, event):
return event.participants.filter(user=user).exists()


@register.filter(name='is_on_waiting_list')
@register.filter(name="is_on_waiting_list")
def is_on_waiting_list(user, event):
return EventApplication.objects.filter(
user=user,
event=event,
status=EventApplication.EventApplicationStatus.WAITLISTED
status=EventApplication.EventApplicationStatus.WAITLISTED,
).exists()


@register.filter(name='has_access_to_event_dataset')
@register.filter(name="has_access_to_event_dataset")
def has_access_to_event_dataset(user, dataset):
return has_access_to_event_dataset_func(user, dataset)


@register.filter(name='get_status_options')
def get_status_options(event_details, event_id):
@register.filter(name="get_applicant_info")
def get_applicant_info(event_details, event_id):
return event_details[event_id]

0 comments on commit 0e6ca6a

Please sign in to comment.