diff --git a/physionet-django/console/templates/console/event_management.html b/physionet-django/console/templates/console/event_management.html index 1ec760e079..8a1cd8bd58 100644 --- a/physionet-django/console/templates/console/event_management.html +++ b/physionet-django/console/templates/console/event_management.html @@ -72,7 +72,7 @@ - {% include 'events/event_entries.html' %} + {% include 'events/event_applications.html' %} diff --git a/physionet-django/events/templates/events/email/event_cohost_cohost_status_change.html b/physionet-django/events/templates/events/email/event_cohost_cohost_status_change.html index 03d9b0bc55..fbc4a5be78 100644 --- a/physionet-django/events/templates/events/email/event_cohost_cohost_status_change.html +++ b/physionet-django/events/templates/events/email/event_cohost_cohost_status_change.html @@ -8,7 +8,7 @@ Your Cohost access has been removed from the Event : {{ event_title }}. {% endif %} You can view further information about the event using the following link: -{{ url_prefix }}{{ event_url }} +{{ event_url }} Regards The {{ SITE_NAME }} Team diff --git a/physionet-django/events/templates/events/email/event_host_cohost_status_change.html b/physionet-django/events/templates/events/email/event_host_cohost_status_change.html index c22563e470..dcaa1e4a1f 100644 --- a/physionet-django/events/templates/events/email/event_host_cohost_status_change.html +++ b/physionet-django/events/templates/events/email/event_host_cohost_status_change.html @@ -6,8 +6,7 @@ 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. - -{{ url_prefix }}/events/ +{{ event_url }} Regards The {{ SITE_NAME }} Team diff --git a/physionet-django/events/templates/events/event_applications.html b/physionet-django/events/templates/events/event_applications.html new file mode 100644 index 0000000000..28c9ed6aa4 --- /dev/null +++ b/physionet-django/events/templates/events/event_applications.html @@ -0,0 +1,37 @@ +
+ + + + + + + + + + + + {% for participant in event.participants.all %} + + + + + + + + {% endfor %} + +
UsernameFull nameEmailCredentialedCohost
{{ participant.user.username }}{{ participant.user.get_full_name }}{{ participant.user.email }}{{ participant.user.is_credentialed }} + {% if not event.has_ended %} +
+ {% csrf_token %} + + + {% if participant.is_cohost %} + + {% else %} + + {% endif %} +
+ {% endif %} +
+
diff --git a/physionet-django/events/templates/events/event_home.html b/physionet-django/events/templates/events/event_home.html index 323215c857..c583fa6c7f 100644 --- a/physionet-django/events/templates/events/event_home.html +++ b/physionet-django/events/templates/events/event_home.html @@ -110,7 +110,7 @@ - {% include 'events/event_entries.html' %} + {% include 'events/event_applications.html' %} @@ -178,7 +178,7 @@ - {% include 'events/event_entries.html' %} + {% include 'events/event_applications.html' %} diff --git a/physionet-django/events/views.py b/physionet-django/events/views.py index 88d80ce721..d12584772d 100644 --- a/physionet-django/events/views.py +++ b/physionet-django/events/views.py @@ -247,7 +247,7 @@ def manage_co_hosts(request): """ user = request.user - if request.method == 'POST' and request.is_ajax(): + if request.method == 'POST' and request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest': participant_id = request.POST.get('participant_id') event_slug = request.POST.get('event_slug') @@ -269,10 +269,8 @@ def manage_co_hosts(request): return JsonResponse({'error': 'User is not a cohost of this event'}, status=403) participant.is_cohost = False participant.save() - # notify the cohost that their cohost permission has been removed notification.notify_event_cohost_cohost_status_change(request=request, cohost=participant.user, event=event, status='Remove cohost') - # notify the host that they have removed a cohost notification.notify_event_host_cohost_status_change(request=request, cohost=participant.user, event=event, status='Remove cohost') @@ -282,10 +280,8 @@ def manage_co_hosts(request): return JsonResponse({'error': 'User is already a cohost of this event'}, status=403) participant.is_cohost = True participant.save() - # notify the cohost that they have been added as a cohost for the event notification.notify_event_cohost_cohost_status_change(request=request, cohost=participant.user, event=event, status='Make cohost') - # notify the host that they have added a cohost for the event notification.notify_event_host_cohost_status_change(request=request, cohost=participant.user, event=event, status='Make cohost') diff --git a/physionet-django/notification/utility.py b/physionet-django/notification/utility.py index afaf6e5add..2c312714af 100644 --- a/physionet-django/notification/utility.py +++ b/physionet-django/notification/utility.py @@ -3,6 +3,7 @@ """ from email.utils import formataddr from functools import cache +import re from urllib import parse from django.conf import settings @@ -1006,7 +1007,7 @@ def notify_participant_event_decision(request, user, event, decision, comment_to send_mail(subject, body, settings.DEFAULT_FROM_EMAIL, [user.email], fail_silently=False) -def notify_event_cohost_cohost_status_change(request, cohost, event, status='Make cohost'): +def notify_event_cohost_cohost_status_change(request, cohost, event, status): """ Send email to co-host about their cohost status change for the event. """ @@ -1014,9 +1015,8 @@ def notify_event_cohost_cohost_status_change(request, cohost, event, status='Mak context = { 'name': cohost.get_full_name(), 'domain': get_current_site(request), - 'url_prefix': get_url_prefix(request), 'event_title': event.title, - 'event_url': reverse('event_detail', args=[event.slug]), + 'event_url': request.build_absolute_uri(reverse('event_detail', args=[event.slug])), 'status': status, 'SITE_NAME': settings.SITE_NAME, } @@ -1034,9 +1034,8 @@ def notify_event_host_cohost_status_change(request, cohost, event, status='Make 'host_name': event.host.get_full_name(), 'cohost_name': cohost.get_full_name(), 'domain': get_current_site(request), - 'url_prefix': get_url_prefix(request), 'event_title': event.title, - 'event_url': reverse('event_detail', args=[event.slug]), + 'event_url': request.build_absolute_uri(reverse('event_detail', args=[event.slug])), 'status': status, 'SITE_NAME': settings.SITE_NAME, }