From a3e5b7fb717dc1baaae233052b8919595196fc8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=BChler=20Ma=C3=ABlys?= Date: Mon, 18 Mar 2024 21:35:44 +0100 Subject: [PATCH 1/3] update database to make text longer --- .../migrations/0002_auto_20240303_1147.py | 2 +- .../migrations/0003_alter_category_users.py | 2 +- .../migrations/0005_category_image_path.py | 2 +- ...ion_question_alter_option_text_and_more.py | 29 +++++++++++++++++++ api/masteriqapp/models/Option.py | 2 +- api/masteriqapp/models/Question.py | 2 +- 6 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 api/masteriqapp/migrations/0006_alter_option_question_alter_option_text_and_more.py diff --git a/api/masteriqapp/migrations/0002_auto_20240303_1147.py b/api/masteriqapp/migrations/0002_auto_20240303_1147.py index 626789f..986820f 100644 --- a/api/masteriqapp/migrations/0002_auto_20240303_1147.py +++ b/api/masteriqapp/migrations/0002_auto_20240303_1147.py @@ -36,7 +36,7 @@ def load_initial_data(apps, schema_editor): class Migration(migrations.Migration): dependencies = [ - ('masteriqapp', '0001_initial'), + ('masteriqapp', '0003_alter_category_users'), ] operations = [ diff --git a/api/masteriqapp/migrations/0003_alter_category_users.py b/api/masteriqapp/migrations/0003_alter_category_users.py index 0654f23..b7662a1 100644 --- a/api/masteriqapp/migrations/0003_alter_category_users.py +++ b/api/masteriqapp/migrations/0003_alter_category_users.py @@ -7,7 +7,7 @@ class Migration(migrations.Migration): dependencies = [ - ('masteriqapp', '0002_auto_20240303_1147'), + ('masteriqapp', '0006_alter_option_question_alter_option_text_and_more'), migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] diff --git a/api/masteriqapp/migrations/0005_category_image_path.py b/api/masteriqapp/migrations/0005_category_image_path.py index 051222c..1022252 100644 --- a/api/masteriqapp/migrations/0005_category_image_path.py +++ b/api/masteriqapp/migrations/0005_category_image_path.py @@ -6,7 +6,7 @@ class Migration(migrations.Migration): dependencies = [ - ('masteriqapp', '0003_alter_category_users'), + ('masteriqapp', '0002_auto_20240303_1147'), ] operations = [ diff --git a/api/masteriqapp/migrations/0006_alter_option_question_alter_option_text_and_more.py b/api/masteriqapp/migrations/0006_alter_option_question_alter_option_text_and_more.py new file mode 100644 index 0000000..c608f65 --- /dev/null +++ b/api/masteriqapp/migrations/0006_alter_option_question_alter_option_text_and_more.py @@ -0,0 +1,29 @@ +# Generated by Django 5.0.2 on 2024-03-18 20:09 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('masteriqapp', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='option', + name='question', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='options', to='masteriqapp.question'), + ), + migrations.AlterField( + model_name='option', + name='text', + field=models.CharField(max_length=1024), + ), + migrations.AlterField( + model_name='question', + name='text', + field=models.CharField(max_length=1024), + ), + ] diff --git a/api/masteriqapp/models/Option.py b/api/masteriqapp/models/Option.py index 6c0e852..08a8c63 100644 --- a/api/masteriqapp/models/Option.py +++ b/api/masteriqapp/models/Option.py @@ -3,7 +3,7 @@ class Option(models.Model): - text = models.CharField(max_length=255) + text = models.CharField(max_length=1024) is_correct = models.BooleanField() question = models.ForeignKey(Question, related_name='options', on_delete=models.CASCADE) diff --git a/api/masteriqapp/models/Question.py b/api/masteriqapp/models/Question.py index ccce863..051f392 100644 --- a/api/masteriqapp/models/Question.py +++ b/api/masteriqapp/models/Question.py @@ -3,5 +3,5 @@ class Question(models.Model): - text = models.CharField(max_length=255) + text = models.CharField(max_length=1024) category = models.ForeignKey(Category, on_delete=models.CASCADE) From d72fb08d0235214c1cfe1ff0463aa63927363159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=BChler=20Ma=C3=ABlys?= Date: Mon, 18 Mar 2024 21:50:28 +0100 Subject: [PATCH 2/3] add db sttings to .env --- api/masteriq/settings.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/api/masteriq/settings.py b/api/masteriq/settings.py index 373231b..c466ae3 100644 --- a/api/masteriq/settings.py +++ b/api/masteriq/settings.py @@ -9,7 +9,7 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/5.0/ref/settings/ """ - +from distutils.util import strtobool from pathlib import Path import os from dotenv import load_dotenv @@ -27,7 +27,7 @@ SECRET_KEY = os.getenv('SECRET_KEY') # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = os.getenv('DEBUG') +DEBUG = bool(strtobool(os.getenv('DEBUG'))) ALLOWED_HOSTS = [ os.getenv('BACKEND_HOST') @@ -86,13 +86,24 @@ # Database # https://docs.djangoproject.com/en/5.0/ref/settings/#databases - DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': BASE_DIR / 'db.sqlite3', } } +if os.getenv('PRODUCTION') == 'True': + DATABASES = { + 'default': { + 'ENGINE': os.getenv('DB_ENGINE'), + 'NAME': os.getenv('DB_NAME'), + 'USER': os.getenv('DB_USER'), + 'PASSWORD': os.getenv('DB_PASSWORD'), + 'HOST': os.getenv('DB_HOST'), + 'PORT': os.getenv('DB_PORT'), + } + } + # Password validation From 56aa4d9f7722c9a76a0213ec3ee9ed38ef809e84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=BChler=20Ma=C3=ABlys?= Date: Mon, 18 Mar 2024 21:53:15 +0100 Subject: [PATCH 3/3] add env var to cicd --- api/.env.cicd | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/.env.cicd b/api/.env.cicd index bd19ab7..4055713 100644 --- a/api/.env.cicd +++ b/api/.env.cicd @@ -2,4 +2,5 @@ FRONTEND_URL=http://localhost:5173 BACKEND_URL=http://127.0.0.1:5173 BACKEND_HOST=127.0.0.1:5173 DEBUG=True -SECRET_KEY=django-insecure-^=xy+akjdagtjisch+_5fku9!1aw)hhf_&feny8r3@6ds%rds \ No newline at end of file +SECRET_KEY=django-insecure-^=xy+akjdagtjisch+_5fku9!1aw)hhf_&feny8r3@6ds%rds +PRODUCTION=False \ No newline at end of file