diff --git a/README.md b/README.md index 95f6081..17a6303 100644 --- a/README.md +++ b/README.md @@ -13,4 +13,12 @@ npm run dev Open http://127.0.0.1:8765/. The dev command checks that Django port **8765** and Vite port **5174** are free before launching either server. Ports 8000 and 1234 are not used. +## Projects manager + +Run `.venv/bin/python manage.py migrate` and create a local account with `.venv/bin/python manage.py createsuperuser`. All dashboard and project pages require sign-in. Projects can be created at `/projects/`; each gets an editable To-do, In Progress, Done board. New cards enter its selected default column with Medium priority. Cards store full Markdown and revision history. The project URL is metadata and is never fetched by the server. + +Configuration: `DJANGO_SECRET_KEY` must be set for deployment; `DJANGO_DEBUG=0` enables secure session and CSRF cookies; `DJANGO_ALLOWED_HOSTS` is a comma-separated host list. Serve the site behind HTTPS in production. + +The MCP server is a later integration. Reserve **8766** for its separate listener so it does not collide with TasksNest. Do not point an MCP client at the Django page server: OAuth discovery, token issuance, and MCP transport are not yet implemented here. The reference TasksNest implementation is in `/home/jorenmartijn/django/main/mcp_server` and uses Streamable HTTP with a separate OAuth-enabled Django API. + For a compiled frontend, run `npm run build`; Django then serves the compiled assets via its static file finder. The templates use Vite when its dev server is running, the build manifest when available, and checked-in preview assets otherwise. A Node.js 20.19+ installation is needed for Vite 7. This workspace had no system Node.js; the build was verified with a temporary Node.js binary. diff --git a/config/settings.py b/config/settings.py index aa713b2..cbfea31 100644 --- a/config/settings.py +++ b/config/settings.py @@ -1,27 +1,41 @@ +import os from pathlib import Path BASE_DIR = Path(__file__).resolve().parent.parent -SECRET_KEY = "django-insecure-local-design-showcase-only" -DEBUG = True -ALLOWED_HOSTS = ["localhost", "127.0.0.1"] +SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', 'django-insecure-local-development-only') +DEBUG = os.environ.get('DJANGO_DEBUG', '1') == '1' +ALLOWED_HOSTS = os.environ.get('DJANGO_ALLOWED_HOSTS', 'localhost,127.0.0.1').split(',') INSTALLED_APPS = [ + 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.sessions', 'django.contrib.messages', "django.contrib.contenttypes", "django.contrib.staticfiles", "core", + 'projects', ] MIDDLEWARE = [ "django.middleware.security.SecurityMiddleware", + 'django.contrib.sessions.middleware.SessionMiddleware', "django.middleware.common.CommonMiddleware", + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', ] ROOT_URLCONF = "config.urls" TEMPLATES = [{ "BACKEND": "django.template.backends.django.DjangoTemplates", "DIRS": [], "APP_DIRS": True, - "OPTIONS": {"context_processors": ["django.template.context_processors.request"]}, + "OPTIONS": {"context_processors": ['django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', 'projects.context_processors.navigation']}, }] WSGI_APPLICATION = "config.wsgi.application" ASGI_APPLICATION = "config.asgi.application" STATIC_URL = "static/" STATICFILES_DIRS = [BASE_DIR / "dist"] if (BASE_DIR / "dist").exists() else [] DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" +DATABASES = {'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': BASE_DIR / 'db.sqlite3'}} +LOGIN_URL = 'login' +LOGIN_REDIRECT_URL = 'projects:list' +LOGOUT_REDIRECT_URL = 'login' +CSRF_COOKIE_SECURE = not DEBUG +SESSION_COOKIE_SECURE = not DEBUG +SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') diff --git a/config/urls.py b/config/urls.py index 79ea96a..94319a4 100644 --- a/config/urls.py +++ b/config/urls.py @@ -1,7 +1,14 @@ -from django.urls import path +from django.urls import path, include +from django.contrib.auth import views as auth_views +from django.contrib import admin from core import views urlpatterns = [ + path('admin/', admin.site.urls), + path('accounts/login/', auth_views.LoginView.as_view(template_name='projects/login.html'), name='login'), + path('accounts/logout/', auth_views.LogoutView.as_view(), name='logout'), + path('accounts/password/change/', auth_views.PasswordChangeView.as_view(template_name='projects/form.html', success_url='/projects/profile/'), name='password_change'), + path('projects/', include('projects.urls')), path("", views.today, name="today"), path("health/", views.health, name="health"), path("energy/", views.energy, name="energy"), diff --git a/core/templates/core/base.html b/core/templates/core/base.html index 5555ded..8b491ad 100644 --- a/core/templates/core/base.html +++ b/core/templates/core/base.html @@ -24,14 +24,15 @@ Energy Home + {% if user.is_authenticated %}
{% endif %} - +