mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
fix: mutations issues + trail + next canary bump
This commit is contained in:
parent
7583752362
commit
5cbf9f809c
11 changed files with 205 additions and 121 deletions
|
|
@ -18,6 +18,9 @@ const CollectionAdminEditsArea = (props: any) => {
|
||||||
// reload the page
|
// reload the page
|
||||||
router.refresh();
|
router.refresh();
|
||||||
router.push(getUriWithOrg(props.orgslug, "/collections"));
|
router.push(getUriWithOrg(props.orgslug, "/collections"));
|
||||||
|
|
||||||
|
// refresh page (FIX for Next.js BUG)
|
||||||
|
window.location.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,9 @@ function NewCollection(params: any) {
|
||||||
router.prefetch(getUriWithOrg(orgslug, "/collections"));
|
router.prefetch(getUriWithOrg(orgslug, "/collections"));
|
||||||
router.push(getUriWithOrg(orgslug, "/collections"));
|
router.push(getUriWithOrg(orgslug, "/collections"));
|
||||||
router.refresh();
|
router.refresh();
|
||||||
|
|
||||||
|
// refresh page (FIX for Next.js BUG)
|
||||||
|
window.location.reload();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,10 @@ export function MarkStatus(props: { activityid: string, course: any, orgslug: st
|
||||||
async function markActivityAsCompleteFront() {
|
async function markActivityAsCompleteFront() {
|
||||||
const trail = await markActivityAsComplete(props.orgslug, props.courseid, props.activityid);
|
const trail = await markActivityAsComplete(props.orgslug, props.courseid, props.activityid);
|
||||||
router.refresh();
|
router.refresh();
|
||||||
|
|
||||||
|
// refresh page (FIX for Next.js BUG)
|
||||||
|
window.location.reload();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,9 @@ const CourseClient = (props: any) => {
|
||||||
await startCourse("course_" + courseid, orgslug);
|
await startCourse("course_" + courseid, orgslug);
|
||||||
revalidateTags(['courses']);
|
revalidateTags(['courses']);
|
||||||
router.refresh();
|
router.refresh();
|
||||||
|
|
||||||
|
// refresh page (FIX for Next.js BUG)
|
||||||
|
window.location.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function quitCourse() {
|
async function quitCourse() {
|
||||||
|
|
@ -32,6 +35,9 @@ const CourseClient = (props: any) => {
|
||||||
// Mutate course
|
// Mutate course
|
||||||
revalidateTags(['courses']);
|
revalidateTags(['courses']);
|
||||||
router.refresh();
|
router.refresh();
|
||||||
|
|
||||||
|
// refresh page (FIX for Next.js BUG)
|
||||||
|
window.location.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,9 @@ function OrganizationClient(props: any) {
|
||||||
revalidateTags(['organizations']);
|
revalidateTags(['organizations']);
|
||||||
router.refresh();
|
router.refresh();
|
||||||
|
|
||||||
|
// refresh page (FIX for Next.js BUG)
|
||||||
|
window.location.reload();
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,9 @@ function CreateCourseModal({ closeModal, orgslug }: any) {
|
||||||
if (status.org_id == orgId) {
|
if (status.org_id == orgId) {
|
||||||
closeModal();
|
closeModal();
|
||||||
router.refresh();
|
router.refresh();
|
||||||
|
|
||||||
|
// refresh page (FIX for Next.js BUG)
|
||||||
|
window.location.reload();
|
||||||
} else {
|
} else {
|
||||||
alert("Error creating course, please see console logs");
|
alert("Error creating course, please see console logs");
|
||||||
console.log(status);
|
console.log(status);
|
||||||
|
|
|
||||||
174
front/package-lock.json
generated
174
front/package-lock.json
generated
|
|
@ -26,7 +26,7 @@
|
||||||
"formik": "^2.2.9",
|
"formik": "^2.2.9",
|
||||||
"framer-motion": "^7.3.6",
|
"framer-motion": "^7.3.6",
|
||||||
"lucide-react": "^0.248.0",
|
"lucide-react": "^0.248.0",
|
||||||
"next": "^13.4.7-canary.4",
|
"next": "^13.4.8-canary.4",
|
||||||
"re-resizable": "^6.9.9",
|
"re-resizable": "^6.9.9",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-beautiful-dnd": "^13.1.1",
|
"react-beautiful-dnd": "^13.1.1",
|
||||||
|
|
@ -2123,9 +2123,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/env": {
|
"node_modules/@next/env": {
|
||||||
"version": "13.4.7",
|
"version": "13.4.8-canary.4",
|
||||||
"resolved": "https://registry.npmjs.org/@next/env/-/env-13.4.7.tgz",
|
"resolved": "https://registry.npmjs.org/@next/env/-/env-13.4.8-canary.4.tgz",
|
||||||
"integrity": "sha512-ZlbiFulnwiFsW9UV1ku1OvX/oyIPLtMk9p/nnvDSwI0s7vSoZdRtxXNsaO+ZXrLv/pMbXVGq4lL8TbY9iuGmVw=="
|
"integrity": "sha512-C6riyNtIP+qE3Q1qIthEOprGm7h6LeMf1SjIUenhHyFLiPKLd0O4ltD1+AGhXw+bW3VFO26Wa9N2LHWpigdJtA=="
|
||||||
},
|
},
|
||||||
"node_modules/@next/eslint-plugin-next": {
|
"node_modules/@next/eslint-plugin-next": {
|
||||||
"version": "13.0.6",
|
"version": "13.0.6",
|
||||||
|
|
@ -2137,9 +2137,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-darwin-arm64": {
|
"node_modules/@next/swc-darwin-arm64": {
|
||||||
"version": "13.4.7",
|
"version": "13.4.8-canary.4",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.4.7.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.4.8-canary.4.tgz",
|
||||||
"integrity": "sha512-VZTxPv1b59KGiv/pZHTO5Gbsdeoxcj2rU2cqJu03btMhHpn3vwzEK0gUSVC/XW96aeGO67X+cMahhwHzef24/w==",
|
"integrity": "sha512-clQaivrVkk5g2VAjp0X5EElpgN/Xt62ZX9PNKPcnHSjA7ybWh5snlqfjYpaCwMVpZYvs/F042sT2MzIACRb9AQ==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
|
|
@ -2152,9 +2152,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-darwin-x64": {
|
"node_modules/@next/swc-darwin-x64": {
|
||||||
"version": "13.4.7",
|
"version": "13.4.8-canary.4",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.4.7.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.4.8-canary.4.tgz",
|
||||||
"integrity": "sha512-gO2bw+2Ymmga+QYujjvDz9955xvYGrWofmxTq7m70b9pDPvl7aDFABJOZ2a8SRCuSNB5mXU8eTOmVVwyp/nAew==",
|
"integrity": "sha512-NP73yfCTGlEyBdiL2LJo9qnCoEFN3shILxiiBEA3LwA9JNgG540yLNFEN2hTt+J1D+YDhsQhWWgg4Iln4qXrbw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
|
|
@ -2167,9 +2167,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-linux-arm64-gnu": {
|
"node_modules/@next/swc-linux-arm64-gnu": {
|
||||||
"version": "13.4.7",
|
"version": "13.4.8-canary.4",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.4.7.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.4.8-canary.4.tgz",
|
||||||
"integrity": "sha512-6cqp3vf1eHxjIDhEOc7Mh/s8z1cwc/l5B6ZNkOofmZVyu1zsbEM5Hmx64s12Rd9AYgGoiCz4OJ4M/oRnkE16/Q==",
|
"integrity": "sha512-HmIsfizzt1mv0Zoxq6c3snBvtSOIX7k8rc6Wm2Ta3valSjc54ZhylNyQOWD2wuE9ufVpn2n1AHFlhUE+APY+nQ==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
|
|
@ -2182,9 +2182,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-linux-arm64-musl": {
|
"node_modules/@next/swc-linux-arm64-musl": {
|
||||||
"version": "13.4.7",
|
"version": "13.4.8-canary.4",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.4.7.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.4.8-canary.4.tgz",
|
||||||
"integrity": "sha512-T1kD2FWOEy5WPidOn1si0rYmWORNch4a/NR52Ghyp4q7KyxOCuiOfZzyhVC5tsLIBDH3+cNdB5DkD9afpNDaOw==",
|
"integrity": "sha512-HJ1VyGSecFl+jKWLJ8iPrz7IEAbw+LMtUybIRepipWKUioTsSnh1jrnYY575KZVYPhFNRX6lvx5XXPTaZ5eYfQ==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
|
|
@ -2197,9 +2197,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-linux-x64-gnu": {
|
"node_modules/@next/swc-linux-x64-gnu": {
|
||||||
"version": "13.4.7",
|
"version": "13.4.8-canary.4",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.4.7.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.4.8-canary.4.tgz",
|
||||||
"integrity": "sha512-zaEC+iEiAHNdhl6fuwl0H0shnTzQoAoJiDYBUze8QTntE/GNPfTYpYboxF5LRYIjBwETUatvE0T64W6SKDipvg==",
|
"integrity": "sha512-VrzpVY/NO5uEvHhDfD8aXKY+Rr7YOQ9KKDQmeUvzeNi63fwhbRY7WasjNOSBp7AG53kWtiwL7uzuZvx6AMVJuA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
|
|
@ -2212,9 +2212,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-linux-x64-musl": {
|
"node_modules/@next/swc-linux-x64-musl": {
|
||||||
"version": "13.4.7",
|
"version": "13.4.8-canary.4",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.4.7.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.4.8-canary.4.tgz",
|
||||||
"integrity": "sha512-X6r12F8d8SKAtYJqLZBBMIwEqcTRvUdVm+xIq+l6pJqlgT2tNsLLf2i5Cl88xSsIytBICGsCNNHd+siD2fbWBA==",
|
"integrity": "sha512-qIODBX/0azVrHCcpakafyy/B40gYrjBXUtDo4tanfBQlyDgDDdY7R1JV1+vodLvCi/2/bnqtz7S9Bb0ZyMN19g==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
|
|
@ -2227,9 +2227,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-win32-arm64-msvc": {
|
"node_modules/@next/swc-win32-arm64-msvc": {
|
||||||
"version": "13.4.7",
|
"version": "13.4.8-canary.4",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.4.7.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.4.8-canary.4.tgz",
|
||||||
"integrity": "sha512-NPnmnV+vEIxnu6SUvjnuaWRglZzw4ox5n/MQTxeUhb5iwVWFedolPFebMNwgrWu4AELwvTdGtWjqof53AiWHcw==",
|
"integrity": "sha512-+sJasAcqz8XiX1sVEhc6fuNSVZMvQjC/L0pUJ5dzFXaAIPfH6s0c8Bx36F3c81C3KoF8UykWUp2IotXWUlJkQA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
|
|
@ -2242,9 +2242,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-win32-ia32-msvc": {
|
"node_modules/@next/swc-win32-ia32-msvc": {
|
||||||
"version": "13.4.7",
|
"version": "13.4.8-canary.4",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.4.7.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.4.8-canary.4.tgz",
|
||||||
"integrity": "sha512-6Hxijm6/a8XqLQpOOf/XuwWRhcuc/g4rBB2oxjgCMuV9Xlr2bLs5+lXyh8w9YbAUMYR3iC9mgOlXbHa79elmXw==",
|
"integrity": "sha512-DNjdyOH6i4A62cwR3GOpQpS21GPzz6r6KkjzuQP7A3q/lYQBULX4Jmr8iBm37Sr5o3PXEPI5owWcC6xsqOsduw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"ia32"
|
"ia32"
|
||||||
],
|
],
|
||||||
|
|
@ -2257,9 +2257,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-win32-x64-msvc": {
|
"node_modules/@next/swc-win32-x64-msvc": {
|
||||||
"version": "13.4.7",
|
"version": "13.4.8-canary.4",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.4.7.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.4.8-canary.4.tgz",
|
||||||
"integrity": "sha512-sW9Yt36Db1nXJL+mTr2Wo0y+VkPWeYhygvcHj1FF0srVtV+VoDjxleKtny21QHaG05zdeZnw2fCtf2+dEqgwqA==",
|
"integrity": "sha512-zsuSyWhNRXa8toC1Eu0RE9Ol4C006yXDvQc3AJ1vPzFj6ggibLhrmYImFOLV716VDwOj5oALHI0Lc5qMM0NZYQ==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
|
|
@ -6374,11 +6374,11 @@
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/next": {
|
"node_modules/next": {
|
||||||
"version": "13.4.7",
|
"version": "13.4.8-canary.4",
|
||||||
"resolved": "https://registry.npmjs.org/next/-/next-13.4.7.tgz",
|
"resolved": "https://registry.npmjs.org/next/-/next-13.4.8-canary.4.tgz",
|
||||||
"integrity": "sha512-M8z3k9VmG51SRT6v5uDKdJXcAqLzP3C+vaKfLIAM0Mhx1um1G7MDnO63+m52qPdZfrTFzMZNzfsgvm3ghuVHIQ==",
|
"integrity": "sha512-Dy5BOsaoXhxEoZ7ljZ/l+BUjh+5ODVMRSUV0AOXhzcDparLh0+AcZUyglaqANyh94hZoevod4ubkJDSPRYSHtQ==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@next/env": "13.4.7",
|
"@next/env": "13.4.8-canary.4",
|
||||||
"@swc/helpers": "0.5.1",
|
"@swc/helpers": "0.5.1",
|
||||||
"busboy": "1.6.0",
|
"busboy": "1.6.0",
|
||||||
"caniuse-lite": "^1.0.30001406",
|
"caniuse-lite": "^1.0.30001406",
|
||||||
|
|
@ -6394,15 +6394,15 @@
|
||||||
"node": ">=16.8.0"
|
"node": ">=16.8.0"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@next/swc-darwin-arm64": "13.4.7",
|
"@next/swc-darwin-arm64": "13.4.8-canary.4",
|
||||||
"@next/swc-darwin-x64": "13.4.7",
|
"@next/swc-darwin-x64": "13.4.8-canary.4",
|
||||||
"@next/swc-linux-arm64-gnu": "13.4.7",
|
"@next/swc-linux-arm64-gnu": "13.4.8-canary.4",
|
||||||
"@next/swc-linux-arm64-musl": "13.4.7",
|
"@next/swc-linux-arm64-musl": "13.4.8-canary.4",
|
||||||
"@next/swc-linux-x64-gnu": "13.4.7",
|
"@next/swc-linux-x64-gnu": "13.4.8-canary.4",
|
||||||
"@next/swc-linux-x64-musl": "13.4.7",
|
"@next/swc-linux-x64-musl": "13.4.8-canary.4",
|
||||||
"@next/swc-win32-arm64-msvc": "13.4.7",
|
"@next/swc-win32-arm64-msvc": "13.4.8-canary.4",
|
||||||
"@next/swc-win32-ia32-msvc": "13.4.7",
|
"@next/swc-win32-ia32-msvc": "13.4.8-canary.4",
|
||||||
"@next/swc-win32-x64-msvc": "13.4.7"
|
"@next/swc-win32-x64-msvc": "13.4.8-canary.4"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@opentelemetry/api": "^1.1.0",
|
"@opentelemetry/api": "^1.1.0",
|
||||||
|
|
@ -10055,9 +10055,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@next/env": {
|
"@next/env": {
|
||||||
"version": "13.4.7",
|
"version": "13.4.8-canary.4",
|
||||||
"resolved": "https://registry.npmjs.org/@next/env/-/env-13.4.7.tgz",
|
"resolved": "https://registry.npmjs.org/@next/env/-/env-13.4.8-canary.4.tgz",
|
||||||
"integrity": "sha512-ZlbiFulnwiFsW9UV1ku1OvX/oyIPLtMk9p/nnvDSwI0s7vSoZdRtxXNsaO+ZXrLv/pMbXVGq4lL8TbY9iuGmVw=="
|
"integrity": "sha512-C6riyNtIP+qE3Q1qIthEOprGm7h6LeMf1SjIUenhHyFLiPKLd0O4ltD1+AGhXw+bW3VFO26Wa9N2LHWpigdJtA=="
|
||||||
},
|
},
|
||||||
"@next/eslint-plugin-next": {
|
"@next/eslint-plugin-next": {
|
||||||
"version": "13.0.6",
|
"version": "13.0.6",
|
||||||
|
|
@ -10069,57 +10069,57 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@next/swc-darwin-arm64": {
|
"@next/swc-darwin-arm64": {
|
||||||
"version": "13.4.7",
|
"version": "13.4.8-canary.4",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.4.7.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.4.8-canary.4.tgz",
|
||||||
"integrity": "sha512-VZTxPv1b59KGiv/pZHTO5Gbsdeoxcj2rU2cqJu03btMhHpn3vwzEK0gUSVC/XW96aeGO67X+cMahhwHzef24/w==",
|
"integrity": "sha512-clQaivrVkk5g2VAjp0X5EElpgN/Xt62ZX9PNKPcnHSjA7ybWh5snlqfjYpaCwMVpZYvs/F042sT2MzIACRb9AQ==",
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
"@next/swc-darwin-x64": {
|
"@next/swc-darwin-x64": {
|
||||||
"version": "13.4.7",
|
"version": "13.4.8-canary.4",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.4.7.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.4.8-canary.4.tgz",
|
||||||
"integrity": "sha512-gO2bw+2Ymmga+QYujjvDz9955xvYGrWofmxTq7m70b9pDPvl7aDFABJOZ2a8SRCuSNB5mXU8eTOmVVwyp/nAew==",
|
"integrity": "sha512-NP73yfCTGlEyBdiL2LJo9qnCoEFN3shILxiiBEA3LwA9JNgG540yLNFEN2hTt+J1D+YDhsQhWWgg4Iln4qXrbw==",
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
"@next/swc-linux-arm64-gnu": {
|
"@next/swc-linux-arm64-gnu": {
|
||||||
"version": "13.4.7",
|
"version": "13.4.8-canary.4",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.4.7.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.4.8-canary.4.tgz",
|
||||||
"integrity": "sha512-6cqp3vf1eHxjIDhEOc7Mh/s8z1cwc/l5B6ZNkOofmZVyu1zsbEM5Hmx64s12Rd9AYgGoiCz4OJ4M/oRnkE16/Q==",
|
"integrity": "sha512-HmIsfizzt1mv0Zoxq6c3snBvtSOIX7k8rc6Wm2Ta3valSjc54ZhylNyQOWD2wuE9ufVpn2n1AHFlhUE+APY+nQ==",
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
"@next/swc-linux-arm64-musl": {
|
"@next/swc-linux-arm64-musl": {
|
||||||
"version": "13.4.7",
|
"version": "13.4.8-canary.4",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.4.7.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.4.8-canary.4.tgz",
|
||||||
"integrity": "sha512-T1kD2FWOEy5WPidOn1si0rYmWORNch4a/NR52Ghyp4q7KyxOCuiOfZzyhVC5tsLIBDH3+cNdB5DkD9afpNDaOw==",
|
"integrity": "sha512-HJ1VyGSecFl+jKWLJ8iPrz7IEAbw+LMtUybIRepipWKUioTsSnh1jrnYY575KZVYPhFNRX6lvx5XXPTaZ5eYfQ==",
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
"@next/swc-linux-x64-gnu": {
|
"@next/swc-linux-x64-gnu": {
|
||||||
"version": "13.4.7",
|
"version": "13.4.8-canary.4",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.4.7.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.4.8-canary.4.tgz",
|
||||||
"integrity": "sha512-zaEC+iEiAHNdhl6fuwl0H0shnTzQoAoJiDYBUze8QTntE/GNPfTYpYboxF5LRYIjBwETUatvE0T64W6SKDipvg==",
|
"integrity": "sha512-VrzpVY/NO5uEvHhDfD8aXKY+Rr7YOQ9KKDQmeUvzeNi63fwhbRY7WasjNOSBp7AG53kWtiwL7uzuZvx6AMVJuA==",
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
"@next/swc-linux-x64-musl": {
|
"@next/swc-linux-x64-musl": {
|
||||||
"version": "13.4.7",
|
"version": "13.4.8-canary.4",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.4.7.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.4.8-canary.4.tgz",
|
||||||
"integrity": "sha512-X6r12F8d8SKAtYJqLZBBMIwEqcTRvUdVm+xIq+l6pJqlgT2tNsLLf2i5Cl88xSsIytBICGsCNNHd+siD2fbWBA==",
|
"integrity": "sha512-qIODBX/0azVrHCcpakafyy/B40gYrjBXUtDo4tanfBQlyDgDDdY7R1JV1+vodLvCi/2/bnqtz7S9Bb0ZyMN19g==",
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
"@next/swc-win32-arm64-msvc": {
|
"@next/swc-win32-arm64-msvc": {
|
||||||
"version": "13.4.7",
|
"version": "13.4.8-canary.4",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.4.7.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.4.8-canary.4.tgz",
|
||||||
"integrity": "sha512-NPnmnV+vEIxnu6SUvjnuaWRglZzw4ox5n/MQTxeUhb5iwVWFedolPFebMNwgrWu4AELwvTdGtWjqof53AiWHcw==",
|
"integrity": "sha512-+sJasAcqz8XiX1sVEhc6fuNSVZMvQjC/L0pUJ5dzFXaAIPfH6s0c8Bx36F3c81C3KoF8UykWUp2IotXWUlJkQA==",
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
"@next/swc-win32-ia32-msvc": {
|
"@next/swc-win32-ia32-msvc": {
|
||||||
"version": "13.4.7",
|
"version": "13.4.8-canary.4",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.4.7.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.4.8-canary.4.tgz",
|
||||||
"integrity": "sha512-6Hxijm6/a8XqLQpOOf/XuwWRhcuc/g4rBB2oxjgCMuV9Xlr2bLs5+lXyh8w9YbAUMYR3iC9mgOlXbHa79elmXw==",
|
"integrity": "sha512-DNjdyOH6i4A62cwR3GOpQpS21GPzz6r6KkjzuQP7A3q/lYQBULX4Jmr8iBm37Sr5o3PXEPI5owWcC6xsqOsduw==",
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
"@next/swc-win32-x64-msvc": {
|
"@next/swc-win32-x64-msvc": {
|
||||||
"version": "13.4.7",
|
"version": "13.4.8-canary.4",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.4.7.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.4.8-canary.4.tgz",
|
||||||
"integrity": "sha512-sW9Yt36Db1nXJL+mTr2Wo0y+VkPWeYhygvcHj1FF0srVtV+VoDjxleKtny21QHaG05zdeZnw2fCtf2+dEqgwqA==",
|
"integrity": "sha512-zsuSyWhNRXa8toC1Eu0RE9Ol4C006yXDvQc3AJ1vPzFj6ggibLhrmYImFOLV716VDwOj5oALHI0Lc5qMM0NZYQ==",
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
"@nicolo-ribaudo/chokidar-2": {
|
"@nicolo-ribaudo/chokidar-2": {
|
||||||
|
|
@ -13092,20 +13092,20 @@
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"next": {
|
"next": {
|
||||||
"version": "13.4.7",
|
"version": "13.4.8-canary.4",
|
||||||
"resolved": "https://registry.npmjs.org/next/-/next-13.4.7.tgz",
|
"resolved": "https://registry.npmjs.org/next/-/next-13.4.8-canary.4.tgz",
|
||||||
"integrity": "sha512-M8z3k9VmG51SRT6v5uDKdJXcAqLzP3C+vaKfLIAM0Mhx1um1G7MDnO63+m52qPdZfrTFzMZNzfsgvm3ghuVHIQ==",
|
"integrity": "sha512-Dy5BOsaoXhxEoZ7ljZ/l+BUjh+5ODVMRSUV0AOXhzcDparLh0+AcZUyglaqANyh94hZoevod4ubkJDSPRYSHtQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@next/env": "13.4.7",
|
"@next/env": "13.4.8-canary.4",
|
||||||
"@next/swc-darwin-arm64": "13.4.7",
|
"@next/swc-darwin-arm64": "13.4.8-canary.4",
|
||||||
"@next/swc-darwin-x64": "13.4.7",
|
"@next/swc-darwin-x64": "13.4.8-canary.4",
|
||||||
"@next/swc-linux-arm64-gnu": "13.4.7",
|
"@next/swc-linux-arm64-gnu": "13.4.8-canary.4",
|
||||||
"@next/swc-linux-arm64-musl": "13.4.7",
|
"@next/swc-linux-arm64-musl": "13.4.8-canary.4",
|
||||||
"@next/swc-linux-x64-gnu": "13.4.7",
|
"@next/swc-linux-x64-gnu": "13.4.8-canary.4",
|
||||||
"@next/swc-linux-x64-musl": "13.4.7",
|
"@next/swc-linux-x64-musl": "13.4.8-canary.4",
|
||||||
"@next/swc-win32-arm64-msvc": "13.4.7",
|
"@next/swc-win32-arm64-msvc": "13.4.8-canary.4",
|
||||||
"@next/swc-win32-ia32-msvc": "13.4.7",
|
"@next/swc-win32-ia32-msvc": "13.4.8-canary.4",
|
||||||
"@next/swc-win32-x64-msvc": "13.4.7",
|
"@next/swc-win32-x64-msvc": "13.4.8-canary.4",
|
||||||
"@swc/helpers": "0.5.1",
|
"@swc/helpers": "0.5.1",
|
||||||
"busboy": "1.6.0",
|
"busboy": "1.6.0",
|
||||||
"caniuse-lite": "^1.0.30001406",
|
"caniuse-lite": "^1.0.30001406",
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
"formik": "^2.2.9",
|
"formik": "^2.2.9",
|
||||||
"framer-motion": "^7.3.6",
|
"framer-motion": "^7.3.6",
|
||||||
"lucide-react": "^0.248.0",
|
"lucide-react": "^0.248.0",
|
||||||
"next": "^13.4.7-canary.4",
|
"next": "^13.4.8-canary.4",
|
||||||
"re-resizable": "^6.9.9",
|
"re-resizable": "^6.9.9",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-beautiful-dnd": "^13.1.1",
|
"react-beautiful-dnd": "^13.1.1",
|
||||||
|
|
|
||||||
|
|
@ -46,8 +46,7 @@ async def verify_user_rights_with_roles(request: Request, action: str, user_id:
|
||||||
|
|
||||||
# Check if user is anonymous
|
# Check if user is anonymous
|
||||||
if user_id == "anonymous":
|
if user_id == "anonymous":
|
||||||
raise HTTPException(
|
return False
|
||||||
status_code=status.HTTP_403_FORBIDDEN, detail="The ressource you are trying to access is not publicly available")
|
|
||||||
|
|
||||||
# Check if the user is an admin
|
# Check if the user is an admin
|
||||||
user: UserInDB = UserInDB(**await users.find_one({"user_id": user_id}))
|
user: UserInDB = UserInDB(**await users.find_one({"user_id": user_id}))
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ class ActivityInDB(Activity):
|
||||||
creationDate: str
|
creationDate: str
|
||||||
updateDate: str
|
updateDate: str
|
||||||
|
|
||||||
|
|
||||||
#### Classes ####################################################
|
#### Classes ####################################################
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -29,58 +30,102 @@ class ActivityInDB(Activity):
|
||||||
####################################################
|
####################################################
|
||||||
|
|
||||||
|
|
||||||
async def create_activity(request: Request, activity_object: Activity, org_id: str, coursechapter_id: str, current_user: PublicUser):
|
async def create_activity(
|
||||||
|
request: Request,
|
||||||
|
activity_object: Activity,
|
||||||
|
org_id: str,
|
||||||
|
coursechapter_id: str,
|
||||||
|
current_user: PublicUser,
|
||||||
|
):
|
||||||
activities = request.app.db["activities"]
|
activities = request.app.db["activities"]
|
||||||
courses = request.app.db["courses"]
|
courses = request.app.db["courses"]
|
||||||
|
|
||||||
# generate activity_id
|
# generate activity_id
|
||||||
activity_id = str(f"activity_{uuid4()}")
|
activity_id = str(f"activity_{uuid4()}")
|
||||||
|
|
||||||
hasRoleRights = await verify_user_rights_with_roles(request, "create", current_user.user_id, activity_id, org_id)
|
hasRoleRights = await verify_user_rights_with_roles(
|
||||||
|
request, "create", current_user.user_id, activity_id, org_id
|
||||||
|
)
|
||||||
|
|
||||||
if not hasRoleRights:
|
if not hasRoleRights:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_409_CONFLICT, detail="Roles : Insufficient rights to perform this action")
|
status_code=status.HTTP_409_CONFLICT,
|
||||||
|
detail="Roles : Insufficient rights to perform this action",
|
||||||
|
)
|
||||||
|
|
||||||
# create activity
|
# create activity
|
||||||
activity = ActivityInDB(**activity_object.dict(), creationDate=str(
|
activity = ActivityInDB(
|
||||||
datetime.now()), coursechapter_id=coursechapter_id, updateDate=str(datetime.now()), activity_id=activity_id, org_id=org_id)
|
**activity_object.dict(),
|
||||||
|
creationDate=str(datetime.now()),
|
||||||
|
coursechapter_id=coursechapter_id,
|
||||||
|
updateDate=str(datetime.now()),
|
||||||
|
activity_id=activity_id,
|
||||||
|
org_id=org_id,
|
||||||
|
)
|
||||||
await activities.insert_one(activity.dict())
|
await activities.insert_one(activity.dict())
|
||||||
|
|
||||||
# update chapter
|
# update chapter
|
||||||
await courses.update_one({"chapters_content.coursechapter_id": coursechapter_id}, {
|
await courses.update_one(
|
||||||
"$addToSet": {"chapters_content.$.activities": activity_id}})
|
{"chapters_content.coursechapter_id": coursechapter_id},
|
||||||
|
{"$addToSet": {"chapters_content.$.activities": activity_id}},
|
||||||
|
)
|
||||||
|
|
||||||
return activity
|
return activity
|
||||||
|
|
||||||
|
|
||||||
async def get_activity(request: Request, activity_id: str, current_user: PublicUser):
|
async def get_activity(request: Request, activity_id: str, current_user: PublicUser):
|
||||||
activities = request.app.db["activities"]
|
activities = request.app.db["activities"]
|
||||||
|
courses = request.app.db["courses"]
|
||||||
|
|
||||||
activity = await activities.find_one({"activity_id": activity_id})
|
activity = await activities.find_one({"activity_id": activity_id})
|
||||||
|
|
||||||
# verify course rights
|
# get course_id from activity
|
||||||
hasRoleRights = await verify_user_rights_with_roles(request, "read", current_user.user_id, activity_id, element_org_id=activity["org_id"])
|
coursechapter_id = activity["coursechapter_id"]
|
||||||
|
course = await courses.find_one({"chapters": coursechapter_id})
|
||||||
|
|
||||||
if not hasRoleRights:
|
isCoursePublic = course["public"]
|
||||||
|
|
||||||
|
# verify course rights
|
||||||
|
hasRoleRights = await verify_user_rights_with_roles(
|
||||||
|
request,
|
||||||
|
"read",
|
||||||
|
current_user.user_id,
|
||||||
|
activity_id,
|
||||||
|
element_org_id=activity["org_id"],
|
||||||
|
)
|
||||||
|
|
||||||
|
if not hasRoleRights and not isCoursePublic:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_409_CONFLICT, detail="Roles : Insufficient rights to perform this action")
|
status_code=status.HTTP_409_CONFLICT,
|
||||||
|
detail="Roles : Insufficient rights to perform this action",
|
||||||
|
)
|
||||||
|
|
||||||
if not activity:
|
if not activity:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_409_CONFLICT, detail="Course does not exist")
|
status_code=status.HTTP_409_CONFLICT, detail="Course does not exist"
|
||||||
|
)
|
||||||
|
|
||||||
activity = ActivityInDB(**activity)
|
activity = ActivityInDB(**activity)
|
||||||
return activity
|
return activity
|
||||||
|
|
||||||
|
|
||||||
async def update_activity(request: Request, activity_object: Activity, activity_id: str, current_user: PublicUser):
|
async def update_activity(
|
||||||
|
request: Request,
|
||||||
|
activity_object: Activity,
|
||||||
|
activity_id: str,
|
||||||
|
current_user: PublicUser,
|
||||||
|
):
|
||||||
activities = request.app.db["activities"]
|
activities = request.app.db["activities"]
|
||||||
|
|
||||||
activity = await activities.find_one({"activity_id": activity_id})
|
activity = await activities.find_one({"activity_id": activity_id})
|
||||||
# verify course rights
|
# verify course rights
|
||||||
await verify_user_rights_with_roles(request, "update", current_user.user_id, activity_id, element_org_id=activity["org_id"])
|
await verify_user_rights_with_roles(
|
||||||
|
request,
|
||||||
|
"update",
|
||||||
|
current_user.user_id,
|
||||||
|
activity_id,
|
||||||
|
element_org_id=activity["org_id"],
|
||||||
|
)
|
||||||
|
|
||||||
if activity:
|
if activity:
|
||||||
creationDate = activity["creationDate"]
|
creationDate = activity["creationDate"]
|
||||||
|
|
@ -89,30 +134,44 @@ async def update_activity(request: Request, activity_object: Activity, activity_
|
||||||
datetime_object = datetime.now()
|
datetime_object = datetime.now()
|
||||||
|
|
||||||
updated_course = ActivityInDB(
|
updated_course = ActivityInDB(
|
||||||
activity_id=activity_id, coursechapter_id=activity["coursechapter_id"], creationDate=creationDate, updateDate=str(datetime_object), org_id=activity["org_id"], **activity_object.dict())
|
activity_id=activity_id,
|
||||||
|
coursechapter_id=activity["coursechapter_id"],
|
||||||
|
creationDate=creationDate,
|
||||||
|
updateDate=str(datetime_object),
|
||||||
|
org_id=activity["org_id"],
|
||||||
|
**activity_object.dict(),
|
||||||
|
)
|
||||||
|
|
||||||
await activities.update_one({"activity_id": activity_id}, {
|
await activities.update_one(
|
||||||
"$set": updated_course.dict()})
|
{"activity_id": activity_id}, {"$set": updated_course.dict()}
|
||||||
|
)
|
||||||
|
|
||||||
return ActivityInDB(**updated_course.dict())
|
return ActivityInDB(**updated_course.dict())
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_409_CONFLICT, detail="activity does not exist")
|
status_code=status.HTTP_409_CONFLICT, detail="activity does not exist"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def delete_activity(request: Request, activity_id: str, current_user: PublicUser):
|
async def delete_activity(request: Request, activity_id: str, current_user: PublicUser):
|
||||||
|
|
||||||
activities = request.app.db["activities"]
|
activities = request.app.db["activities"]
|
||||||
|
|
||||||
activity = await activities.find_one({"activity_id": activity_id})
|
activity = await activities.find_one({"activity_id": activity_id})
|
||||||
|
|
||||||
# verify course rights
|
# verify course rights
|
||||||
await verify_user_rights_with_roles(request, "delete", current_user.user_id, activity_id, element_org_id=activity["org_id"])
|
await verify_user_rights_with_roles(
|
||||||
|
request,
|
||||||
|
"delete",
|
||||||
|
current_user.user_id,
|
||||||
|
activity_id,
|
||||||
|
element_org_id=activity["org_id"],
|
||||||
|
)
|
||||||
|
|
||||||
if not activity:
|
if not activity:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_409_CONFLICT, detail="activity does not exist")
|
status_code=status.HTTP_409_CONFLICT, detail="activity does not exist"
|
||||||
|
)
|
||||||
|
|
||||||
isDeleted = await activities.delete_one({"activity_id": activity_id})
|
isDeleted = await activities.delete_one({"activity_id": activity_id})
|
||||||
|
|
||||||
|
|
@ -120,26 +179,30 @@ async def delete_activity(request: Request, activity_id: str, current_user: Publ
|
||||||
return {"detail": "activity deleted"}
|
return {"detail": "activity deleted"}
|
||||||
else:
|
else:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_503_SERVICE_UNAVAILABLE, detail="Unavailable database")
|
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
|
||||||
|
detail="Unavailable database",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
####################################################
|
####################################################
|
||||||
# Misc
|
# Misc
|
||||||
####################################################
|
####################################################
|
||||||
|
|
||||||
|
|
||||||
async def get_activities(request: Request, coursechapter_id: str, current_user: PublicUser):
|
async def get_activities(
|
||||||
|
request: Request, coursechapter_id: str, current_user: PublicUser
|
||||||
|
):
|
||||||
activities = request.app.db["activities"]
|
activities = request.app.db["activities"]
|
||||||
|
|
||||||
# TODO : TERRIBLE SECURITY ISSUE HERE, NEED TO FIX ASAP
|
|
||||||
# TODO : TERRIBLE SECURITY ISSUE HERE, NEED TO FIX ASAP
|
|
||||||
# TODO : TERRIBLE SECURITY ISSUE HERE, NEED TO FIX ASAP
|
|
||||||
|
|
||||||
activities = activities.find({"coursechapter_id": coursechapter_id})
|
activities = activities.find({"coursechapter_id": coursechapter_id})
|
||||||
|
|
||||||
if not activities:
|
if not activities:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_409_CONFLICT, detail="Course does not exist")
|
status_code=status.HTTP_409_CONFLICT, detail="Course does not exist"
|
||||||
|
)
|
||||||
|
|
||||||
activities = [ActivityInDB(**activity) for activity in await activities.to_list(length=100)]
|
activities = [
|
||||||
|
ActivityInDB(**activity) for activity in await activities.to_list(length=100)
|
||||||
|
]
|
||||||
|
|
||||||
return activities
|
return activities
|
||||||
|
|
|
||||||
|
|
@ -174,7 +174,7 @@ async def add_activity_to_trail(request: Request, user: PublicUser, course_id:
|
||||||
# modify trail object
|
# modify trail object
|
||||||
await trails.replace_one({"trail_id": trail["trail_id"]}, trail)
|
await trails.replace_one({"trail_id": trail["trail_id"]}, trail)
|
||||||
|
|
||||||
return Trail(**trail.dict())
|
return Trail(**trail)
|
||||||
|
|
||||||
|
|
||||||
async def add_course_to_trail(request: Request, user: PublicUser, orgslug: str, course_id: str) -> Trail:
|
async def add_course_to_trail(request: Request, user: PublicUser, orgslug: str, course_id: str) -> Trail:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue