Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
db.session, event_name, flask_login.current_user.name,
event.ramp_sandbox_name
)
event_team = get_event_team_by_name(
db.session, event_name, flask_login.current_user.name
)
# initialize the form for the code
# The amount of python magic we have to do for rendering a variable
# number of textareas, named and populated at run time, is mind
# boggling.
# First we need to make sure CodeForm is empty
# for name_code in CodeForm.names_codes:
# name, _ = name_code
# delattr(CodeForm, name)
CodeForm.names_codes = []
# Then we create named fields in the CodeForm class for each editable
# submission file. They have to be populated when the code_form object
# is created, so we also create a code_form_kwargs dictionary and
# populate it with the codes.
code_form_kwargs = {}
for submission_file in sandbox_submission.files:
if submission_file.is_editable:
f_field = submission_file.name
setattr(CodeForm,
f_field, StringField('Text', widget=TextArea()))
code_form_kwargs[f_field] = submission_file.get_code()
code_form_kwargs['prefix'] = 'code'
code_form = CodeForm(**code_form_kwargs)
# Then, to be able to iterate over the files in the sandbox.html
# template, we also fill a separate table of pairs (file name, code).