Skip to content

Commit

Permalink
Fully working events functionality - serialized add/remove pending
Browse files Browse the repository at this point in the history
  • Loading branch information
Rutvikrj26 committed Nov 15, 2023
1 parent 93f1c8b commit ff7d936
Show file tree
Hide file tree
Showing 4 changed files with 272 additions and 254 deletions.
127 changes: 63 additions & 64 deletions physionet-django/console/templates/console/event_management.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,78 +2,77 @@
{% load static %}
{% block title %}Event Management{% endblock %}
{% block content %}
<h1>{{ event.title }}</h1>
<hr/>
<div class="card mb-3">
<div class="card-header">Event Details</div>
<div class="card-body">
<div class="row mb-1">
<div class="col-md-3">Event Organizer:</div>
<div class="col-md-9">
<a href="{% url 'user_management' event.host.username %}">{{ event.host.username }}</a>
</div>
</div>
<div class="row mb-1">
<div class="col-md-3">Category:</div>
<div class="col-md-9">{{ event.category }}</div>
</div>
<div class="row mb-1">
<div class="col-md-3">Created on:</div>
<div class="col-md-9">{{ event.added_datetime | date:"d M Y" }}</div>
</div>
<div class="row mb-1">
<div class="col-md-3">Start Date:</div>
<div class="col-md-9">{{ event.start_date | date:"d M Y" }}</div>
<h1>{{ event.title }}</h1>
<hr />
<div class="card mb-3">
<div class="card-header">Event Details</div>
<div class="card-body">
<div class="row mb-1">
<div class="col-md-3">Event Organizer:</div>
<div class="col-md-9">
<a href="{% url 'user_management' event.host.username %}">{{ event.host.username }}</a>
</div>
<div class="row mb-1">
<div class="col-md-3">End Date:</div>
<div class="col-md-9">{{ event.end_date | date:"d M Y" }}</div>
</div>
<div class="row mb-1">
<div class="col-md-3">Allowed Domains:</div>
<div class="col-md-9">
{% if event.allowed_domains %}
{{ event.allowed_domains }}
{% else %}
{% endif %}
</div>
</div>
<div class="row mb-1">
<div class="col-md-3">Category:</div>
<div class="col-md-9">{{ event.category }}</div>
</div>
<div class="row mb-1">
<div class="col-md-3">Created on:</div>
<div class="col-md-9">{{ event.added_datetime | date:"d M Y" }}</div>
</div>
<div class="row mb-1">
<div class="col-md-3">Start Date:</div>
<div class="col-md-9">{{ event.start_date | date:"d M Y" }}</div>
</div>
<div class="row mb-1">
<div class="col-md-3">End Date:</div>
<div class="col-md-9">{{ event.end_date | date:"d M Y" }}</div>
</div>
<div class="row mb-1">
<div class="col-md-3">Allowed Domains:</div>
<div class="col-md-9">
{% if event.allowed_domains %}
{{ event.allowed_domains }}
{% else %}
{% endif %}
</div>
<div class="row mb-1">
<div class="col-md-3">Total participants:</div>
<div class="col-md-9">
<div class="row mb-1">
<div class="col-md-1">{{ event.participants.count }}</div>
<div class="col-md-11">
<button class="btn btn-sm btn-primary"
data-toggle="modal"
data-target="#view-participants">View participants</button>
</div>
</div>
<div class="row mb-1">
<div class="col-md-3">Total participants:</div>
<div class="col-md-9">
<div class="row mb-1">
<div class="col-md-1">{{ event.participants.count }}</div>
<div class="col-md-11">
<button class="btn btn-sm btn-primary" data-toggle="modal" data-target="#view-participants">View
participants</button>
</div>
</div>
</div>
<div class="row mb-1">
<div class="col-md-3">Description:</div>
<div class="col-md-9">{{ event.description }}</div>
</div>
</div>
<div class="row mb-1">
<div class="col-md-3">Description:</div>
<div class="col-md-9">{{ event.description }}</div>
</div>
</div>
{% include 'console/event_management_manage_dataset.html' %}
<div class="modal fade"
id="view-participants"
tabindex="-1"
role="dialog"
aria-labelledby="view-participants-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">
<span aria-hidden="true">&times;</span>
</button>
</div>
{% include 'events/event_applications.html' %}
</div>
{% include 'console/event_management_manage_dataset.html' %}
<div class="modal fade" id="view-participants" tabindex="-1" role="dialog" aria-labelledby="view-participants-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">
<span aria-hidden="true">&times;</span>
</button>
</div>
{% include 'events/event_applications.html' %}
</div>
</div>
</div>
{% endblock %}

{% block local_js_bottom %}
<script src="{% static 'custom/js/resize-ck.js' %}"></script>
{% endblock %}
48 changes: 47 additions & 1 deletion physionet-django/events/templates/events/event_applications.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,50 @@
{% endfor %}
</tbody>
</table>
</div>
</div>

{% block local_js_bottom %}
<script>
$(document).ready(function () {
$('.manage-cohost').submit(function (e) {
e.preventDefault();
let $form = $(this);
$form.find('input[type="submit"]').prop('disabled', true);

let participant_id = e.target.participant.value;
let event_slug = e.target.event.value;
let submit_value = $form.find('input[type="submit"]').val();
let csrftoken = e.target.csrfmiddlewaretoken.value;
let url = e.target.action;

$.ajax({
url: url,
type: 'POST',
data: {
'participant_id': participant_id,
'event_slug': event_slug,
'csrfmiddlewaretoken': csrftoken,
'submit': submit_value
},
success: function (data) {

$form.find('input[type="submit"]').prop('disabled', false);

if (submit_value == 'Make cohost') {
$form.find('input[type="submit"]').val('Remove cohost');
$form.find('input[type="submit"]').removeClass('btn-primary');
$form.find('input[type="submit"]').addClass('btn-danger');
} else if (submit_value == 'Remove cohost') {
$form.find('input[type="submit"]').val('Make cohost');
$form.find('input[type="submit"]').removeClass('btn-danger');
$form.find('input[type="submit"]').addClass('btn-success');
}
},
error: function (data) {
$form.find('input[type="submit"]').prop('disabled', false);
}
});
});
});
</script>
{% endblock %}
Loading

0 comments on commit ff7d936

Please sign in to comment.