Exemple #1
0
def home():
    user_details = get_user_details()

    if not is_user_registered(user_details[0]):
        return redirect(url_for('userManagement.sign_up'))

    form = Computation()
    user_id = get_user_id(user_details[0])
    if form.validate_on_submit():  # this block of code is executed when browser sent POST request(user submitted form)
        try:
            DirectoryAndFileWriter.create_experiment(form, str(user_id))
            flash(current_app.config['EXPERIMENT_SUBMITTED'], "info")
            return redirect('/home')
        except NewComputationRequestSubmitError:
            flash(current_app.config['EXPERIMENT_SUBMISSION_FAILED'], "error")
            return redirect('/home')

    try:
        help_cookie = request.cookies["help"]
    except KeyError:
        help_cookie = "enabled"

    if is_user_registered(user_details[0]) and is_user_confirmed(user_details[0]):
        return render_template('home.html', form=form, username=get_user_username(user_details[0]), help=help_cookie, is_admin=is_user_admin(user_details[0]),
                               pages=DirectoryAndFileReader.get_pagination_controls_count(user_id),
                               comps=DirectoryAndFileReader.get_subset_of_computations_for_one_page(
                                   get_user_id(user_details[0]), 0, 'date', -1, {}))
    elif is_user_registered(user_details[0]) and not is_user_confirmed(user_details[0]):
        return redirect(url_for('userManagement.unconfirmed'))
Exemple #2
0
def get_experiments(page, sort_option, sort_order):
    user_details = get_user_details()
    user_id = get_user_id(user_details[0])

    if not is_user_registered(user_details[0]):
        return redirect(url_for('userManagement.sign_up'))

    elif is_user_registered(user_details[0]) and not is_user_confirmed(user_details[0]):
        return redirect(url_for('userManagement.unconfirmed'))

    return jsonify(comps=DirectoryAndFileReader.get_subset_of_computations_for_one_page(user_id, int(page), sort_option, int(sort_order), request.json),
                   pages=len(DirectoryAndFileReader.get_pagination_controls_count(computations=DirectoryAndFileReader.get_computations(user_id, sort_option, int(sort_order), request.json))))
Exemple #3
0
def get_experiments(page, sort_option, sort_order):
    user_details = get_user_details()
    user_id = get_user_id(user_details[0])

    if not is_user_registered(user_details[0]):
        return redirect(url_for('userManagement.sign_up'))

    elif is_user_registered(
            user_details[0]) and not is_user_confirmed(user_details[0]):
        return redirect(url_for('userManagement.unconfirmed'))

    return jsonify(
        comps=DirectoryAndFileReader.get_subset_of_computations_for_one_page(
            user_id, int(page), sort_option, int(sort_order), request.json),
        pages=len(
            DirectoryAndFileReader.get_pagination_controls_count(
                computations=DirectoryAndFileReader.get_computations(
                    user_id, sort_option, int(sort_order), request.json))))
Exemple #4
0
def home():
    user_details = get_user_details()

    if not is_user_registered(user_details[0]):
        return redirect(url_for('userManagement.sign_up'))

    form = Computation()
    user_id = get_user_id(user_details[0])
    if form.validate_on_submit(
    ):  # this block of code is executed when browser sent POST request(user submitted form)
        try:
            DirectoryAndFileWriter.create_experiment(form, str(user_id))
            flash(current_app.config['EXPERIMENT_SUBMITTED'], "info")
            return redirect('/home')
        except NewComputationRequestSubmitError:
            flash(current_app.config['EXPERIMENT_SUBMISSION_FAILED'], "error")
            return redirect('/home')

    try:
        help_cookie = request.cookies["help"]
    except KeyError:
        help_cookie = "enabled"

    if is_user_registered(user_details[0]) and is_user_confirmed(
            user_details[0]):
        return render_template(
            'home.html',
            form=form,
            username=get_user_username(user_details[0]),
            help=help_cookie,
            is_admin=is_user_admin(user_details[0]),
            pages=DirectoryAndFileReader.get_pagination_controls_count(
                user_id),
            comps=DirectoryAndFileReader.
            get_subset_of_computations_for_one_page(
                get_user_id(user_details[0]), 0, 'date', -1, {}))
    elif is_user_registered(
            user_details[0]) and not is_user_confirmed(user_details[0]):
        return redirect(url_for('userManagement.unconfirmed'))