41 lines
1.5 KiB
Python
41 lines
1.5 KiB
Python
#!/usr/bin/env python
|
|
"""
|
|
Script to verify survey URLs
|
|
"""
|
|
import os
|
|
import django
|
|
|
|
# Setup Django
|
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings.dev')
|
|
django.setup()
|
|
|
|
from apps.surveys.models import SurveyInstance
|
|
|
|
# Check if the survey instance exists
|
|
token = 'H8d9tlVs0BgeAp1XA4NczXoiCcqAaN0r_lc0Eb63U1Y'
|
|
|
|
try:
|
|
survey = SurveyInstance.objects.get(access_token=token)
|
|
print(f'\n✓ Survey instance found!')
|
|
print(f' ID: {survey.id}')
|
|
print(f' Template: {survey.survey_template.name}')
|
|
print(f' Patient: {survey.patient.get_full_name()}')
|
|
print(f' Status: {survey.status}')
|
|
print(f' Created: {survey.created_at}')
|
|
print(f'\nCorrect URLs:')
|
|
print(f' Public Form: http://localhost:8000/surveys/s/{survey.access_token}/')
|
|
print(f' Thank You: http://localhost:8000/surveys/s/{survey.access_token}/thank-you/')
|
|
print(f'\nAdmin URLs:')
|
|
print(f' Detail: http://localhost:8000/surveys/instances/{survey.id}/')
|
|
print(f' List: http://localhost:8000/surveys/instances/\n')
|
|
except SurveyInstance.DoesNotExist:
|
|
print(f'\n✗ Survey instance with token "{token}" not found!')
|
|
print(f'\nAvailable survey instances:')
|
|
surveys = SurveyInstance.objects.all()[:10]
|
|
if surveys:
|
|
for s in surveys:
|
|
print(f' - {s.access_token}: {s.survey_template.name} ({s.status})')
|
|
print(f' URL: http://localhost:8000/surveys/s/{s.access_token}/')
|
|
else:
|
|
print(f' No survey instances found. Run create_test_survey.py first.\n')
|