Commit 0f021177 authored by Samuel GAIST's avatar Samuel GAIST Committed by Flavio TARSETTI
Browse files

[experiment][views] Remove all edition related views

parent b7709974
......@@ -26,104 +26,15 @@
###############################################################################
from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from django.db.models.functions import Coalesce
from django.http import Http404
from django.shortcuts import get_object_or_404
from django.shortcuts import redirect
from django.shortcuts import render
from ..team.models import Team
from ..toolchains.models import Toolchain
from .models import Experiment
# ----------------------------------------------------------
@login_required
def new_from_toolchain(
request, toolchain_author_name, toolchain_name, toolchain_version
):
"""Sets up a new experiment from a toolchain name"""
# Retrieve the toolchain
toolchain = get_object_or_404(
Toolchain,
author__username=toolchain_author_name,
name=toolchain_name,
version=toolchain_version,
)
# Check that the user can access it
has_access = toolchain.accessibility_for(request.user)[0]
if not (has_access):
raise Http404()
return render(
request, "experiments/setup.html", {"toolchain": toolchain, "action": "new"}
)
# ----------------------------------------------------------
@login_required
def fork(
request, author_name, toolchain_author_name, toolchain_name, toolchain_version, name
):
"""Sets up a new experiment from an experiment fork"""
# Retrieve the experiment
experiment = get_object_or_404(
Experiment,
author__username=author_name,
toolchain__author__username=toolchain_author_name,
toolchain__name=toolchain_name,
toolchain__version=toolchain_version,
name=name,
)
# Check that the user can access it
(has_access, accessibility) = experiment.accessibility_for(request.user)
if not (has_access):
raise Http404()
return render(
request,
"experiments/setup.html",
{
"toolchain": experiment.toolchain,
"experiment": experiment,
"action": "fork",
},
)
# ----------------------------------------------------------
@login_required
def reset(request, toolchain_author_name, toolchain_name, toolchain_version, name):
"""Resets the current experiment so it can run again"""
# Retrieve the experiment
experiment = get_object_or_404(
Experiment,
author=request.user,
toolchain__author__username=toolchain_author_name,
toolchain__name=toolchain_name,
toolchain__version=toolchain_version,
name=name,
)
if not experiment.deletable():
raise Http404()
experiment.reset()
return redirect(experiment)
def view(
request, author_name, toolchain_author_name, toolchain_name, toolchain_version, name
......@@ -145,19 +56,6 @@ def view(
if not (has_access):
raise Http404()
if experiment.status == Experiment.PENDING:
if request.user.is_anonymous:
raise Http404()
return render(
request,
"experiments/setup.html",
{
"toolchain": experiment.toolchain,
"experiment": experiment,
"action": "pending",
},
)
# Users the object can be shared with
users = User.objects.exclude(
username__in=settings.ACCOUNTS_TO_EXCLUDE_FROM_TEAMS
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment