feat(src/djinit): add Django‑Q and Celery configuration options to scaffolding
- New Features - Introduce `use_django_q` and `use_celery` boolean flags in the project metadata - Add UI prompts to confirm inclusion of Django‑Q2 and Celery when generating a project - Expose these flags to all file templates and context processing - Enhancements - Update context dictionaries and file generation to respect the new flags - Extend required files handling for unified and single project structures - Display Django‑Q2 and Celery choices in the final project summary output
This commit is contained in:
4 files changed
+75
-8
No files matched your search
@@ -21,6 +21,8 @@ class ProjectMetadata:
|
||||
use_vite: bool = False
|
||||
use_vue: bool = False
|
||||
use_pytest: bool = False
|
||||
use_django_q: bool = False
|
||||
use_celery: bool = False
|
||||
predefined_structure: bool = False
|
||||
unified_structure: bool = False
|
||||
single_structure: bool = False
|
||||
@@ -41,6 +43,7 @@ class ProjectMetadata:
|
||||
"use_vite": self.use_vite,
|
||||
"use_vue": self.use_vue,
|
||||
"use_pytest": self.use_pytest,
|
||||
"use_django_q": self.use_django_q,
|
||||
"predefined_structure": self.predefined_structure,
|
||||
"unified_structure": self.unified_structure,
|
||||
"single_structure": self.single_structure,
|
||||
|
||||
@@ -94,6 +94,8 @@ class FileCreator(BaseService):
|
||||
base_settings_context["use_vite"] = self.metadata.get("use_vite", False)
|
||||
base_settings_context["use_vue"] = self.metadata.get("use_vue", False)
|
||||
base_settings_context["use_pytest"] = self.metadata.get("use_pytest", False)
|
||||
base_settings_context["use_django_q"] = self.metadata.get("use_django_q", False)
|
||||
base_settings_context["use_celery"] = self.metadata.get("use_celery", False)
|
||||
|
||||
for filename, context in [
|
||||
("base.py", base_settings_context),
|
||||
@@ -146,6 +148,8 @@ class FileCreator(BaseService):
|
||||
"use_vite": self.metadata.get("use_vite", False),
|
||||
"use_vue": self.metadata.get("use_vue", False),
|
||||
"use_pytest": self.metadata.get("use_pytest", False),
|
||||
"use_django_q": self.metadata.get("use_django_q", False),
|
||||
"use_celery": self.metadata.get("use_celery", False),
|
||||
"module_name": self.module_name,
|
||||
"app_names": self.app_names,
|
||||
}
|
||||
|
||||
@@ -128,16 +128,51 @@ class ProjectCreator(BaseService):
|
||||
# Core Django project files
|
||||
required_files = [
|
||||
join("manage.py"),
|
||||
join(self.module_name, "__init__.py"),
|
||||
join(self.module_name, "settings", "__init__.py"),
|
||||
join(self.module_name, "settings", "base.py"),
|
||||
join(self.module_name, "settings", "development.py"),
|
||||
join(self.module_name, "settings", "production.py"),
|
||||
join(self.module_name, "urls.py"),
|
||||
join(self.module_name, "wsgi.py"),
|
||||
join(self.module_name, "asgi.py"),
|
||||
]
|
||||
|
||||
if self.metadata.get("unified_structure"):
|
||||
# Unified structure: settings in core/
|
||||
required_files.extend(
|
||||
[
|
||||
join("core", "__init__.py"),
|
||||
join("core", "settings", "__init__.py"),
|
||||
join("core", "settings", "base.py"),
|
||||
join("core", "settings", "development.py"),
|
||||
join("core", "settings", "production.py"),
|
||||
join("core", "urls.py"),
|
||||
join("core", "wsgi.py"),
|
||||
join("core", "asgi.py"),
|
||||
]
|
||||
)
|
||||
elif self.metadata.get("single_structure"):
|
||||
# Single structure: in project_name folder
|
||||
required_files.extend(
|
||||
[
|
||||
join(self.module_name, "__init__.py"),
|
||||
join(self.module_name, "settings", "__init__.py"),
|
||||
join(self.module_name, "settings", "base.py"),
|
||||
join(self.module_name, "settings", "development.py"),
|
||||
join(self.module_name, "settings", "production.py"),
|
||||
join(self.module_name, "urls.py"),
|
||||
join(self.module_name, "wsgi.py"),
|
||||
join(self.module_name, "asgi.py"),
|
||||
]
|
||||
)
|
||||
else:
|
||||
# Standard/Predefined structure
|
||||
required_files.extend(
|
||||
[
|
||||
join(self.module_name, "__init__.py"),
|
||||
join(self.module_name, "settings", "__init__.py"),
|
||||
join(self.module_name, "settings", "base.py"),
|
||||
join(self.module_name, "settings", "development.py"),
|
||||
join(self.module_name, "settings", "production.py"),
|
||||
join(self.module_name, "urls.py"),
|
||||
join(self.module_name, "wsgi.py"),
|
||||
join(self.module_name, "asgi.py"),
|
||||
]
|
||||
)
|
||||
|
||||
apps_base_dir = self._get_apps_base_dir()
|
||||
|
||||
if self.metadata.get("unified_structure"):
|
||||
|
||||
@@ -29,6 +29,8 @@ class StructureOptions(TypedDict):
|
||||
use_vite: bool
|
||||
use_vue: bool
|
||||
use_pytest: bool
|
||||
use_django_q: bool
|
||||
use_celery: bool
|
||||
use_github: bool
|
||||
use_gitlab: bool
|
||||
|
||||
@@ -195,6 +197,12 @@ class InputCollector:
|
||||
def get_pytest_choice(self) -> bool:
|
||||
return UIFormatter.confirm("Include pytest testing framework? (pytest, coverage)", default=True)
|
||||
|
||||
def get_django_q_choice(self) -> bool:
|
||||
return UIFormatter.confirm("Include Django-Q2? (async task queue)", default=False)
|
||||
|
||||
def get_celery_choice(self) -> bool:
|
||||
return UIFormatter.confirm("Include Celery? (async task queue)", default=False)
|
||||
|
||||
def _get_structure_metadata(self, options: StructureOptions) -> Tuple[str, str, list[str], dict]:
|
||||
"""Helper method to generate metadata dictionary."""
|
||||
project_dir = options["project_dir"]
|
||||
@@ -223,6 +231,7 @@ class InputCollector:
|
||||
use_vite=options.get("use_vite", False),
|
||||
use_vue=options.get("use_vue", False),
|
||||
use_pytest=options.get("use_pytest", False),
|
||||
use_django_q=options.get("use_django_q", False),
|
||||
predefined_structure=options["predefined"],
|
||||
unified_structure=options["unified"],
|
||||
single_structure=options["single"],
|
||||
@@ -296,6 +305,12 @@ def get_user_input() -> Tuple[str, str, str, list, dict]:
|
||||
# Step 7: pytest
|
||||
use_pytest = collector.get_pytest_choice()
|
||||
|
||||
# Step 8: Django-Q2
|
||||
use_django_q = collector.get_django_q_choice()
|
||||
|
||||
# Step 9: Celery
|
||||
use_celery = collector.get_celery_choice()
|
||||
|
||||
# Step 3: Django Apps (Standard only)
|
||||
nested = False
|
||||
nested_dir = None
|
||||
@@ -325,6 +340,8 @@ def get_user_input() -> Tuple[str, str, str, list, dict]:
|
||||
use_vite=use_vite,
|
||||
use_vue=use_vue,
|
||||
use_pytest=use_pytest,
|
||||
use_django_q=use_django_q,
|
||||
use_celery=use_celery,
|
||||
)
|
||||
return project_dir, project_name, app_names[0], app_names, metadata.to_dict()
|
||||
else:
|
||||
@@ -342,6 +359,8 @@ def get_user_input() -> Tuple[str, str, str, list, dict]:
|
||||
use_vite=use_vite,
|
||||
use_vue=use_vue,
|
||||
use_pytest=use_pytest,
|
||||
use_django_q=use_django_q,
|
||||
use_celery=use_celery,
|
||||
use_github=use_github,
|
||||
use_gitlab=use_gitlab,
|
||||
)
|
||||
@@ -392,6 +411,12 @@ def confirm_setup(project_dir: str, project_name: str, app_names: list, metadata
|
||||
use_vue = "Yes" if metadata.get("use_vue", False) else "No"
|
||||
console.print(f"[{UIColors.HIGHLIGHT}]Vite/Vue:[/{UIColors.HIGHLIGHT}] {use_vue}")
|
||||
|
||||
use_django_q = "Yes" if metadata.get("use_django_q", False) else "No"
|
||||
console.print(f"[{UIColors.HIGHLIGHT}]Django-Q2:[/{UIColors.HIGHLIGHT}] {use_django_q}")
|
||||
|
||||
use_celery = "Yes" if metadata.get("use_celery", False) else "No"
|
||||
console.print(f"[{UIColors.HIGHLIGHT}]Celery:[/{UIColors.HIGHLIGHT}] {use_celery}")
|
||||
|
||||
console.print()
|
||||
UIFormatter.print_separator()
|
||||
console.print()
|
||||
|
||||
Reference in new issue
Block a user