fix: remove testing leftovers

This commit is contained in:
swve 2023-08-14 14:26:44 +02:00
parent b564c8db64
commit c7061a26fa
16 changed files with 30 additions and 71 deletions

38
app.py
View file

@ -64,45 +64,7 @@ app.mount("/content", StaticFiles(directory="content"), name="content")
app.include_router(v1_router) app.include_router(v1_router)
# General Routes # General Routes
@app.get("/") @app.get("/")
async def root(): async def root():
return {"Message": "Welcome to LearnHouse ✨"} return {"Message": "Welcome to LearnHouse ✨"}
@app.get("/test")
async def rootd(request: Request):
res = await authorization_verify_based_on_roles(
request=request,
user_id="user_c441e47e-5c04-4b03-9886-b0f5cb333c06",
action="read",
roles_list=[
UserRolesInOrganization(
org_id="org_e7085838-2efc-48f3-b414-77318572d9f5", role_id="role_admin"
),
],
element_id="collection_1c277b46-5a4b-440a-ac29-94b874ef7cf4",
)
return res
@app.get("/test2")
async def rootds(request: Request):
res = await authorization_verify_if_user_is_author(
request=request,
user_id="user_c441e47e-5c04-4b03-9886-b0f5cb333c06",
action="read",
element_id="course_1c277b46-5a4b-440a-ac29-94b874ef7cf4",
)
return res
@app.get("/test3")
async def rootdsc(request: Request):
res = await authorization_verify_if_element_is_public(
request=request,
user_id="anonymous",
action="read",
element_id="course_1c277b46-5a4b-440a-ac29-94b874ef7cf4",
)
return res

View file

@ -61,7 +61,7 @@ function AccountCreation() {
}, },
validate, validate,
onSubmit: values => { onSubmit: values => {
console.log(install.data[1].slug)
let finalvalues = { ...values, org_slug: install.data[1].slug } let finalvalues = { ...values, org_slug: install.data[1].slug }
let finalvalueswithoutpasswords = { ...values, password: '', confirmPassword: '', org_slug: install.data[1].slug } let finalvalueswithoutpasswords = { ...values, password: '', confirmPassword: '', org_slug: install.data[1].slug }
let install_data = { ...install.data, 3: finalvalues } let install_data = { ...install.data, 3: finalvalues }

View file

@ -28,7 +28,7 @@ function DefaultElements() {
setIsSubmitted(true) setIsSubmitted(true)
} }
catch (e) { catch (e) {
console.log(e)
} }
} }

View file

@ -11,7 +11,7 @@ const Finish = () => {
const router = useRouter() const router = useRouter()
async function finishInstall() { async function finishInstall() {
console.log('install_data')
let install_data = { ...install.data, 5: { status: 'OK' } } let install_data = { ...install.data, 5: { status: 'OK' } }
let data = await updateInstall(install_data, 6) let data = await updateInstall(install_data, 6)
@ -19,7 +19,7 @@ const Finish = () => {
router.push('/install?step=6') router.push('/install?step=6')
} }
else { else {
console.log('Error')
} }
} }

View file

@ -65,7 +65,7 @@ function OrgCreation() {
setIsSubmitted(true) setIsSubmitted(true)
} }
catch (e) { catch (e) {
console.log(e)
} }
} }

View file

@ -14,7 +14,7 @@ function SampleData() {
try { try {
let username = install.data[3].username let username = install.data[3].username
let slug = install.data[1].slug let slug = install.data[1].slug
console.log(install.data)
createSampleDataInstall(username, slug) createSampleDataInstall(username, slug)
let install_data = { ...install.data, 4: { status: 'OK' } } let install_data = { ...install.data, 4: { status: 'OK' } }
@ -24,7 +24,7 @@ function SampleData() {
} }
catch (e) { catch (e) {
console.log(e)
} }
} }

View file

