Skip to content

Commit

Permalink
Re-enable HTML in registration status message (#3617)
Browse files Browse the repository at this point in the history
* Re-enable HTML in registration status message

* Strip HTML tags in CalendarJS

* Enable overriding all event status messages in admin
  • Loading branch information
ColonelPhantom authored Apr 10, 2024
1 parent 743ab0b commit 60d9441
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
19 changes: 19 additions & 0 deletions website/events/admin/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,26 @@ class EventAdmin(DoNextModelAdmin):
"cancel_deadline",
"send_cancel_email",
"optional_registrations",
),
"classes": ("collapse",),
},
),
(
_("Registration status messages"),
{
"fields": (
"no_registration_message",
"registration_msg_optional",
"registration_msg_optional_registered",
"registration_msg_registered",
"registration_msg_open",
"registration_msg_full",
"registration_msg_waitinglist",
"registration_msg_will_open",
"registration_msg_expired",
"registration_msg_cancelled",
"registration_msg_cancelled_late",
"registration_msg_cancelled_final",
),
"classes": ("collapse",),
},
Expand Down
7 changes: 6 additions & 1 deletion website/events/static/events/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ function checkViewState(calendar) {
}
}

function strip(html){
let doc = new DOMParser().parseFromString(html, 'text/html');
return doc.body.textContent || "";
}

document.addEventListener('DOMContentLoaded', function () {
let lastKnownWidth = window.innerWidth;
const calendarEl = document.getElementById('calendar');
Expand Down Expand Up @@ -131,7 +136,7 @@ document.addEventListener('DOMContentLoaded', function () {
const regInfoElem = document.createElement('div');
regInfoElem.classList.add('mt-2', 'fc-title');
regInfoElem.title = event.extendedProps.registration_info;
regInfoElem.textContent = event.extendedProps.registration_info;
regInfoElem.textContent = strip(event.extendedProps.registration_info);
el.children[0].appendChild(regInfoElem);
}
},
Expand Down
4 changes: 2 additions & 2 deletions website/events/templates/events/event.html
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@ <h1 class="section-title">
<td>
<em>
{% if show_cancel_status %}
<p>{{ registration_status }} {{cancel_info}}</p>
<p>{{ registration_status | bleach }} {{cancel_info}}</p>
{% else %}
<p>{{ registration_status }}</p>
<p>{{ registration_status | bleach }}</p>
{% endif %}
</em>
</td>
Expand Down

0 comments on commit 60d9441

Please sign in to comment.