mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2026-01-01 23:27:02 -05:00
feat: Implement initial schema and add various API, service, and management command enhancements across the application.
This commit is contained in:
@@ -17,16 +17,16 @@ def search_for_tuple_fallbacks():
|
||||
|
||||
# Patterns that indicate tuple fallbacks
|
||||
choice_fallback_patterns = [
|
||||
r'choices\.get\([^,]+,\s*[^)]+\)', # choices.get(value, fallback)
|
||||
r'status_.*\.get\([^,]+,\s*[^)]+\)', # status_colors.get(value, fallback)
|
||||
r'category_.*\.get\([^,]+,\s*[^)]+\)', # category_images.get(value, fallback)
|
||||
r'sla_hours\.get\([^,]+,\s*[^)]+\)', # sla_hours.get(priority, fallback)
|
||||
r'get_tuple_choices\(', # get_tuple_choices function
|
||||
r'from_tuple\(', # from_tuple function
|
||||
r'convert_tuple_choices\(', # convert_tuple_choices function
|
||||
r"choices\.get\([^,]+,\s*[^)]+\)", # choices.get(value, fallback)
|
||||
r"status_.*\.get\([^,]+,\s*[^)]+\)", # status_colors.get(value, fallback)
|
||||
r"category_.*\.get\([^,]+,\s*[^)]+\)", # category_images.get(value, fallback)
|
||||
r"sla_hours\.get\([^,]+,\s*[^)]+\)", # sla_hours.get(priority, fallback)
|
||||
r"get_tuple_choices\(", # get_tuple_choices function
|
||||
r"from_tuple\(", # from_tuple function
|
||||
r"convert_tuple_choices\(", # convert_tuple_choices function
|
||||
]
|
||||
|
||||
apps_dir = Path('apps')
|
||||
apps_dir = Path("apps")
|
||||
if not apps_dir.exists():
|
||||
print("❌ Error: apps directory not found")
|
||||
return False
|
||||
@@ -34,24 +34,21 @@ def search_for_tuple_fallbacks():
|
||||
found_fallbacks = []
|
||||
|
||||
# Search all Python files in apps directory
|
||||
for py_file in apps_dir.rglob('*.py'):
|
||||
for py_file in apps_dir.rglob("*.py"):
|
||||
# Skip migrations (they're supposed to have hardcoded values)
|
||||
if 'migration' in str(py_file):
|
||||
if "migration" in str(py_file):
|
||||
continue
|
||||
|
||||
try:
|
||||
with open(py_file, encoding='utf-8') as f:
|
||||
with open(py_file, encoding="utf-8") as f:
|
||||
content = f.read()
|
||||
|
||||
for line_num, line in enumerate(content.split('\n'), 1):
|
||||
for line_num, line in enumerate(content.split("\n"), 1):
|
||||
for pattern in choice_fallback_patterns:
|
||||
if re.search(pattern, line):
|
||||
found_fallbacks.append({
|
||||
'file': py_file,
|
||||
'line': line_num,
|
||||
'content': line.strip(),
|
||||
'pattern': pattern
|
||||
})
|
||||
found_fallbacks.append(
|
||||
{"file": py_file, "line": line_num, "content": line.strip(), "pattern": pattern}
|
||||
)
|
||||
except Exception as e:
|
||||
print(f"❌ Error reading {py_file}: {e}")
|
||||
continue
|
||||
@@ -66,12 +63,14 @@ def search_for_tuple_fallbacks():
|
||||
print("✅ NO TUPLE FALLBACKS FOUND - All eliminated!")
|
||||
return True
|
||||
|
||||
|
||||
def verify_tuple_functions_removed():
|
||||
"""Verify that tuple fallback functions have been removed."""
|
||||
|
||||
# Check that get_tuple_choices is not importable
|
||||
try:
|
||||
from apps.core.choices.registry import get_tuple_choices # noqa: F401
|
||||
|
||||
print("❌ ERROR: get_tuple_choices function still exists!")
|
||||
return False
|
||||
except ImportError:
|
||||
@@ -80,18 +79,20 @@ def verify_tuple_functions_removed():
|
||||
# Check that Rich Choice objects work as primary source
|
||||
try:
|
||||
from apps.core.choices.registry import get_choices # noqa: F401
|
||||
|
||||
print("✅ get_choices function (Rich Choice objects) works as primary source")
|
||||
return True
|
||||
except ImportError:
|
||||
print("❌ ERROR: get_choices function missing!")
|
||||
return False
|
||||
|
||||
|
||||
def main():
|
||||
"""Main verification function."""
|
||||
print("=== TUPLE FALLBACK ELIMINATION VERIFICATION ===\n")
|
||||
|
||||
# Change to backend directory if needed
|
||||
if 'backend' not in os.getcwd():
|
||||
if "backend" not in os.getcwd():
|
||||
backend_dir = Path(__file__).parent
|
||||
os.chdir(backend_dir)
|
||||
print(f"Changed directory to: {os.getcwd()}")
|
||||
@@ -110,5 +111,6 @@ def main():
|
||||
print("❌ FAILURE: Tuple fallbacks still exist!")
|
||||
return 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
|
||||
Reference in New Issue
Block a user