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

Event: Allow host to add cohosts #1925

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
fe098ad
use buttons to create/remove cohosts
superryeti Mar 8, 2023
6cbf544
add view to manage cohost
superryeti Mar 8, 2023
0069751
implement the make cohost on templates
superryeti Mar 8, 2023
f543b35
only allow to add cohost to active event
superryeti Mar 8, 2023
de11f3e
send email to host,cohost
superryeti Mar 10, 2023
2be3b50
addressed comments - made the template more consistent & fixed the is…
Rutvikrj26 Oct 11, 2023
a5d1ef0
Removed string based email triggers - now using boolean based on data…
Rutvikrj26 Nov 8, 2023
468b1b1
fixed multiple return statements with one error message
Rutvikrj26 Nov 8, 2023
27cdb06
fixed the double equal issue
Rutvikrj26 Nov 8, 2023
85245f2
Fully working events functionality - serialized add/remove pending
Rutvikrj26 Nov 15, 2023
55df121
made the events urls more restful
Rutvikrj26 Nov 15, 2023
efb84cb
WIP - making the update logic more robust by removing strings
Rutvikrj26 Nov 20, 2023
14091e9
WIP - making the update logic more robust by removing strings
Rutvikrj26 Nov 22, 2023
1691e6a
Replaced string to use IntEnum - Ajax button update pendig
Rutvikrj26 Nov 22, 2023
f0514b8
Issue with double request
Rutvikrj26 Nov 23, 2023
fc4599c
Implemented the complete refactoring to remove the string based logic.
Rutvikrj26 Nov 23, 2023
1e2296a
Fixed rebasing issues
Rutvikrj26 Nov 29, 2023
7b02e06
fixing styling issues
Rutvikrj26 Nov 29, 2023
3a16271
Fixing codebase based on Karol's comments
Rutvikrj26 Dec 5, 2023
d57c0a6
Merge branch 'dev' into au/event/feature/add_cohosts
Rutvikrj26 Jan 9, 2024
dd8dcc4
Updated the methods to PUT & DELETE
Rutvikrj26 Jan 15, 2024
38f386d
Adding other methods for Testing
Rutvikrj26 Jan 16, 2024
77225a7
Fully working event-cohost feature.
Rutvikrj26 Jan 16, 2024
8e7813b
added individual endpointd for the cohost functionality
Rutvikrj26 Jan 24, 2024
f62a2c9
added login_required decorators to the views
Rutvikrj26 Jan 24, 2024
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
139 changes: 67 additions & 72 deletions physionet-django/console/templates/console/event_management.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,90 +2,85 @@
{% 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>
</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>
<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">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>

{% for info in applicant_info %}
<div class="row mb-1">
<div class="col-md-3">{{ info.title }}</div>
<div class="col-md-9">
<div class="row mb-1">
<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="#{{ info.id }}">View</button>
</div>
{% for info in applicant_info %}
<div class="row mb-1">
<div class="col-md-3">{{ info.title }}</div>
<div class="col-md-9">
<div class="row mb-1">
<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="#{{ info.id }}">View</button>
</div>
</div>
</div>
{% endfor %}
</div>
{% endfor %}

<div class="row mb-1">
<div class="col-md-3">Description:</div>
<div class="col-md-9">{{ event.description }}</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>
{% include 'console/event_management_manage_dataset.html' %}

{% for info in applicant_info %}
<div class="modal fade"
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">{{ 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_applications.html' %}
{% for info in applicant_info %}
<div class="modal fade" 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">{{ 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_applications.html' %}
</div>
</div>
{% endfor %}
</div>
{% endfor %}

{% endblock %}

{% block local_js_bottom %}
<script src="{% static 'custom/js/resize-ck.js' %}"></script>
{% endblock %}
4 changes: 3 additions & 1 deletion physionet-django/console/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,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, EventApplication
from events.models import Event, EventAgreement, EventDataset, EventApplication, CohostStatus
from notification.models import News
from physionet.forms import set_saved_fields_cookie
from physionet.middleware.maintenance import ServiceUnavailable
Expand Down Expand Up @@ -3109,6 +3109,7 @@ def event_management(request, event_slug):
else:
event_dataset_form = EventDatasetForm()

cohost_status = {member: value.value for member, value in CohostStatus.__members__.items()}
participants = selected_event.participants.all()
pending_applications = selected_event.applications.filter(
status=EventApplication.EventApplicationStatus.WAITLISTED
Expand Down Expand Up @@ -3157,6 +3158,7 @@ def event_management(request, event_slug):
"event_datasets": event_datasets,
"applicant_info": applicant_info,
"participants": participants,
"cohostStatus": cohost_status,
},
)

Expand Down
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 %}
Rutvikrj26 marked this conversation as resolved.
Show resolved Hide resolved
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 %}
Loading
Loading