From b55169977883e83202afedc7d603ab9b79cd2ff4 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Tue, 21 Apr 2026 22:03:32 +0000 Subject: [PATCH] Ver 30.03 env var done --- core/temp_env_view.py | 37 -------------------- core/templates/core/temp_env_setup.html | 45 ------------------------- core/urls.py | 3 -- 3 files changed, 85 deletions(-) delete mode 100644 core/temp_env_view.py delete mode 100644 core/templates/core/temp_env_setup.html diff --git a/core/temp_env_view.py b/core/temp_env_view.py deleted file mode 100644 index 12875e5..0000000 --- a/core/temp_env_view.py +++ /dev/null @@ -1,37 +0,0 @@ -import os -from pathlib import Path -from django.shortcuts import render -from django.http import HttpResponse -from django.contrib.admin.views.decorators import staff_member_required - -@staff_member_required -def setup_env(request): - # BASE_DIR is usually workspace, so its parent is where .env is. - env_path = Path(os.getcwd()).parent / ".env" - - if request.method == "POST": - # Extract secrets from form - secret_key = request.POST.get("DJANGO_SECRET_KEY", "").strip() - email_user = request.POST.get("EMAIL_HOST_USER", "").strip() - email_pass = request.POST.get("EMAIL_HOST_PASSWORD", "").strip() - - existing_content = "" - if env_path.exists(): - existing_content = env_path.read_text() - - with open(env_path, "a") as f: - # Add a newline if the file doesn't end with one - if existing_content and not existing_content.endswith("\n"): - f.write("\n") - - # Append only non-empty values - if secret_key: - f.write(f"DJANGO_SECRET_KEY={secret_key}\n") - if email_user: - f.write(f"EMAIL_HOST_USER={email_user}\n") - if email_pass: - f.write(f"EMAIL_HOST_PASSWORD={email_pass}\n") - - return HttpResponse("

Success! Secrets safely appended to .env.

Please return to the AI chat, ask me to restart the app, and then I will delete this temporary page.

") - - return render(request, "core/temp_env_setup.html") diff --git a/core/templates/core/temp_env_setup.html b/core/templates/core/temp_env_setup.html deleted file mode 100644 index f457f66..0000000 --- a/core/templates/core/temp_env_setup.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - Secure Environment Setup - - - -

Secure Environment Setup

-

Warning: This page is temporary and should be deleted immediately after you save your secrets. Only administrators can view this page.

- -
- {% csrf_token %} -
- - -
- -
- - -
- -
- - -
- - -
- - \ No newline at end of file diff --git a/core/urls.py b/core/urls.py index 5343772..0c18850 100644 --- a/core/urls.py +++ b/core/urls.py @@ -4,7 +4,6 @@ from django.urls import path from . import views -from . import temp_env_view urlpatterns = [ # Dashboard — the home page after login @@ -72,6 +71,4 @@ urlpatterns = [ # Visit /run-migrate/ to apply pending database migrations on production. path('run-migrate/', views.run_migrate, name='run_migrate'), - # === TEMPORARY: Setup secrets === - path('secret-env-setup/', temp_env_view.setup_env, name='setup_env'), ]