Skip to content

Instantly share code, notes, and snippets.

@takinbo
Created November 22, 2023 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takinbo/01a08dfde112b8298de103e1ad11a4b2 to your computer and use it in GitHub Desktop.
Save takinbo/01a08dfde112b8298de103e1ad11a4b2 to your computer and use it in GitHub Desktop.
Apollo snippet to updated submissions to use the same location as their participants
from apollo.models import Event, Submission, Form
event_name = ''
form_name = ''
ev = Event.query.filter(Event.name==event_name).first()
form = Form.query.filter(Form.name==form_name).first()
to_fix = 0
for sb in Submission.query.filter(Submission.form==form, Submission.event==ev, Submission.submission_type=="O"):
if sb.location != sb.participant.location:
to_fix += 1
print("{} submission(s) to update...".format(to_fix))
for sb in Submission.query.filter(Submission.form==form, Submission.event==ev, Submission.submission_type=="O"):
if sb.location != sb.participant.location:
sb.location = sb.participant.location
sb.master.location = sb.participant.location
sb.master.save()
sb.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment