How to use the ramp-frontend.ramp_frontend.forms.ImportForm function in ramp-frontend

To help you get started, we’ve selected a few ramp-frontend examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github paris-saclay-cds / ramp-board / ramp-frontend / ramp_frontend / views / ramp.py View on Github external
interaction='download',
                user=flask_login.current_user,
                event=event,
                submission=submission,
                submission_file=submission_file
            )

        return send_from_directory(
            submission_abspath, f_name, as_attachment=True,
            attachment_filename='{}_{}'.format(submission.hash_[:6], f_name),
            mimetype='application/octet-stream'
        )

    # Importing selected files into sandbox
    choices = [(f, f) for f in submission.f_names]
    import_form = ImportForm()
    import_form.selected_f_names.choices = choices
    if import_form.validate_on_submit():
        sandbox_submission = get_submission_by_name(
            db.session, event.name, flask_login.current_user.name,
            event.ramp_sandbox_name
        )
        for filename in import_form.selected_f_names.data:
            logger.info(
                '{} is importing {}/{}/{}/{}'
                .format(flask_login.current_user.name, event, team,
                        submission, filename)
            )

            # TODO: deal with different extensions of the same file
            src = os.path.join(submission.path, filename)
            dst = os.path.join(sandbox_submission.path, filename)