Fixed ElectionAdmin query bug. Refactored query code into database.py