Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Context processors workflow testing #15

Open
wants to merge 15 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_entries.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 %}
12 changes: 12 additions & 0 deletions physionet-django/events/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from enum import IntEnum
from django.db import models, transaction
from django.utils.crypto import get_random_string
from django.utils import timezone
Expand All @@ -10,6 +11,11 @@
from project.validators import validate_version, validate_slug


class cohostStatus(IntEnum):
MAKE_COHOST = 0
REMOVE_COHOST = 1


class Event(models.Model):
"""
Captures information on events such as datathons, workshops and classes.
Expand Down Expand Up @@ -59,6 +65,12 @@ def get_cohosts(self):
"""
return self.participants.filter(is_cohost=True)

def has_ended(self):
"""
Returns true if the event has ended.
"""
return self.end_date < timezone.now().date()


class EventParticipant(models.Model):
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% load i18n %}{% autoescape off %}{% filter wordwrap:70 %}
Dear {{ name }},
{% if status == True %}
You have been added as Cohost to the Event : {{ event_title }}.

You can now manage the event participants from your events dashboard.
{% elif status == False %}
Your Cohost access has been removed from the Event : {{ event_title }}.
{% endif %}
You can view further information about the event using the following link:
{{ event_url }}

Regards
The {{ SITE_NAME }} Team
{% endfilter %}{% endautoescape %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% load i18n %}{% autoescape off %}{% filter wordwrap:70 %}
Dear {{ host_name }},

{% if status == True %}
You have provided {{ cohost_name }} Cohost access to the Event : {{ event_title }}.
{% elif status == False %}
You have removed {{ cohost_name }}'s Cohost access from the Event : {{ event_title }}.
{% endif %}
If this was done by mistake, you can change the cohost status by visiting the events dashboard.
{{ event_url }}

Regards
The {{ SITE_NAME }} Team
{% endfilter %}{% endautoescape %}
87 changes: 87 additions & 0 deletions physionet-django/events/templates/events/event_applications.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<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 not event.has_ended %}
<form class="manage-cohost" action="{% url 'manage_co_hosts' event.slug %}"
data-cohost-status="{{ participant.is_cohost }}">
{% csrf_token %}
<input type="text" name="event" value="{{ event.slug }}" hidden>
<input type="text" name="participant" value="{{ participant.id }}" hidden>
{% if participant.is_cohost %}
<input type="submit" value="Remove cohost" data-action="{{ cohostStatus.REMOVE_COHOST }}"
class="btn btn-sm btn-danger">
{% else %}
<input type="submit" value="Make cohost" data-action="{{ cohostStatus.MAKE_COHOST }}"
class="btn btn-sm btn-success">
{% endif %}
</form>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</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 action = $form.find('input[type="submit"]').attr('data-action');
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,
'action': action
},
success: function (data) {

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

if ($form.attr('data-action') == '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 ($form.attr('data-action') == '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 %}
30 changes: 0 additions & 30 deletions physionet-django/events/templates/events/event_entries.html

This file was deleted.

Loading