$ python manage.py dumpdata ballot --format=json --indent=2 > ballot/fixtures/YYYYMMDD.json
, (ProTip: The date of the previous election's likely still kicking around in your ELECTION_DISPLAY_STRING
variable in your ballot/management/commands/ballot_settings.py
file! But if not, you can also look it up on the Lane County Elections site.) then, using the web admin delete all previous election data except for Regions
. Note: Running ballot_setup
(see below) also deletes Cand_yes_no
, Contest
and Contest_wrapper
leaves Region
intact, but you it needs to have the Election IDs loaded, which it probably doesn't at this point, so ... .chromedriver
to that seems to work is /usr/local/bin
.ballot/management/commands/ballot_settings.py
file so the scraper script can find it.ballot_upload_csv
(local). This tests out the Selenium grab of the .csv file from the Oregon Secretary of State web site. If successful, it gets you the Election IDs of all the contests, which you need to update ballot_settings.py
below.ELECTION_DISPLAY_STRING
in /management/commands/ballot_settings.py
with the Election Day date and the type of election (special, general, primary ... ).
NOTE: As
ballot_settings.py
isn't in version control, once you've got it updated, you will have to update this manually both on your local machine and the remote server. BUT DON'T COPY THE ENTIRE FILE!
FINAL
template variable in /management/commands/ballot_settings.py
to False (since it's probably set to True from the previous election being called final by the county clerk). This variable sets the "Unofficial/Official final" bit at the front of the title strings.LANE_CONTEST_IDS
in .../ballot_settings.py
prior to running ballot_setup
ballot_upload_csv
above, then Option
+ Command
+ Down Arrow
... but this won't get you the uniques, so you'll still need to upload to Googlge Sheet to remove dupe IDs.
Quick & dirty hack; import .csv into Google Sheet, copy ID column into another Sheet and run =UNIQUE(A:A)
on it from Column B. Copy & paste that column into BBEdit for grep cleanup (add indent & trailing comma).
NOTE: Only copy the
LANE_CONTEST_IDS
variable to theballot/management/commands/ballot_settings.py
file on the server (as opposed to copying the entireballot_settings.py
file). Thelocal
andremote
versions ofballot_settings.py
have different CSV_DIRECTORY locations! Also, remember to update remoteELECTION_DISPLAY_STRING
and anything else you had to update in the local version. Like any tweaks/updates made toCSV_FILE_NAMES
.
And you will need to reload your Python code for the template string settings to appear, i.e.,touch apache/django.wsgi
.
ballot_setup
(run it remote with LANE_CONTEST_IDS
edits that you made locally; a one-time-per-election thing) Ballot > Contests
to properly group the Federal, State, City etc. measures & races.
Pro Tip: Depending on the view that's powering your request, the quickest way to separate Measures from Races is the
is_race
attribute, which is easily edited in a bulk fashion from the adminContest
index view.
python manage.py ballot_upload_csv
(local; Uses Selenium to browser-fake JavaScript click to download .csv, uploads .csv file to server)python manage.py ballot_process_csv
(remote; insert .csv data in server db)python manage.py ballot_upload_json
(local; make JSON from URL requests, upload to AWS S3 bucket)ballot_settings.py
: local and remote: Different environmental settings for directories.
ballot_setup
: remote: After updating with new LANE_CONTEST_IDS
, run once. Deletes previous election data, sets up new election fields. If you're running it locally to test, it's looking for the .csv
files to be in the same directory as the script file (so you may need to copy them over from your Downloads
directory).
ballot_test_data_in
: both
ballot_test_data_reset
: both
ballot_clear_cache
: probably only remote Main web results page has a cached URL ('/ballot/results/full/') as well as a name template fragment cache ('main_results_table'). This clears both.
Current hacky set-up:
save_election_lane_setup_[YYYYMMDD].py
)election_lane_get_data_[YYYYMMDD].py
)election_oregon_sos_get_data_primary_[YYYYMMDD].py
) Note: There is no Oregon SOS set-up script as all the relevant races are driven by what's in the Lane County Elections races list.contest_wrapper
s, is_race
, web_front
, use_in_paper
, candidate names, race names.On Election Night repeat this cycle:
• Currently scripts run on projects.registerguard.com
from the /rgcalendar/oper/scripts
directory.
• The principal and significant difference between primaries and general/special elections is that primaries have two (or three) versions of each contest: Democratic, Republican and/or Independent.