From 689b3fbd199d327beba93ebdf02eeea0dc711638 Mon Sep 17 00:00:00 2001 From: Plumey Simon Date: Fri, 15 Mar 2024 14:09:49 +0100 Subject: [PATCH 1/7] update gitignore to ignore capistrano --- .gitignore | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.gitignore b/.gitignore index 3f8147b..29e67e8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,10 @@ .idea db.sqlite3 __pycache__ + +# Capistrano +/config/ +Capfile +Gemfile +Gemfile.lock +capistrano.log \ No newline at end of file From 5df4949b1bed747aae72f338b6fc780577fbac43 Mon Sep 17 00:00:00 2001 From: Plumey Simon Date: Fri, 15 Mar 2024 14:10:50 +0100 Subject: [PATCH 2/7] First request and CORS problem resolution --- api/Pipfile | 1 + api/Pipfile.lock | 11 ++++++++++- api/masteriq/settings.py | 6 ++++++ api/masteriq/urls.py | 2 +- frontend/src/views/HomeView.vue | 21 +++++++++++++++++++++ 5 files changed, 39 insertions(+), 2 deletions(-) diff --git a/api/Pipfile b/api/Pipfile index f21ff8d..d39257b 100644 --- a/api/Pipfile +++ b/api/Pipfile @@ -7,6 +7,7 @@ name = "pypi" django = "==5.0.2" djangorestframework = "==3.14.0" pandas = "*" +django-cors-headers = "*" [dev-packages] diff --git a/api/Pipfile.lock b/api/Pipfile.lock index aa65ea6..01ca358 100644 --- a/api/Pipfile.lock +++ b/api/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "edae6cc81aa424ed1cebb5c17ba2e06710e8b358349736357a8d185c37cff4b2" + "sha256": "ae0fd64da1a6ba308a4ef9796f6cf1300e15a871d05775c966137d67f82a5c11" }, "pipfile-spec": 6, "requires": { @@ -33,6 +33,15 @@ "markers": "python_version >= '3.10'", "version": "==5.0.2" }, + "django-cors-headers": { + "hashes": [ + "sha256:0b1fd19297e37417fc9f835d39e45c8c642938ddba1acce0c1753d3edef04f36", + "sha256:0bf65ef45e606aff1994d35503e6b677c0b26cafff6506f8fd7187f3be840207" + ], + "index": "pypi", + "markers": "python_version >= '3.8'", + "version": "==4.3.1" + }, "djangorestframework": { "hashes": [ "sha256:579a333e6256b09489cbe0a067e66abe55c6595d8926be6b99423786334350c8", diff --git a/api/masteriq/settings.py b/api/masteriq/settings.py index ef79e5a..0766c8c 100644 --- a/api/masteriq/settings.py +++ b/api/masteriq/settings.py @@ -28,6 +28,10 @@ ALLOWED_HOSTS = [] +CORS_ALLOWED_ORIGINS = [ + "http://localhost:5173", + "http://127.0.0.1:5173", +] # Application definition @@ -40,9 +44,11 @@ 'django.contrib.staticfiles', 'masteriqapp', 'rest_framework', + "corsheaders", ] MIDDLEWARE = [ + "corsheaders.middleware.CorsMiddleware", 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', diff --git a/api/masteriq/urls.py b/api/masteriq/urls.py index 28782d9..5a55a85 100644 --- a/api/masteriq/urls.py +++ b/api/masteriq/urls.py @@ -28,5 +28,5 @@ urlpatterns = [ path('admin/', admin.site.urls), - path("", include(router.urls)) + path("api/", include(router.urls)) ] diff --git a/frontend/src/views/HomeView.vue b/frontend/src/views/HomeView.vue index e979aa8..1917b42 100644 --- a/frontend/src/views/HomeView.vue +++ b/frontend/src/views/HomeView.vue @@ -1,9 +1,30 @@ From 4e460ef1c54f0f8880a94e1ce303a37785ef8378 Mon Sep 17 00:00:00 2001 From: Plumey Simon Date: Fri, 15 Mar 2024 21:24:45 +0100 Subject: [PATCH 3/7] Adding environement variables --- frontend/package-lock.json | 13 +++++++++++++ frontend/package.json | 1 + frontend/src/views/HomeView.vue | 7 ++++--- frontend/vite.config.js | 18 +++++++++++------- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/frontend/package-lock.json b/frontend/package-lock.json index c4ae547..8e0c52d 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -14,6 +14,7 @@ }, "devDependencies": { "@vitejs/plugin-vue": "^5.0.3", + "dotenv": "^16.4.5", "vite": "^5.0.11" } }, @@ -723,6 +724,18 @@ "node": ">=0.4.0" } }, + "node_modules/dotenv": { + "version": "16.4.5", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", + "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, "node_modules/entities": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", diff --git a/frontend/package.json b/frontend/package.json index 48ed71f..04f80a1 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -15,6 +15,7 @@ }, "devDependencies": { "@vitejs/plugin-vue": "^5.0.3", + "dotenv": "^16.4.5", "vite": "^5.0.11" } } diff --git a/frontend/src/views/HomeView.vue b/frontend/src/views/HomeView.vue index 1917b42..a028e11 100644 --- a/frontend/src/views/HomeView.vue +++ b/frontend/src/views/HomeView.vue @@ -1,11 +1,12 @@ - - - - diff --git a/frontend/src/components/CategoryItem.vue b/frontend/src/components/CategoryItem.vue new file mode 100644 index 0000000..bd074bb --- /dev/null +++ b/frontend/src/components/CategoryItem.vue @@ -0,0 +1,84 @@ + + + + + diff --git a/frontend/src/router/index.js b/frontend/src/router/index.js index f824cc1..e4de527 100644 --- a/frontend/src/router/index.js +++ b/frontend/src/router/index.js @@ -10,7 +10,7 @@ const router = createRouter({ component: HomeView }, { - path: '/quiz', + path: '/quiz/:id_category', name: 'Quiz', component: () => import('../views/QuizView.vue') }, diff --git a/frontend/src/views/HomeView.vue b/frontend/src/views/HomeView.vue index a028e11..0008346 100644 --- a/frontend/src/views/HomeView.vue +++ b/frontend/src/views/HomeView.vue @@ -1,16 +1,16 @@