37769-vm/test_voter_status.py
2026-05-30 08:01:02 +00:00

39 lines
1.1 KiB
Python

import os
import django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
django.setup()
from core.models import Voter, Tenant
def test():
tenant = Tenant.objects.first()
if not tenant:
tenant = Tenant.objects.create(name="Test Tenant")
# Create a voter that is targeted and needs a call
voter = Voter.objects.create(
tenant=tenant,
first_name="Test",
last_name="Voter",
is_targeted=True,
target_door_visit=True,
call_queue_status='to_be_called',
voted=False
)
print(f"Before: voted={voter.voted}, target_door_visit={voter.target_door_visit}, call_queue_status='{voter.call_queue_status}'")
# Update voted to True
voter.voted = True
voter.save()
# Refresh from DB
voter.refresh_from_db()
print(f"After: voted={voter.voted}, target_door_visit={voter.target_door_visit}, call_queue_status='{voter.call_queue_status}'")
# Clean up if needed, but maybe leave it for now
# voter.delete()
if __name__ == "__main__":
test()