Beispiel #1
0
def update_experiment_template(request,eid):
    '''This will update static files, along with the config.json parameters'''
    context = {"experients": ExperimentTemplate.objects.all()}
    if request.user.is_superuser:
        experiment = get_experiment_template(eid=eid,request=request)
        errored_experiments = install_experiments(experiment_tags=[experiment.exp_id])
        if len(errored_experiments) > 0:
            message = "The experiments %s did not update successfully." %(",".join(errored_experiments))
        else:
            message = "Experiments updated successfully."
            experiments = ExperimentTemplate.objects.all()
            context = {"experiments":experiments,
                       "message":message}
    return render(request, "all_experiments.html", context)
Beispiel #2
0
def save_new_template(request,template_type):
    '''save_new_template
    view for actually adding new surveys, experiments, or games (files, etc) to application and database
    '''
    newtemplates = request.POST.keys()
    new_selection = get_experiment_selection(template_type)
    selected_experiments = [e["exp_id"] for e in new_selection if e["exp_id"] in newtemplates]
    errored = install_experiments(experiment_tags=selected_experiments,repo_type=template_type)
    if len(errored) > 0:
        message = "The %s %s did not install successfully." %(template_type,",".join(errored))
    else:
        message = "%s installed successfully." %(template_type)
    experiments = ExperimentTemplate.objects.all()
    context = {"experiments":experiments,
               "message":message}
    return render(request, "experiments/all_experiments.html", context)
Beispiel #3
0
def save_experiment_template(request):
    '''save_experiments template
    view for actually adding new experiments (files, etc) to application and database
    '''
    newexperiments = request.POST.keys()
    experiment_selection = get_experiment_selection()
    selected_experiments = [e["exp_id"] for e in experiment_selection if e["exp_id"] in newexperiments]
    errored_experiments = install_experiments(experiment_tags=selected_experiments)
    if len(errored_experiments) > 0:
        message = "The experiments %s did not install successfully." %(",".join(errored_experiments))
    else:
        message = "Experiments installed successfully."
    experiments = ExperimentTemplate.objects.all()
    context = {"experiments":experiments,
               "message":message}
    return render(request, "all_experiments.html", context)
Beispiel #4
0
def update_experiment_template(request, eid):
    '''This will update static files, along with the config.json parameters'''
    context = {"experiments": ExperimentTemplate.objects.all()}
    if request.user.is_superuser:
        experiment = get_experiment_template(eid=eid, request=request)
        experiment_type = get_experiment_type(experiment)
        errored_experiments = install_experiments(
            experiment_tags=[experiment.exp_id], repo_type=experiment_type)
        if len(errored_experiments) > 0:
            message = "The experiments %s did not update successfully." % (
                ",".join(errored_experiments))
        else:
            message = "Experiments updated successfully."
            experiments = ExperimentTemplate.objects.all()
            context = {"experiments": experiments, "message": message}
    return render(request, "experiments/all_experiments.html", context)
Beispiel #5
0
def save_new_template(request, template_type):
    '''save_new_template
    view for actually adding new surveys, experiments, or games (files, etc) to application and database
    '''
    newtemplates = request.POST.keys()
    new_selection = get_experiment_selection(template_type)
    selected_experiments = [
        e["exp_id"] for e in new_selection if e["exp_id"] in newtemplates
    ]
    errored = install_experiments(experiment_tags=selected_experiments,
                                  repo_type=template_type)
    if len(errored) > 0:
        message = "The %s %s did not install successfully." % (
            template_type, ",".join(errored))
    else:
        message = "%s installed successfully." % (template_type)
    experiments = ExperimentTemplate.objects.all()
    context = {"experiments": experiments, "message": message}
    return render(request, "experiments/all_experiments.html", context)
Beispiel #6
0
def save_experiment(request, bid):
    '''save_experiment
    save experiment and custom details for battery. This is linked to the upload experiment view,
    as experiments come by way of upload (from Github url)
    '''
    battery = get_battery(bid, request)

    if request.method == "POST":
        contenders = request.POST.keys()

        # Get the repo_url and requests experiments
        repo_url = request.POST.get("repo_url", None)
        expression = re.compile("^EXPERIMENT_")
        experiment_ids = [
            x.replace("EXPERIMENT_", "") for x in contenders
            if expression.search(x)
        ]

        if repo_url != None and len(experiment_ids) > 0:
            message = install_experiments(battery, repo_url, experiment_ids)
        return view_battery(request, bid, message=message)

    return HttpResponseRedirect(battery.get_absolute_url())