From 555fa8fb7c114a7560c709cbf6df882964d5efa3 Mon Sep 17 00:00:00 2001 From: Daru13 Date: Thu, 22 Nov 2018 22:34:09 +0100 Subject: [PATCH 1/6] Adds effective enrol/unerol POST request on related button click. --- event/static/js/calendar.js | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/event/static/js/calendar.js b/event/static/js/calendar.js index 03c15dc..58f2572 100644 --- a/event/static/js/calendar.js +++ b/event/static/js/calendar.js @@ -787,12 +787,37 @@ class EventDetails { // On click, switch the subscription state // and update objects related to the perm count let event = this.event; - buttonNode.on("click", () => { - // TODO: subscribe or unsubscribe - event.subscribedByUser = ! event.subscribedByUser; - this.updatePermManagementArea(); - event.updatePermCounter(); + buttonNode.on("click", () => { + let goal = event.subscribedByUser ? "unenrol" : "enrol"; + let url = event.calendar.subscriptionURLFormat + .replace("999999", event.id); + + $.ajax(url, { + method: "POST", + dataType: "json", + + headers: { + "X-CSRFToken": event.calendar.csrfToken + }, + + data: { + "goal": goal + }, + + success: (jsonAnswer) => { + event.subscribedByUser = jsonAnswer.enrolled; + event.nbPerms = jsonAnswer.number; + + this.updatePermManagementArea(); + event.updatePermCounter(); + event.updateNodeStyle(); + }, + + error: (_, message) => { + alert(message); + } + }); }); return buttonNode; From 5da4c7050c376dad177088c80c83e394ed9b3bdf Mon Sep 17 00:00:00 2001 From: Daru13 Date: Thu, 22 Nov 2018 22:34:45 +0100 Subject: [PATCH 2/6] Updates the perm counter on perm area update. --- event/static/js/calendar.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/event/static/js/calendar.js b/event/static/js/calendar.js index 58f2572..a94db4d 100644 --- a/event/static/js/calendar.js +++ b/event/static/js/calendar.js @@ -770,7 +770,9 @@ class EventDetails { } updatePermManagementCounter () { - let permCounterNode = this.node.find(".cal-detail-perm-count"); + let permCounterNode = this.node + .find(".cal-detail-perm-count") + .html(`👤 ${this.event.nbPerms}/${this.event.maxNbPerms}`); if (this.event.minNbPerms > this.event.nbPerms) { permCounterNode.addClass("cal-perms-missing"); From 7a7254f3da0e32ad635072dff149a7976c947454 Mon Sep 17 00:00:00 2001 From: Daru13 Date: Thu, 22 Nov 2018 22:36:23 +0100 Subject: [PATCH 3/6] Put the event title on its own line (in the detail popup). --- event/static/css/calendar.css | 1 + 1 file changed, 1 insertion(+) diff --git a/event/static/css/calendar.css b/event/static/css/calendar.css index e4501dc..0426e9d 100644 --- a/event/static/css/calendar.css +++ b/event/static/css/calendar.css @@ -313,6 +313,7 @@ } #cal-container .cal-event-details .cal-detail-perm-title { + display: block; margin: 0 0 10px 0; } From 2699573913722a31ca75bc960a574130b3221edc Mon Sep 17 00:00:00 2001 From: Daru13 Date: Thu, 22 Nov 2018 22:42:09 +0100 Subject: [PATCH 4/6] Fix the title of the event (used to be the event id). --- event/templates/event/calendar.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/event/templates/event/calendar.html b/event/templates/event/calendar.html index 88426e3..620bfa6 100644 --- a/event/templates/event/calendar.html +++ b/event/templates/event/calendar.html @@ -35,7 +35,7 @@ {% for activity in day.list %}
{{ activity.id }} - {{ activity.id }} + {{ activity.title }} {{ activity.beginning | date:"j/m/Y H:i" }} {{ activity.end | date:"j/m/Y H:i" }} {{ activity.places.all | join:", " }} From 12534ff2da0d0e450e9ae2d96e2b163e6f74e047 Mon Sep 17 00:00:00 2001 From: Daru13 Date: Thu, 22 Nov 2018 22:42:31 +0100 Subject: [PATCH 5/6] Update the start and end date of the calendar (displayed era). --- event/templates/event/calendar.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/event/templates/event/calendar.html b/event/templates/event/calendar.html index 620bfa6..a0530f4 100644 --- a/event/templates/event/calendar.html +++ b/event/templates/event/calendar.html @@ -13,8 +13,8 @@