Created
November 22, 2023 10:39
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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