nodebb-plugin-onekite-calendar 2.0.74 → 2.0.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/admin.js +1 -0
- package/lib/api.js +22 -25
- package/lib/scheduler.js +1 -0
- package/package.json +1 -1
- package/public/admin.js +12 -2
package/lib/admin.js
CHANGED
|
@@ -89,6 +89,7 @@ admin.approveReservation = async function (req, res) {
|
|
|
89
89
|
r.pickupLat = String((req.body && req.body.pickupLat) || '').trim();
|
|
90
90
|
r.pickupLon = String((req.body && req.body.pickupLon) || '').trim();
|
|
91
91
|
r.approvedAt = Date.now();
|
|
92
|
+
r.paymentDeferred = !!(req.body && req.body.paymentDeferred);
|
|
92
93
|
|
|
93
94
|
try {
|
|
94
95
|
const approver = await user.getUserFields(req.uid, ['username']);
|
package/lib/api.js
CHANGED
|
@@ -778,7 +778,7 @@ api.getCapabilities = async function (req, res) {
|
|
|
778
778
|
isValidator: canMod,
|
|
779
779
|
canCreateSpecial: canSpecialC,
|
|
780
780
|
canDeleteSpecial: canSpecialD,
|
|
781
|
-
canCreateOuting: canReq,
|
|
781
|
+
canCreateOuting: canMod || canReq,
|
|
782
782
|
canCreateReservation: canReq,
|
|
783
783
|
specialEventCategoryCid: parseInt(settings && settings.specialEventCategoryId, 10) || 0,
|
|
784
784
|
});
|
|
@@ -938,7 +938,7 @@ api.getOutingDetails = async function (req, res) {
|
|
|
938
938
|
});
|
|
939
939
|
|
|
940
940
|
const participants = normalizeUidList(o.participants);
|
|
941
|
-
const canEditOuting = uid ? await canRequest(uid, settings, Date.now()) : false;
|
|
941
|
+
const canEditOuting = uid ? (canMod || await canRequest(uid, settings, Date.now())) : false;
|
|
942
942
|
const out = {
|
|
943
943
|
oid: o.oid,
|
|
944
944
|
title: o.title || '',
|
|
@@ -967,8 +967,7 @@ api.joinOuting = async function (req, res) {
|
|
|
967
967
|
const settings = await getSettings();
|
|
968
968
|
const uid = req.uid;
|
|
969
969
|
if (!uid) return res.status(401).json({ error: 'not-logged-in' });
|
|
970
|
-
|
|
971
|
-
const ok = await canRequest(uid, settings, Date.now());
|
|
970
|
+
const ok = (await canValidate(uid, settings)) || (await canRequest(uid, settings, Date.now()));
|
|
972
971
|
if (!ok) return res.status(403).json({ error: 'not-allowed' });
|
|
973
972
|
|
|
974
973
|
const oid = String(req.params.oid || '').replace(/^outing:/, '').trim();
|
|
@@ -999,8 +998,7 @@ api.leaveOuting = async function (req, res) {
|
|
|
999
998
|
const settings = await getSettings();
|
|
1000
999
|
const uid = req.uid;
|
|
1001
1000
|
if (!uid) return res.status(401).json({ error: 'not-logged-in' });
|
|
1002
|
-
|
|
1003
|
-
const ok = await canRequest(uid, settings, Date.now());
|
|
1001
|
+
const ok = (await canValidate(uid, settings)) || (await canRequest(uid, settings, Date.now()));
|
|
1004
1002
|
if (!ok) return res.status(403).json({ error: 'not-allowed' });
|
|
1005
1003
|
|
|
1006
1004
|
const oid = String(req.params.oid || '').replace(/^outing:/, '').trim();
|
|
@@ -1032,12 +1030,9 @@ api.createOuting = async function (req, res) {
|
|
|
1032
1030
|
if (!req.uid) return res.status(401).json({ error: 'not-logged-in' });
|
|
1033
1031
|
|
|
1034
1032
|
const startTs = toTs(req.body && req.body.start);
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
// requiring next-year group membership.
|
|
1039
|
-
const ok = await canRequest(req.uid, settings, Date.now());
|
|
1040
|
-
if (!ok) {
|
|
1033
|
+
const isValidatorForOuting = await canValidate(req.uid, settings);
|
|
1034
|
+
const canMakeOuting = isValidatorForOuting || (await canRequest(req.uid, settings, Date.now()));
|
|
1035
|
+
if (!canMakeOuting) {
|
|
1041
1036
|
return res.status(403).json({
|
|
1042
1037
|
error: 'not-allowed',
|
|
1043
1038
|
code: 'NOT_MEMBER',
|
|
@@ -1051,18 +1046,20 @@ api.createOuting = async function (req, res) {
|
|
|
1051
1046
|
return res.status(400).json({ error: 'bad-dates' });
|
|
1052
1047
|
}
|
|
1053
1048
|
|
|
1054
|
-
//
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1049
|
+
// Validators can create outings in the past (regularization); others cannot.
|
|
1050
|
+
if (!isValidatorForOuting) {
|
|
1051
|
+
try {
|
|
1052
|
+
const today0 = new Date();
|
|
1053
|
+
today0.setHours(0, 0, 0, 0);
|
|
1054
|
+
const today0ts = today0.getTime();
|
|
1055
|
+
if (startTs < today0ts) {
|
|
1056
|
+
return res.status(400).json({
|
|
1057
|
+
error: 'date-too-soon',
|
|
1058
|
+
message: "Impossible de créer pour une date passée.",
|
|
1059
|
+
});
|
|
1060
|
+
}
|
|
1061
|
+
} catch (e) {}
|
|
1062
|
+
}
|
|
1066
1063
|
|
|
1067
1064
|
const address = String((req.body && req.body.address) || '').trim();
|
|
1068
1065
|
const notes = String((req.body && req.body.notes) || '').trim();
|
|
@@ -1122,7 +1119,7 @@ api.deleteOuting = async function (req, res) {
|
|
|
1122
1119
|
api.updateOuting = async function (req, res) {
|
|
1123
1120
|
const settings = await getSettings();
|
|
1124
1121
|
if (!req.uid) return res.status(401).json({ error: 'not-logged-in' });
|
|
1125
|
-
const ok = await canRequest(req.uid, settings, Date.now());
|
|
1122
|
+
const ok = (await canValidate(req.uid, settings)) || (await canRequest(req.uid, settings, Date.now()));
|
|
1126
1123
|
if (!ok) return res.status(403).json({ error: 'not-allowed' });
|
|
1127
1124
|
|
|
1128
1125
|
const oid = String(req.params.oid || '').replace(/^outing:/, '').trim();
|
package/lib/scheduler.js
CHANGED
|
@@ -224,6 +224,7 @@ async function processAwaitingPayment(preIds, preReservations) {
|
|
|
224
224
|
const rid = ids[i];
|
|
225
225
|
const r = reservations[i];
|
|
226
226
|
if (!r || r.status !== 'awaiting_payment') continue;
|
|
227
|
+
if (r.paymentDeferred) continue;
|
|
227
228
|
|
|
228
229
|
const approvedAt = parseInt(r.approvedAt || r.validatedAt || 0, 10) || 0;
|
|
229
230
|
if (!approvedAt) continue;
|
package/package.json
CHANGED
package/public/admin.js
CHANGED
|
@@ -838,6 +838,10 @@ define('admin/plugins/calendar-onekite', ['alerts', 'bootbox'], function (alerts
|
|
|
838
838
|
<label class="form-label">Heure de récupération</label>
|
|
839
839
|
<select class="form-select" id="onekite-pickup-time">${opts}</select>
|
|
840
840
|
</div>
|
|
841
|
+
<div class="form-check mb-2">
|
|
842
|
+
<input class="form-check-input" type="checkbox" id="onekite-payment-deferred" />
|
|
843
|
+
<label class="form-check-label" for="onekite-payment-deferred">Paiement différé <span class="text-muted" style="font-size:12px;">(pas d'annulation automatique)</span></label>
|
|
844
|
+
</div>
|
|
841
845
|
<div class="text-muted" style="font-size:12px;">Ces infos seront appliquées aux ${rids.length} demandes sélectionnées.</div>
|
|
842
846
|
`;
|
|
843
847
|
const dlg = bootbox.dialog({
|
|
@@ -856,8 +860,9 @@ define('admin/plugins/calendar-onekite', ['alerts', 'bootbox'], function (alerts
|
|
|
856
860
|
const pickupTime = (document.getElementById('onekite-pickup-time')?.value || '').trim();
|
|
857
861
|
const pickupLat = (document.getElementById('onekite-pickup-lat')?.value || '').trim();
|
|
858
862
|
const pickupLon = (document.getElementById('onekite-pickup-lon')?.value || '').trim();
|
|
863
|
+
const paymentDeferred = !!(document.getElementById('onekite-payment-deferred')?.checked);
|
|
859
864
|
for (const rr of rids) {
|
|
860
|
-
await approve(rr, { pickupAddress, notes, pickupTime, pickupLat, pickupLon });
|
|
865
|
+
await approve(rr, { pickupAddress, notes, pickupTime, pickupLat, pickupLon, paymentDeferred });
|
|
861
866
|
}
|
|
862
867
|
showAlert('success', `${rids.length} demande(s) validée(s).`);
|
|
863
868
|
await refreshPending();
|
|
@@ -1010,6 +1015,10 @@ define('admin/plugins/calendar-onekite', ['alerts', 'bootbox'], function (alerts
|
|
|
1010
1015
|
<label class="form-label">Heure de récupération</label>
|
|
1011
1016
|
<select class="form-select" id="onekite-pickup-time">${opts}</select>
|
|
1012
1017
|
</div>
|
|
1018
|
+
<div class="form-check mb-2">
|
|
1019
|
+
<input class="form-check-input" type="checkbox" id="onekite-payment-deferred" />
|
|
1020
|
+
<label class="form-check-label" for="onekite-payment-deferred">Paiement différé <span class="text-muted" style="font-size:12px;">(pas d'annulation automatique)</span></label>
|
|
1021
|
+
</div>
|
|
1013
1022
|
`;
|
|
1014
1023
|
|
|
1015
1024
|
const dlg = bootbox.dialog({
|
|
@@ -1028,7 +1037,8 @@ define('admin/plugins/calendar-onekite', ['alerts', 'bootbox'], function (alerts
|
|
|
1028
1037
|
const pickupTime = (document.getElementById('onekite-pickup-time')?.value || '').trim();
|
|
1029
1038
|
const pickupLat = (document.getElementById('onekite-pickup-lat')?.value || '').trim();
|
|
1030
1039
|
const pickupLon = (document.getElementById('onekite-pickup-lon')?.value || '').trim();
|
|
1031
|
-
|
|
1040
|
+
const paymentDeferred = !!(document.getElementById('onekite-payment-deferred')?.checked);
|
|
1041
|
+
await approve(rid, { pickupAddress, notes, pickupTime, pickupLat, pickupLon, paymentDeferred });
|
|
1032
1042
|
if (rowEl && rowEl.parentNode) rowEl.parentNode.removeChild(rowEl);
|
|
1033
1043
|
showAlert('success', 'Demande validée.');
|
|
1034
1044
|
await refreshPending();
|