@ -26,7 +26,7 @@ const Organizations = () => {
const handleSubmit = async (e: any) => { const handleSubmit = async (e: any) => {
e.preventDefault(); e.preventDefault();
console.log({ name, description, email });
let logo = '' let logo = ''
const status = await createNewOrganization({ name, description, email, logo, slug, default: false }); const status = await createNewOrganization({ name, description, email, logo, slug, default: false });
alert(JSON.stringify(status)); alert(JSON.stringify(status));

View file

@ -21,7 +21,7 @@ export async function generateMetadata(
const org = await getOrganizationContextInfo(params.orgslug, { revalidate: 1800, tags: ['organizations'] }); const org = await getOrganizationContextInfo(params.orgslug, { revalidate: 1800, tags: ['organizations'] });
const col = await getCollectionByIdWithAuthHeader(params.collectionid, access_token_cookie ? access_token_cookie.value : null, { revalidate: 0, tags: ['collections'] }); const col = await getCollectionByIdWithAuthHeader(params.collectionid, access_token_cookie ? access_token_cookie.value : null, { revalidate: 0, tags: ['collections'] });
console.log(col)
return { return {
title: `Collection : ${col.name}${org.name}`, title: `Collection : ${col.name}${org.name}`,

View file

@ -35,7 +35,7 @@ function NewCollection(params: any) {
const handleSubmit = async (e: any) => { const handleSubmit = async (e: any) => {
e.preventDefault(); e.preventDefault();
console.log("selectedCourses", selectedCourses);
const collection = { const collection = {
name: name, name: name,
description: description, description: description,

View file

@ -83,7 +83,7 @@ function CourseEdit(params: any) {
// Submit new activity // Submit new activity
const submitActivity = async (activity: any) => { const submitActivity = async (activity: any) => {
console.log("submitActivity", activity);
let org = await getOrganizationContextInfo(orgslug, { revalidate: 1800 }); let org = await getOrganizationContextInfo(orgslug, { revalidate: 1800 });
await updateChaptersMetadata(courseid, data); await updateChaptersMetadata(courseid, data);
await createActivity(activity, activity.chapterId, org.org_id); await createActivity(activity, activity.chapterId, org.org_id);
@ -105,7 +105,7 @@ function CourseEdit(params: any) {
// Submit YouTube Video Upload // Submit YouTube Video Upload
const submitExternalVideo = async (external_video_data: any, activity: any, chapterId: string) => { const submitExternalVideo = async (external_video_data: any, activity: any, chapterId: string) => {
console.log("submitExternalVideo", external_video_data);
await updateChaptersMetadata(courseid, data); await updateChaptersMetadata(courseid, data);
await createExternalVideoActivity(external_video_data, activity, chapterId); await createExternalVideoActivity(external_video_data, activity, chapterId);
await getCourseChapters(); await getCourseChapters();
@ -115,7 +115,7 @@ function CourseEdit(params: any) {
}; };
const deleteChapterUI = async (chapterId: any) => { const deleteChapterUI = async (chapterId: any) => {
console.log("deleteChapter", chapterId);
await deleteChapter(chapterId); await deleteChapter(chapterId);
getCourseChapters(); getCourseChapters();
revalidateTags(['courses'], orgslug); revalidateTags(['courses'], orgslug);
@ -123,7 +123,7 @@ function CourseEdit(params: any) {
}; };
const updateChapters = () => { const updateChapters = () => {
console.log(data);
updateChaptersMetadata(courseid, data); updateChaptersMetadata(courseid, data);
revalidateTags(['courses'], orgslug); revalidateTags(['courses'], orgslug);
router.refresh(); router.refresh();
@ -134,7 +134,7 @@ function CourseEdit(params: any) {
*/ */
const openNewActivityModal = async (chapterId: any) => { const openNewActivityModal = async (chapterId: any) => {
console.log("openNewActivityModal", chapterId);
setNewActivityModal(true); setNewActivityModal(true);
setNewActivityModalData(chapterId); setNewActivityModalData(chapterId);
}; };
@ -145,7 +145,7 @@ function CourseEdit(params: any) {
}; };
const closeNewActivityModal = () => { const closeNewActivityModal = () => {
console.log("closeNewActivityModal");
setNewActivityModal(false); setNewActivityModal(false);
}; };
@ -156,7 +156,7 @@ function CourseEdit(params: any) {
*/ */
const onDragEnd = (result: any) => { const onDragEnd = (result: any) => {
const { destination, source, draggableId, type } = result; const { destination, source, draggableId, type } = result;
console.log(result);
// check if the activity is dropped outside the droppable area // check if the activity is dropped outside the droppable area
if (!destination) { if (!destination) {
@ -177,7 +177,7 @@ function CourseEdit(params: any) {
...data, ...data,
chapterOrder: newChapterOrder, chapterOrder: newChapterOrder,
}; };
console.log(newState);
setData(newState); setData(newState);
return; return;

View file

@ -8,7 +8,7 @@ import { updatePassword } from '@services/settings/password';
function PasswordsClient() { function PasswordsClient() {
const auth: any = React.useContext(AuthContext); const auth: any = React.useContext(AuthContext);
console.log('auth', auth)
const updatePasswordUI = async (values: any) => { const updatePasswordUI = async (values: any) => {
let user_id = auth.userInfo.user_object.user_id; let user_id = auth.userInfo.user_object.user_id;

View file

@ -29,7 +29,7 @@ function ImageBlockComponent(props: any) {
let modifiedQuestions = [...questions]; let modifiedQuestions = [...questions];
modifiedQuestions.splice(index, 1); modifiedQuestions.splice(index, 1);
setQuestions(modifiedQuestions); setQuestions(modifiedQuestions);
console.log(questions);
// remove the answers from the answers array // remove the answers from the answers array
let modifiedAnswers = [...answers]; let modifiedAnswers = [...answers];
@ -79,17 +79,17 @@ function ImageBlockComponent(props: any) {
option_id: option_id, option_id: option_id,
}; };
setAnswers([...answers, answer]); setAnswers([...answers, answer]);
console.log(answers);
}; };
const saveQuiz = async () => { const saveQuiz = async () => {
// save the questions and answers to the backend // save the questions and answers to the backend
console.log("saving quiz");
console.log(questions);
console.log(answers);
try { try {
let res = await submitQuizBlock(props.extension.options.activity.activity_id, {questions : questions , answers : answers}) let res = await submitQuizBlock(props.extension.options.activity.activity_id, {questions : questions , answers : answers})
console.log(res.block_id);
props.updateAttributes({ props.updateAttributes({
quizId: { quizId: {
value : res.block_id value : res.block_id
@ -98,7 +98,7 @@ function ImageBlockComponent(props: any) {
} }
catch (error) { catch (error) {
console.log(error);
} }
@ -112,9 +112,9 @@ function ImageBlockComponent(props: any) {
React.useEffect(() => { React.useEffect(() => {
// fetch the questions and options from the backend // fetch the questions and options from the backend
console.log("fetching questions");
console.log(questions);
console.log(answers);
}, [questions, answers]); }, [questions, answers]);
return ( return (

View file

@ -19,7 +19,7 @@ function NewChapterModal({ submitChapter, closeModal }: any) {
const handleSubmit = async (e: any) => { const handleSubmit = async (e: any) => {
e.preventDefault(); e.preventDefault();
console.log({ chapterName, chapterDescription });
setIsSubmitting(true); setIsSubmitting(true);
await submitChapter({ name: chapterName, description: chapterDescription, activities: [] }); await submitChapter({ name: chapterName, description: chapterDescription, activities: [] });
setIsSubmitting(false); setIsSubmitting(false);

View file

@ -173,7 +173,6 @@ async def get_collections(
): ):
collections = request.app.db["collections"] collections = request.app.db["collections"]
print(org_id)
if current_user.user_id == "anonymous": if current_user.user_id == "anonymous":
all_collections = collections.find( all_collections = collections.find(

View file

@ -204,7 +204,6 @@ async def create_initial_data(request: Request):
activities=[], activities=[],
) )
coursechapter = await create_coursechapter(request,coursechapter, course_id, current_user) coursechapter = await create_coursechapter(request,coursechapter, course_id, current_user)
pprint(coursechapter)
if coursechapter: if coursechapter:
# create activities # create activities
for i in range(0, 5): for i in range(0, 5):

View file

@ -364,7 +364,6 @@ async def create_sample_data(org_slug: str, username: str, request: Request):
current_user = PublicUser(**user) current_user = PublicUser(**user)
print(current_user)
for i in range(0, 5): for i in range(0, 5):
# get image in BinaryIO format from unsplash and save it to disk # get image in BinaryIO format from unsplash and save it to disk
image = requests.get("https://source.unsplash.com/random/800x600") image = requests.get("https://source.unsplash.com/random/800x600")