Skip to content

Commit 823f17e

Browse files
Merge remote-tracking branch 'origin' into views
2 parents c88f5bc + 2327032 commit 823f17e

File tree

9 files changed

+36
-21
lines changed

9 files changed

+36
-21
lines changed

.env

Lines changed: 0 additions & 4 deletions
This file was deleted.

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,4 +273,5 @@ mailpit
273273
thoughtswap/media/
274274

275275
.pytest_cache/
276-
.env
276+
.env
277+
*.sqlite3

config/asgi.py

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,42 @@
11
import os
2-
from django.core.asgi import get_asgi_application
2+
from pathlib import Path
3+
from django.core.asgi import get_asgi_application # num 1 of 4ish that have to
4+
# be in the correct order https://forum.djangoproject.com/t/i-get-the-error-apps-arent-loaded-yet-when-publishing-with-daphne/30320/14
35
from channels.routing import ProtocolTypeRouter, URLRouter
46
from channels.security.websocket import AllowedHostsOriginValidator
57
from channels.auth import AuthMiddlewareStack
6-
from thoughtswap.thoughtswap.routing import websocket_urlpatterns
7-
from thoughtswap.chat.routing import websocket_urlpatterns as thoughtswap_chat_routing
88

9-
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "thoughtswap.settings")
9+
import environ
10+
11+
BASE_DIR = Path(__file__).resolve(strict=True).parent.parent
12+
# thoughtswap/
13+
APPS_DIR = BASE_DIR / "thoughtswap"
14+
env = environ.Env()
15+
16+
READ_DOT_ENV_FILE = env.bool("DJANGO_READ_DOT_ENV_FILE", default=True)
17+
if READ_DOT_ENV_FILE:
18+
# OS environment variables take precedence over variables from .env
19+
env.read_env(str(BASE_DIR / ".env"))
20+
21+
sett = env("DJANGO_SETTINGS_MODULE")
22+
print("DJANGO_SETTINGS_MODULE before setting in asgi", sett)
23+
# os.environ.setdefault("DJANGO_SETTINGS_MODULE", "thoughtswap.settings")
24+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", sett) # num2
25+
26+
django_asgi_app = get_asgi_application() # num 3
27+
28+
from thoughtswap.thoughtswap.routing import websocket_urlpatterns # 4a
29+
from thoughtswap.chat.routing import websocket_urlpatterns as thoughtswap_chat_routing #4b
1030

11-
django_asgi_app = get_asgi_application()
1231

1332

1433
application = ProtocolTypeRouter(
1534
{
1635
"http": django_asgi_app,
1736
"websocket": AllowedHostsOriginValidator(
18-
AuthMiddlewareStack(URLRouter(websocket_urlpatterns+thoughtswap_chat_routing))
37+
AuthMiddlewareStack(
38+
URLRouter(websocket_urlpatterns + thoughtswap_chat_routing)
39+
)
1940
),
2041
}
2142
)

config/settings/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
),
5656
}
5757
DATABASES["default"]["ATOMIC_REQUESTS"] = True
58-
DATABASES["default"]["TEST"] = {"NAME": BASE_DIR / "db.sqlite3"}
58+
DATABASES["default"]["TEST"] = {"NAME": str(BASE_DIR / "test.sqlite3")}
5959
# https://docs.djangoproject.com/en/stable/ref/settings/#std:setting-DEFAULT_AUTO_FIELD
6060
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
6161

@@ -64,7 +64,7 @@
6464
# https://docs.djangoproject.com/en/dev/ref/settings/#root-urlconf
6565
ROOT_URLCONF = "config.urls"
6666
# https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application
67-
WSGI_APPLICATION = "config.wsgi.application"
67+
# WSGI_APPLICATION = "config.wsgi.application"
6868

6969
ASGI_APPLICATION = "config.asgi.application"
7070

config/settings/test.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
With these settings, tests run faster.
33
"""
44

5-
from .base import * # noqa: F403
6-
from .base import TEMPLATES
7-
from .base import env
8-
5+
from .local import * # noqa: F403
6+
from .local import TEMPLATES
7+
from .local import env
98
# GENERAL
109
# ------------------------------------------------------------------------------
1110
# https://docs.djangoproject.com/en/dev/ref/settings/#secret-key

requirements/local.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ django-debug-toolbar==5.0.1 # https://github.com/jazzband/django-debug-toolbar
3232
django-extensions==3.2.3 # https://github.com/django-extensions/django-extensions
3333
django-coverage-plugin==3.1.0 # https://github.com/nedbat/django_coverage_plugin
3434
pytest-django==4.9.0 # https://github.com/pytest-dev/pytest-django
35+
selenium==4.31.0

thoughtswap/thoughtswap/migrations/0003_seed_example_model_instances_20250324_0943.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def seed_mvp(apps, schema_editor):
108108
draft_session = Session.objects.create(
109109
course=course,
110110
state="a",
111-
begin="2025-03-24 09:43:00",
111+
begin="2025-04-27 01:16:53.260222+00:00",
112112
)
113113

114114
prompt_use = PromptUse.objects.create(

thoughtswap/thoughtswap/models.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ class Session(models.Model):
8181

8282
is_swapping = models.BooleanField(default=False)
8383

84-
8584
begin = models.DateTimeField(blank=True, null=True)
8685
end = models.DateTimeField(blank=True, null=True)
8786
created_at = models.DateTimeField(auto_now_add=True)
@@ -90,7 +89,6 @@ class Session(models.Model):
9089
def __str__(self):
9190
return f"{self.state}"
9291

93-
9492
# 2 use cases:
9593
# 1. prof wants to use this prompt in class tmr, so make it (the Prompt) today so they can just click it in realtime tmr (which would then instantiate the PromptUse). to be fully motivating we actually have to imagine they have 2 prompts in mind for tmr
9694
# 2. prof wants to use the prompt at the beginning of sem and then again at the end

thoughtswap/thoughtswap/views.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,3 @@ def add_prompt_to_bank(request):
165165
return JsonResponse({'status': 'ok', 'id': prompt.id})
166166
return JsonResponse({'error': 'invalid method'}, status=400)
167167

168-

0 commit comments

Comments
 (0)