def process_upload(upload_file, instance, form, event, request):
caption = form.cleaned_data.get('<STR_LIT>')<EOL>upload_name = upload_file.name.lower()<EOL>if upload_name.endswith('<STR_LIT>') or upload_name.endswith('<STR_LIT>'):<EOL><INDENT>try:<EOL><INDENT>upload = Image(<EOL>event=event,<EOL>image=upload_file,<EOL>caption=caption,<EOL>)<EOL>upload.save()<EOL>instance.photos.add(upload)<EOL><DEDENT>except Exception as error:<EOL><INDENT>messages.error(request, '<STR_LIT>'.format(error))<EOL><DEDENT><DEDENT>
Helper function that actually processes and saves the upload(s).
Segregated out for readability.