Merge branch 'main' into storefront-nuxt
This commit is contained in:
commit
18c2f9c154
4 changed files with 55 additions and 8 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -165,3 +165,6 @@ cypress/screenshots/
|
||||||
|
|
||||||
# Development stuff
|
# Development stuff
|
||||||
test.ipynb
|
test.ipynb
|
||||||
|
|
||||||
|
# Production stuff
|
||||||
|
.initialized
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import logging
|
import logging
|
||||||
|
from datetime import datetime
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
@ -130,6 +131,24 @@ class Command(BaseCommand):
|
||||||
def handle(self, *args: list[Any], **options: dict[Any, Any]) -> None:
|
def handle(self, *args: list[Any], **options: dict[Any, Any]) -> None:
|
||||||
self.stdout.write("Initializing must-have instances...")
|
self.stdout.write("Initializing must-have instances...")
|
||||||
|
|
||||||
|
initialized_path = settings.BASE_DIR / ".initialized"
|
||||||
|
|
||||||
|
stored_date: datetime | None = None
|
||||||
|
if initialized_path.exists():
|
||||||
|
try:
|
||||||
|
content = initialized_path.read_text(encoding="utf-8").strip()
|
||||||
|
if content:
|
||||||
|
stored_date = datetime.fromisoformat(content)
|
||||||
|
except Exception as exc:
|
||||||
|
logger.warning("Failed to parse .initialized content: %s", exc)
|
||||||
|
|
||||||
|
if stored_date is None:
|
||||||
|
stored_date = datetime.min
|
||||||
|
|
||||||
|
if not (settings.RELEASE_DATE > stored_date):
|
||||||
|
self.stdout.write(self.style.WARNING("Initialization skipped: already up-to-date."))
|
||||||
|
return
|
||||||
|
|
||||||
Vendor.objects.get_or_create(name="INNER")
|
Vendor.objects.get_or_create(name="INNER")
|
||||||
|
|
||||||
user_support, is_user_support_created = Group.objects.get_or_create(name="User Support")
|
user_support, is_user_support_created = Group.objects.get_or_create(name="User Support")
|
||||||
|
|
@ -160,4 +179,9 @@ class Command(BaseCommand):
|
||||||
valid_codes = [code for code, _ in settings.LANGUAGES]
|
valid_codes = [code for code, _ in settings.LANGUAGES]
|
||||||
(User.objects.filter(Q(language="") | ~Q(language__in=valid_codes)).update(language=settings.LANGUAGE_CODE))
|
(User.objects.filter(Q(language="") | ~Q(language__in=valid_codes)).update(language=settings.LANGUAGE_CODE))
|
||||||
|
|
||||||
|
try:
|
||||||
|
initialized_path.write_text(settings.RELEASE_DATE.isoformat(), encoding="utf-8")
|
||||||
|
except Exception as exc:
|
||||||
|
logger.error("Failed to update .initialized file: %s", exc)
|
||||||
|
|
||||||
self.stdout.write(self.style.SUCCESS("Successfully initialized must-have instances!"))
|
self.stdout.write(self.style.SUCCESS("Successfully initialized must-have instances!"))
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,7 @@ async def forward_thread_message_to_assigned_staff(thread_uuid: str, text: str)
|
||||||
logger.warning("Failed to forward Telegram message for thread %s: %s", _tid, exc)
|
logger.warning("Failed to forward Telegram message for thread %s: %s", _tid, exc)
|
||||||
|
|
||||||
|
|
||||||
def install_aiohttp_webhook(app) -> None: # pragma: no cover - integration helper
|
def install_aiohttp_webhook(app) -> None:
|
||||||
if not is_telegram_enabled():
|
if not is_telegram_enabled():
|
||||||
logger.warning("Telegram forwarder not installed: disabled")
|
logger.warning("Telegram forwarder not installed: disabled")
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,16 @@ get_random_hex() {
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt_default() {
|
prompt_default() {
|
||||||
printf "Enter %s [%s]: " "$1" "$2"
|
if [ -t 0 ]; then
|
||||||
read -r response
|
printf "Enter %s [%s]: " "$1" "$2"
|
||||||
|
if read -r response </dev/tty; then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
response=""
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
response=""
|
||||||
|
fi
|
||||||
if [ -z "${response//[[:space:]]/}" ]; then
|
if [ -z "${response//[[:space:]]/}" ]; then
|
||||||
echo "$2"
|
echo "$2"
|
||||||
else
|
else
|
||||||
|
|
@ -18,8 +26,16 @@ prompt_default() {
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt_autogen() {
|
prompt_autogen() {
|
||||||
printf "Enter %s (leave blank to auto-generate): " "$1"
|
if [ -t 0 ]; then
|
||||||
read -r response
|
printf "Enter %s (leave blank to auto-generate): " "$1"
|
||||||
|
if read -r response </dev/tty; then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
response=""
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
response=""
|
||||||
|
fi
|
||||||
if [ -z "${response//[[:space:]]/}" ]; then
|
if [ -z "${response//[[:space:]]/}" ]; then
|
||||||
get_random_hex "$2"
|
get_random_hex "$2"
|
||||||
else
|
else
|
||||||
|
|
@ -29,8 +45,12 @@ prompt_autogen() {
|
||||||
|
|
||||||
if [ -f .env ]; then
|
if [ -f .env ]; then
|
||||||
echo ".env already exists and will be overwritten." >&2
|
echo ".env already exists and will be overwritten." >&2
|
||||||
printf "Press Enter to continue or Ctrl+C to abort"
|
if [ -t 0 ]; then
|
||||||
read -r
|
printf "Press Enter to continue or Ctrl+C to abort: "
|
||||||
|
read -r _ </dev/tty || true
|
||||||
|
else
|
||||||
|
echo "Non-interactive session detected; proceeding without prompt." >&2
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
EVIBES_PROJECT_NAME=$(prompt_default EVIBES_PROJECT_NAME eVibes)
|
EVIBES_PROJECT_NAME=$(prompt_default EVIBES_PROJECT_NAME eVibes)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue