From c82cb00013014fc97fcc561f42666f615f8d4801 Mon Sep 17 00:00:00 2001 From: James Ravenscroft Date: Fri, 20 Dec 2024 09:47:00 +0000 Subject: [PATCH] refactor project structure --- penparse/config/__init__.py | 3 ++ penparse/{penparse => config}/asgi.py | 0 penparse/{penparse => config}/celery.py | 0 penparse/{penparse => config}/settings.py | 8 +-- .../{penparse => config}/test_settings.py | 6 +-- penparse/config/urls.py | 26 +++++++++ penparse/{penparse => config}/wsgi.py | 0 penparse/manage.py | 2 +- penparse/penparse/__init__.py | 3 -- penparse/{webui => penparse}/admin.py | 0 penparse/{webui => penparse}/apps.py | 4 +- penparse/{webui => penparse}/auth.py | 0 penparse/{webui => penparse}/forms.py | 0 penparse/penparse/migrations/0001_initial.py | 51 ++++++++++++++++++ .../migrations/0002_imagememo.py | 8 +-- ...mo_image_mimetype_alter_imagememo_image.py | 2 +- .../migrations/0004_imagememo_status.py | 5 +- .../0005_imagememo_error_message.py | 2 +- .../migrations/0006_imagememo_model_name.py | 2 +- .../migrations}/__init__.py | 0 penparse/{webui => penparse}/models.py | 0 penparse/{webui => penparse}/tasks.py | 0 .../templates/dashboard.html | 0 .../templates/document.html | 0 .../{webui => penparse}/templates/index.html | 0 .../{webui => penparse}/templates/main.html | 0 .../templates/partial/nav.html | 0 .../templates/register.html | 0 .../templates/registration/login.html | 0 .../migrations => penparse/test}/__init__.py | 0 .../{webui => penparse}/test/data/example.gif | Bin .../{webui => penparse}/test/data/example.jpg | Bin .../{webui => penparse}/test/data/example.png | Bin .../test/test_delete_doc_view.py | 0 .../test/test_delete_document.py | 0 .../{webui => penparse}/test/test_tasks.py | 30 ++++++----- .../test/test_thumbnail_view.py | 0 penparse/penparse/urls.py | 44 +++++++-------- .../{webui => penparse}/views/__init__.py | 0 penparse/{webui => penparse}/views/delete.py | 0 .../{webui => penparse}/views/register.py | 0 .../{webui => penparse}/views/thumbnail.py | 0 penparse/{webui => penparse}/views/upload.py | 0 penparse/webui/migrations/0001_initial.py | 42 --------------- penparse/webui/test/__init__.py | 0 penparse/webui/urls.py | 26 --------- 46 files changed, 141 insertions(+), 123 deletions(-) create mode 100644 penparse/config/__init__.py rename penparse/{penparse => config}/asgi.py (100%) rename penparse/{penparse => config}/celery.py (100%) rename penparse/{penparse => config}/settings.py (96%) rename penparse/{penparse => config}/test_settings.py (97%) create mode 100644 penparse/config/urls.py rename penparse/{penparse => config}/wsgi.py (100%) rename penparse/{webui => penparse}/admin.py (100%) rename penparse/{webui => penparse}/apps.py (62%) rename penparse/{webui => penparse}/auth.py (100%) rename penparse/{webui => penparse}/forms.py (100%) create mode 100644 penparse/penparse/migrations/0001_initial.py rename penparse/{webui => penparse}/migrations/0002_imagememo.py (74%) rename penparse/{webui => penparse}/migrations/0003_imagememo_image_mimetype_alter_imagememo_image.py (93%) rename penparse/{webui => penparse}/migrations/0004_imagememo_status.py (63%) rename penparse/{webui => penparse}/migrations/0005_imagememo_error_message.py (87%) rename penparse/{webui => penparse}/migrations/0006_imagememo_model_name.py (86%) rename penparse/{webui => penparse/migrations}/__init__.py (100%) rename penparse/{webui => penparse}/models.py (100%) rename penparse/{webui => penparse}/tasks.py (100%) rename penparse/{webui => penparse}/templates/dashboard.html (100%) rename penparse/{webui => penparse}/templates/document.html (100%) rename penparse/{webui => penparse}/templates/index.html (100%) rename penparse/{webui => penparse}/templates/main.html (100%) rename penparse/{webui => penparse}/templates/partial/nav.html (100%) rename penparse/{webui => penparse}/templates/register.html (100%) rename penparse/{webui => penparse}/templates/registration/login.html (100%) rename penparse/{webui/migrations => penparse/test}/__init__.py (100%) rename penparse/{webui => penparse}/test/data/example.gif (100%) rename penparse/{webui => penparse}/test/data/example.jpg (100%) rename penparse/{webui => penparse}/test/data/example.png (100%) rename penparse/{webui => penparse}/test/test_delete_doc_view.py (100%) rename penparse/{webui => penparse}/test/test_delete_document.py (100%) rename penparse/{webui => penparse}/test/test_tasks.py (78%) rename penparse/{webui => penparse}/test/test_thumbnail_view.py (100%) rename penparse/{webui => penparse}/views/__init__.py (100%) rename penparse/{webui => penparse}/views/delete.py (100%) rename penparse/{webui => penparse}/views/register.py (100%) rename penparse/{webui => penparse}/views/thumbnail.py (100%) rename penparse/{webui => penparse}/views/upload.py (100%) delete mode 100644 penparse/webui/migrations/0001_initial.py delete mode 100644 penparse/webui/test/__init__.py delete mode 100644 penparse/webui/urls.py diff --git a/penparse/config/__init__.py b/penparse/config/__init__.py new file mode 100644 index 0000000..fb989c4 --- /dev/null +++ b/penparse/config/__init__.py @@ -0,0 +1,3 @@ +from .celery import app as celery_app + +__all__ = ('celery_app',) diff --git a/penparse/penparse/asgi.py b/penparse/config/asgi.py similarity index 100% rename from penparse/penparse/asgi.py rename to penparse/config/asgi.py diff --git a/penparse/penparse/celery.py b/penparse/config/celery.py similarity index 100% rename from penparse/penparse/celery.py rename to penparse/config/celery.py diff --git a/penparse/penparse/settings.py b/penparse/config/settings.py similarity index 96% rename from penparse/penparse/settings.py rename to penparse/config/settings.py index 8d61310..2b9db62 100644 --- a/penparse/penparse/settings.py +++ b/penparse/config/settings.py @@ -42,7 +42,7 @@ INSTALLED_APPS = [ "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", - "webui", + "penparse", "markdown_deux", "markdownify.apps.MarkdownifyConfig", "rest_framework", @@ -129,9 +129,9 @@ AUTH_PASSWORD_VALIDATORS = [ LOGIN_REDIRECT_URL = "/dashboard" -AUTH_USER_MODEL = "webui.User" +AUTH_USER_MODEL = "penparse.User" -AUTHENTICATION_BACKENDS = ["webui.auth.EmailBackend"] +AUTHENTICATION_BACKENDS = ["penparse.auth.EmailBackend"] # Internationalization # https://docs.djangoproject.com/en/4.2/topics/i18n/ @@ -156,7 +156,7 @@ STATIC_URL = "static/" DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" -CELERY_BROKER_URL = "amqp://guest:guest@localhost/" +CELERY_BROKER_URL = os.getenv("CELERY_BROKER_URL") OPENAI_API_BASE = os.getenv("OPENAI_API_BASE") diff --git a/penparse/penparse/test_settings.py b/penparse/config/test_settings.py similarity index 97% rename from penparse/penparse/test_settings.py rename to penparse/config/test_settings.py index ae8b473..ab6394b 100644 --- a/penparse/penparse/test_settings.py +++ b/penparse/config/test_settings.py @@ -37,7 +37,7 @@ INSTALLED_APPS = [ "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", - "webui", + "penparse", "markdown_deux", "markdownify.apps.MarkdownifyConfig", "rest_framework", @@ -115,9 +115,9 @@ AUTH_PASSWORD_VALIDATORS = [ LOGIN_REDIRECT_URL = "/dashboard" -AUTH_USER_MODEL = "webui.User" +AUTH_USER_MODEL = "penparse.User" -AUTHENTICATION_BACKENDS = ["webui.auth.EmailBackend"] +AUTHENTICATION_BACKENDS = ["penparse.auth.EmailBackend"] # Internationalization # https://docs.djangoproject.com/en/4.2/topics/i18n/ diff --git a/penparse/config/urls.py b/penparse/config/urls.py new file mode 100644 index 0000000..06623b1 --- /dev/null +++ b/penparse/config/urls.py @@ -0,0 +1,26 @@ +""" +URL configuration for penparse project. + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/4.2/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.urls import include, path +from django.contrib import admin +from django.urls import path, include + +urlpatterns = [ + path("", include("penparse.urls")), + path('admin/', admin.site.urls), + path("accounts/", include("django.contrib.auth.urls")), + +] diff --git a/penparse/penparse/wsgi.py b/penparse/config/wsgi.py similarity index 100% rename from penparse/penparse/wsgi.py rename to penparse/config/wsgi.py diff --git a/penparse/manage.py b/penparse/manage.py index 82a4f07..8e7ac79 100755 --- a/penparse/manage.py +++ b/penparse/manage.py @@ -6,7 +6,7 @@ import sys def main(): """Run administrative tasks.""" - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'penparse.settings') + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings') try: from django.core.management import execute_from_command_line except ImportError as exc: diff --git a/penparse/penparse/__init__.py b/penparse/penparse/__init__.py index fb989c4..e69de29 100644 --- a/penparse/penparse/__init__.py +++ b/penparse/penparse/__init__.py @@ -1,3 +0,0 @@ -from .celery import app as celery_app - -__all__ = ('celery_app',) diff --git a/penparse/webui/admin.py b/penparse/penparse/admin.py similarity index 100% rename from penparse/webui/admin.py rename to penparse/penparse/admin.py diff --git a/penparse/webui/apps.py b/penparse/penparse/apps.py similarity index 62% rename from penparse/webui/apps.py rename to penparse/penparse/apps.py index 79af5f3..cebdb8c 100644 --- a/penparse/webui/apps.py +++ b/penparse/penparse/apps.py @@ -1,6 +1,6 @@ from django.apps import AppConfig -class WebuiConfig(AppConfig): +class PenParseConfig(AppConfig): default_auto_field = 'django.db.models.BigAutoField' - name = 'webui' + name = 'penparse' diff --git a/penparse/webui/auth.py b/penparse/penparse/auth.py similarity index 100% rename from penparse/webui/auth.py rename to penparse/penparse/auth.py diff --git a/penparse/webui/forms.py b/penparse/penparse/forms.py similarity index 100% rename from penparse/webui/forms.py rename to penparse/penparse/forms.py diff --git a/penparse/penparse/migrations/0001_initial.py b/penparse/penparse/migrations/0001_initial.py new file mode 100644 index 0000000..c3b5995 --- /dev/null +++ b/penparse/penparse/migrations/0001_initial.py @@ -0,0 +1,51 @@ +# Generated by Django 4.2.16 on 2024-11-30 06:31 + +from django.db import migrations, models +import django.utils.timezone +import penparse.models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('auth', '0012_alter_user_first_name_max_length'), + ] + + operations = [ + migrations.CreateModel( + name='User', + fields=[ + ('id', models.BigAutoField(auto_created=True, + primary_key=True, serialize=False, verbose_name='ID')), + ('password', models.CharField( + max_length=128, verbose_name='password')), + ('last_login', models.DateTimeField( + blank=True, null=True, verbose_name='last login')), + ('is_superuser', models.BooleanField(default=False, + help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), + ('is_staff', models.BooleanField(default=False, + help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')), + ('is_active', models.BooleanField( + default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), + ('date_joined', models.DateTimeField( + default=django.utils.timezone.now, verbose_name='date joined')), + ('email', models.EmailField(max_length=254, unique=True)), + ('first_name', models.CharField(max_length=150)), + ('last_name', models.CharField(max_length=150)), + ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', + related_name='user_set', related_query_name='user', to='auth.group', verbose_name='groups')), + ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', + related_name='user_set', related_query_name='user', to='auth.permission', verbose_name='user permissions')), + ], + options={ + 'verbose_name': 'user', + 'verbose_name_plural': 'users', + 'abstract': False, + }, + managers=[ + ('objects', penparse.models.UserManager()), + ], + ), + ] diff --git a/penparse/webui/migrations/0002_imagememo.py b/penparse/penparse/migrations/0002_imagememo.py similarity index 74% rename from penparse/webui/migrations/0002_imagememo.py rename to penparse/penparse/migrations/0002_imagememo.py index 9944d42..6b7208f 100644 --- a/penparse/webui/migrations/0002_imagememo.py +++ b/penparse/penparse/migrations/0002_imagememo.py @@ -9,19 +9,21 @@ import uuid class Migration(migrations.Migration): dependencies = [ - ('webui', '0001_initial'), + ('penparse', '0001_initial'), ] operations = [ migrations.CreateModel( name='ImageMemo', fields=[ - ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), + ('id', models.UUIDField(default=uuid.uuid4, + editable=False, primary_key=True, serialize=False)), ('image', models.ImageField(upload_to='')), ('content', models.TextField()), ('created_at', models.DateTimeField(auto_now_add=True)), ('updated_at', models.DateTimeField(auto_now=True)), - ('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='memos', to=settings.AUTH_USER_MODEL)), + ('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, + related_name='memos', to=settings.AUTH_USER_MODEL)), ], options={ 'ordering': ['-created_at'], diff --git a/penparse/webui/migrations/0003_imagememo_image_mimetype_alter_imagememo_image.py b/penparse/penparse/migrations/0003_imagememo_image_mimetype_alter_imagememo_image.py similarity index 93% rename from penparse/webui/migrations/0003_imagememo_image_mimetype_alter_imagememo_image.py rename to penparse/penparse/migrations/0003_imagememo_image_mimetype_alter_imagememo_image.py index f99503e..fedcd95 100644 --- a/penparse/webui/migrations/0003_imagememo_image_mimetype_alter_imagememo_image.py +++ b/penparse/penparse/migrations/0003_imagememo_image_mimetype_alter_imagememo_image.py @@ -6,7 +6,7 @@ from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ('webui', '0002_imagememo'), + ('penparse', '0002_imagememo'), ] operations = [ diff --git a/penparse/webui/migrations/0004_imagememo_status.py b/penparse/penparse/migrations/0004_imagememo_status.py similarity index 63% rename from penparse/webui/migrations/0004_imagememo_status.py rename to penparse/penparse/migrations/0004_imagememo_status.py index b101864..4f4c53e 100644 --- a/penparse/webui/migrations/0004_imagememo_status.py +++ b/penparse/penparse/migrations/0004_imagememo_status.py @@ -6,13 +6,14 @@ from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ('webui', '0003_imagememo_image_mimetype_alter_imagememo_image'), + ('penparse', '0003_imagememo_image_mimetype_alter_imagememo_image'), ] operations = [ migrations.AddField( model_name='imagememo', name='status', - field=models.CharField(choices=[('pending', 'Pending'), ('processing', 'Processing'), ('done', 'Done'), ('error', 'Error')], default='pending', max_length=10), + field=models.CharField(choices=[('pending', 'Pending'), ('processing', 'Processing'), ( + 'done', 'Done'), ('error', 'Error')], default='pending', max_length=10), ), ] diff --git a/penparse/webui/migrations/0005_imagememo_error_message.py b/penparse/penparse/migrations/0005_imagememo_error_message.py similarity index 87% rename from penparse/webui/migrations/0005_imagememo_error_message.py rename to penparse/penparse/migrations/0005_imagememo_error_message.py index 706227a..e7835e1 100644 --- a/penparse/webui/migrations/0005_imagememo_error_message.py +++ b/penparse/penparse/migrations/0005_imagememo_error_message.py @@ -6,7 +6,7 @@ from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ('webui', '0004_imagememo_status'), + ('penparse', '0004_imagememo_status'), ] operations = [ diff --git a/penparse/webui/migrations/0006_imagememo_model_name.py b/penparse/penparse/migrations/0006_imagememo_model_name.py similarity index 86% rename from penparse/webui/migrations/0006_imagememo_model_name.py rename to penparse/penparse/migrations/0006_imagememo_model_name.py index 9cddff6..040050d 100644 --- a/penparse/webui/migrations/0006_imagememo_model_name.py +++ b/penparse/penparse/migrations/0006_imagememo_model_name.py @@ -6,7 +6,7 @@ from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ('webui', '0005_imagememo_error_message'), + ('penparse', '0005_imagememo_error_message'), ] operations = [ diff --git a/penparse/webui/__init__.py b/penparse/penparse/migrations/__init__.py similarity index 100% rename from penparse/webui/__init__.py rename to penparse/penparse/migrations/__init__.py diff --git a/penparse/webui/models.py b/penparse/penparse/models.py similarity index 100% rename from penparse/webui/models.py rename to penparse/penparse/models.py diff --git a/penparse/webui/tasks.py b/penparse/penparse/tasks.py similarity index 100% rename from penparse/webui/tasks.py rename to penparse/penparse/tasks.py diff --git a/penparse/webui/templates/dashboard.html b/penparse/penparse/templates/dashboard.html similarity index 100% rename from penparse/webui/templates/dashboard.html rename to penparse/penparse/templates/dashboard.html diff --git a/penparse/webui/templates/document.html b/penparse/penparse/templates/document.html similarity index 100% rename from penparse/webui/templates/document.html rename to penparse/penparse/templates/document.html diff --git a/penparse/webui/templates/index.html b/penparse/penparse/templates/index.html similarity index 100% rename from penparse/webui/templates/index.html rename to penparse/penparse/templates/index.html diff --git a/penparse/webui/templates/main.html b/penparse/penparse/templates/main.html similarity index 100% rename from penparse/webui/templates/main.html rename to penparse/penparse/templates/main.html diff --git a/penparse/webui/templates/partial/nav.html b/penparse/penparse/templates/partial/nav.html similarity index 100% rename from penparse/webui/templates/partial/nav.html rename to penparse/penparse/templates/partial/nav.html diff --git a/penparse/webui/templates/register.html b/penparse/penparse/templates/register.html similarity index 100% rename from penparse/webui/templates/register.html rename to penparse/penparse/templates/register.html diff --git a/penparse/webui/templates/registration/login.html b/penparse/penparse/templates/registration/login.html similarity index 100% rename from penparse/webui/templates/registration/login.html rename to penparse/penparse/templates/registration/login.html diff --git a/penparse/webui/migrations/__init__.py b/penparse/penparse/test/__init__.py similarity index 100% rename from penparse/webui/migrations/__init__.py rename to penparse/penparse/test/__init__.py diff --git a/penparse/webui/test/data/example.gif b/penparse/penparse/test/data/example.gif similarity index 100% rename from penparse/webui/test/data/example.gif rename to penparse/penparse/test/data/example.gif diff --git a/penparse/webui/test/data/example.jpg b/penparse/penparse/test/data/example.jpg similarity index 100% rename from penparse/webui/test/data/example.jpg rename to penparse/penparse/test/data/example.jpg diff --git a/penparse/webui/test/data/example.png b/penparse/penparse/test/data/example.png similarity index 100% rename from penparse/webui/test/data/example.png rename to penparse/penparse/test/data/example.png diff --git a/penparse/webui/test/test_delete_doc_view.py b/penparse/penparse/test/test_delete_doc_view.py similarity index 100% rename from penparse/webui/test/test_delete_doc_view.py rename to penparse/penparse/test/test_delete_doc_view.py diff --git a/penparse/webui/test/test_delete_document.py b/penparse/penparse/test/test_delete_document.py similarity index 100% rename from penparse/webui/test/test_delete_document.py rename to penparse/penparse/test/test_delete_document.py diff --git a/penparse/webui/test/test_tasks.py b/penparse/penparse/test/test_tasks.py similarity index 78% rename from penparse/webui/test/test_tasks.py rename to penparse/penparse/test/test_tasks.py index a6488f1..4348c61 100644 --- a/penparse/webui/test/test_tasks.py +++ b/penparse/penparse/test/test_tasks.py @@ -13,7 +13,8 @@ class TestProcessMemo: @pytest.fixture def sample_image_memo(self, db): - user1 = User.objects.create_user(email="user1@test.com", password="password1") + user1 = User.objects.create_user( + email="user1@test.com", password="password1") memo = ImageMemo.objects.create( author=user1, status=MemoStatus.Pending, @@ -23,9 +24,10 @@ class TestProcessMemo: return memo def test_process_memo_success(self, sample_image_memo): - with patch("webui.tasks.litellm") as mock_litellm: + with patch("penparse.tasks.litellm") as mock_litellm: mock_response = MagicMock() - mock_response.choices[0].message = {"content": "Transcribed content"} + mock_response.choices[0].message = { + "content": "Transcribed content"} mock_litellm.completion.return_value = mock_response process_memo(sample_image_memo.id) @@ -45,10 +47,12 @@ class TestProcessMemo: assert "Image file" in processed_memo.error_message def test_process_memo_api_error(self, sample_image_memo): - with patch("webui.tasks.litellm") as mock_litellm: + with patch("penparse.tasks.litellm") as mock_litellm: mock_response = MagicMock() - mock_response.choices[0].message = {"content": "Transcribed content"} - mock_litellm.completion.side_effect = litellm.APIError(400, "API Error", "openai", "any") + mock_response.choices[0].message = { + "content": "Transcribed content"} + mock_litellm.completion.side_effect = litellm.APIError( + 400, "API Error", "openai", "any") process_memo(sample_image_memo.id) @@ -58,11 +62,12 @@ class TestProcessMemo: def test_process_memo_sets_model_name(self, sample_image_memo): with ( - patch("webui.tasks.litellm") as mock_litellm, - patch("webui.tasks.settings") as mock_settings, + patch("penparse.tasks.litellm") as mock_litellm, + patch("penparse.tasks.settings") as mock_settings, ): mock_response = MagicMock() - mock_response.choices[0].message = {"content": "Transcribed content"} + mock_response.choices[0].message = { + "content": "Transcribed content"} mock_litellm.completion.return_value = mock_response mock_settings.OPENAI_MODEL = "test-model" @@ -73,11 +78,12 @@ class TestProcessMemo: def test_process_memo_uses_correct_api_settings(self, sample_image_memo): with ( - patch("webui.tasks.litellm") as mock_litellm, - patch("webui.tasks.settings") as mock_settings, + patch("penparse.tasks.litellm") as mock_litellm, + patch("penparse.tasks.settings") as mock_settings, ): mock_response = MagicMock() - mock_response.choices[0].message = {"content": "Transcribed content"} + mock_response.choices[0].message = { + "content": "Transcribed content"} mock_litellm.completion.return_value = mock_response mock_settings.OPENAI_API_BASE = "https://test-api-base.com" mock_settings.OPENAI_API_KEY = "test-api-key" diff --git a/penparse/webui/test/test_thumbnail_view.py b/penparse/penparse/test/test_thumbnail_view.py similarity index 100% rename from penparse/webui/test/test_thumbnail_view.py rename to penparse/penparse/test/test_thumbnail_view.py diff --git a/penparse/penparse/urls.py b/penparse/penparse/urls.py index 2843830..0125ef3 100644 --- a/penparse/penparse/urls.py +++ b/penparse/penparse/urls.py @@ -1,26 +1,26 @@ -""" -URL configuration for penparse project. +from django.urls import path -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/4.2/topics/http/urls/ -Examples: -Function views - 1. Add an import: from my_app import views - 2. Add a URL to urlpatterns: path('', views.home, name='home') -Class-based views - 1. Add an import: from other_app.views import Home - 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') -Including another URLconf - 1. Import the include() function: from django.urls import include, path - 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) -""" -from django.urls import include, path -from django.contrib import admin -from django.urls import path, include +from . import views urlpatterns = [ - path("", include("webui.urls")), - path('admin/', admin.site.urls), - path("accounts/", include("django.contrib.auth.urls")), - + path("", views.index, name="index"), + path("dashboard", views.dashboard, name="dashboard"), + path("settings", views.settings, name="settings"), + path("documents/upload", views.upload_document, name="upload_document"), + path("documents/", views.view_document, name="view_document"), + path( + "documents//thumbnail", + views.document_thumbnail, + name="document_thumbnail", + ), + path( + "documents//image", + views.document_image, + name="document_image", + ), + path( + "documents//download", views.download_document, name="download_document" + ), + path("documents//delete", views.delete_document, name="delete_document"), + path("auth/register", views.register, name="register"), ] diff --git a/penparse/webui/views/__init__.py b/penparse/penparse/views/__init__.py similarity index 100% rename from penparse/webui/views/__init__.py rename to penparse/penparse/views/__init__.py diff --git a/penparse/webui/views/delete.py b/penparse/penparse/views/delete.py similarity index 100% rename from penparse/webui/views/delete.py rename to penparse/penparse/views/delete.py diff --git a/penparse/webui/views/register.py b/penparse/penparse/views/register.py similarity index 100% rename from penparse/webui/views/register.py rename to penparse/penparse/views/register.py diff --git a/penparse/webui/views/thumbnail.py b/penparse/penparse/views/thumbnail.py similarity index 100% rename from penparse/webui/views/thumbnail.py rename to penparse/penparse/views/thumbnail.py diff --git a/penparse/webui/views/upload.py b/penparse/penparse/views/upload.py similarity index 100% rename from penparse/webui/views/upload.py rename to penparse/penparse/views/upload.py diff --git a/penparse/webui/migrations/0001_initial.py b/penparse/webui/migrations/0001_initial.py deleted file mode 100644 index 79ad4da..0000000 --- a/penparse/webui/migrations/0001_initial.py +++ /dev/null @@ -1,42 +0,0 @@ -# Generated by Django 4.2.16 on 2024-11-30 06:31 - -from django.db import migrations, models -import django.utils.timezone -import webui.models - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - ('auth', '0012_alter_user_first_name_max_length'), - ] - - operations = [ - migrations.CreateModel( - name='User', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('password', models.CharField(max_length=128, verbose_name='password')), - ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), - ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), - ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')), - ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), - ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), - ('email', models.EmailField(max_length=254, unique=True)), - ('first_name', models.CharField(max_length=150)), - ('last_name', models.CharField(max_length=150)), - ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.group', verbose_name='groups')), - ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.permission', verbose_name='user permissions')), - ], - options={ - 'verbose_name': 'user', - 'verbose_name_plural': 'users', - 'abstract': False, - }, - managers=[ - ('objects', webui.models.UserManager()), - ], - ), - ] diff --git a/penparse/webui/test/__init__.py b/penparse/webui/test/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/penparse/webui/urls.py b/penparse/webui/urls.py deleted file mode 100644 index 0125ef3..0000000 --- a/penparse/webui/urls.py +++ /dev/null @@ -1,26 +0,0 @@ -from django.urls import path - -from . import views - -urlpatterns = [ - path("", views.index, name="index"), - path("dashboard", views.dashboard, name="dashboard"), - path("settings", views.settings, name="settings"), - path("documents/upload", views.upload_document, name="upload_document"), - path("documents/", views.view_document, name="view_document"), - path( - "documents//thumbnail", - views.document_thumbnail, - name="document_thumbnail", - ), - path( - "documents//image", - views.document_image, - name="document_image", - ), - path( - "documents//download", views.download_document, name="download_document" - ), - path("documents//delete", views.delete_document, name="delete_document"), - path("auth/register", views.register, name="register"), -]