Przeglądaj źródła

Para que funcione en local

Celestino Rey 2 miesięcy temu
rodzic
commit
6f295b402c

+ 1 - 0
src/.gitignore

@@ -0,0 +1 @@
+migrations/*

+ 3 - 3
src/doc_generator/settings.py

@@ -25,7 +25,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent
 SECRET_KEY = 'django-insecure-qb$!mc5&7qcph*kb&j@x$$zce*i9-3es0%9lw$x89n1nl6ncjy'
 
 # SECURITY WARNING: don't run with debug turned on in production!
-DEBUG = True
+DEBUG = os.environ.get('DEBUG', 'False') == 'True'
 
 ALLOWED_HOSTS = [".rancher.lab", "127.0.0.1", "localhost"]
 
@@ -84,7 +84,7 @@ WSGI_APPLICATION = 'doc_generator.wsgi.application'
 # Database
 # https://docs.djangoproject.com/en/5.2/ref/settings/#databases
 
-if DEBUG == "True":
+if DEBUG:
     DATABASES = { 
         'default': {
             'ENGINE': 'django.db.backends.sqlite3',
@@ -143,7 +143,7 @@ USE_TZ = True
 # https://docs.djangoproject.com/en/4.2/howto/static-files/
 
 STATIC_URL = 'static/'
-STATIC_ROOT = os.path.join(BASE_DIR, 'static')
+STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
 
 #STATICFILES_DIRS = [BASE_DIR / "static",]
 STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'  # For production static file handling

+ 21 - 4
src/textdocs/migrations/0001_initial.py

@@ -1,6 +1,8 @@
-# Generated by Django 4.2.29 on 2026-03-05 11:58
+# Generated by Django 4.2.29 on 2026-05-19 12:23
 
+from django.conf import settings
 from django.db import migrations, models
+import django.db.models.deletion
 
 
 class Migration(migrations.Migration):
@@ -8,6 +10,7 @@ class Migration(migrations.Migration):
     initial = True
 
     dependencies = [
+        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
     ]
 
     operations = [
@@ -16,10 +19,24 @@ class Migration(migrations.Migration):
             fields=[
                 ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                 ('title', models.CharField(max_length=255)),
-                ('introduction', models.TextField(help_text='The introductory section of the document.')),
-                ('main_body', models.TextField(help_text='The main content or analysis.')),
-                ('conclusion', models.TextField(help_text='The concluding remarks or summary.')),
                 ('created_at', models.DateTimeField(auto_now_add=True)),
+                ('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
             ],
         ),
+        migrations.CreateModel(
+            name='DocumentVersion',
+            fields=[
+                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('version_number', models.PositiveIntegerField()),
+                ('introduction', models.TextField()),
+                ('main_body', models.TextField()),
+                ('conclusion', models.TextField()),
+                ('created_at', models.DateTimeField(auto_now_add=True)),
+                ('document', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='versions', to='textdocs.document')),
+            ],
+            options={
+                'ordering': ['-version_number'],
+                'unique_together': {('document', 'version_number')},
+            },
+        ),
     ]

+ 0 - 50
src/textdocs/migrations/0002_remove_document_conclusion_and_more.py

@@ -1,50 +0,0 @@
-# Generated by Django 4.2.29 on 2026-03-10 13:49
-
-from django.conf import settings
-from django.db import migrations, models
-import django.db.models.deletion
-
-
-class Migration(migrations.Migration):
-
-    dependencies = [
-        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
-        ('textdocs', '0001_initial'),
-    ]
-
-    operations = [
-        migrations.RemoveField(
-            model_name='document',
-            name='conclusion',
-        ),
-        migrations.RemoveField(
-            model_name='document',
-            name='introduction',
-        ),
-        migrations.RemoveField(
-            model_name='document',
-            name='main_body',
-        ),
-        migrations.AddField(
-            model_name='document',
-            name='author',
-            field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
-            preserve_default=False,
-        ),
-        migrations.CreateModel(
-            name='DocumentVersion',
-            fields=[
-                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
-                ('version_number', models.PositiveIntegerField()),
-                ('introduction', models.TextField()),
-                ('main_body', models.TextField()),
-                ('conclusion', models.TextField()),
-                ('created_at', models.DateTimeField(auto_now_add=True)),
-                ('document', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='versions', to='textdocs.document')),
-            ],
-            options={
-                'ordering': ['-version_number'],
-                'unique_together': {('document', 'version_number')},
-            },
-        ),
-    ]