Commit b267f967 authored by Flavio TARSETTI's avatar Flavio TARSETTI

Merge branch '576_remove_experiment_editor' into 'remove_asset_edition'

Remove experiment editor

See merge request !403
parents fae79a27 a8cb592b
Pipeline #43877 passed with stage
in 16 minutes and 24 seconds
......@@ -38,32 +38,11 @@
{% endif %}
{% endifnotequal %}
<!-- delete, needs to be the owner -->
{% if status == 'Running' or status == 'Scheduled' %}
<a class="btn btn-default btn-cancel" onclick="beat.experiments.utils.modal_cancel('{{ object.name }}', '{% url 'api_experiments:cancel' object.author.username object.toolchain.author.username object.toolchain.name object.toolchain.version object.name %}', '{{ object.get_absolute_url }}');" data-toggle="tooltip" data-placement="bottom" title="stop"><i class="fa fa-power-off fa-lg"></i></a>
{% endif %}
{% if status in 'Pending Failed Done' and object.deletable %}
<a class="btn btn-default btn-delete" onclick="modal_delete('experiment', '{{ object.fullname }}', '{% url 'api_experiments:all' %}', '{% url 'experiments:list' request.user.username %}');" data-toggle="tooltip" data-placement="bottom" title="Delete"><i class="fa fa-times fa-lg"></i></a>
{% endif %}
<!-- rename, needs to be pending -->
{% if status in 'Done Pending Failed' %}
<a class="btn btn-default btn-rename" onclick="beat.experiments.utils.modal_rename({{ request.user.id }}, '{{ object.name }}', '{% url "api_experiments:list_create" request.user.username %}', '{{ object.get_api_update_url }}');" data-toggle="tooltip" data-placement="bottom" title="Rename"><i class="fa fa-tag fa-lg"></i></a>
{% endif %}
{% if not object.attestation and status == 'Done' %}
{# a small form with confirmation to attest the current experiment #}
<a class="btn btn-default btn-attest" onclick="beat.experiments.utils.modal_attest('{{ object.fullname }}', '{% url "api_attestations:create" %}', '{{ object.get_absolute_url }}');" data-toggle="tooltip" data-placement="bottom" title="Attest"><i class="fa fa-certificate fa-lg"></i></a>
{% endif %}
<!-- edit, needs to be modifiable -->
{% if object.modifiable %}
{% if status == 'Failed' or status == 'Done' %}
<a class="btn btn-default btn-edit" href="{% url 'experiments:reset' object.toolchain.author.username object.toolchain.name object.toolchain.version object.name %}" data-toggle="tooltip" data-placement="bottom" title="Reset"><i class="fa fa-undo fa-lg"></i></a>
{% endif %}
{% endif %}
{% endifequal %}
<!-- Edit, needs to be modifiable -->
......@@ -73,9 +52,6 @@
{% if not request.user.is_anonymous %}
<!-- fork button, needs to be logged in -->
<a class="btn btn-default btn-fork" href="{% url 'experiments:fork' object.author.username object.toolchain.author.username object.toolchain.name object.toolchain.version object.name %}" data-toggle="tooltip" data-placement="bottom" title="Fork"><i class="fa fa-code-fork fa-lg"></i></a>
<!-- add to report button, needs to be logged in -->
{% if status == 'Done' %}
<a class="btn btn-default btn-report" onclick="beat.experiments.utils.modal_add_to_report(['{{ object.fullname }}'], '{% url "api_reports:list_create" request.user.username %}');" data-toggle="tooltip" data-placement="bottom" title="Add to report"><i class="fa fa-file-text-o fa-lg"></i></a>
......
......@@ -68,12 +68,6 @@
</div>
<!-- Notice there can be no div space if vertical-center is used -->
</div><div class="col-sm-2 vertical-center">
{% if owner %}
<a class="btn btn-success btn-sm pull-right" onclick="beat.experiments.utils.modal_new_experiment('{% url "api_toolchains:all" %}');"><i class="fa fa-plus fa-lg"></i> New</a>
{% endif %}
</div><!-- col -->
</div><!-- row -->
......
This diff is collapsed.
......@@ -33,21 +33,6 @@ from . import views
app_name = "experiments"
urlpatterns = [
re_path(
r"^setup/(?P<toolchain_author_name>[-\w]+)/(?P<toolchain_name>[-\w]+)/(?P<toolchain_version>\d+)/$",
views.new_from_toolchain,
name="new-from-toolchain",
),
re_path(
r"^reset/(?P<toolchain_author_name>[-\w]+)/(?P<toolchain_name>[-\w]+)/(?P<toolchain_version>\d+)/(?P<name>[-\w]+)/$",
views.reset,
name="reset",
),
re_path(
r"^fork/(?P<author_name>\w+)/(?P<toolchain_author_name>[-\w]+)/(?P<toolchain_name>[-\w]+)/(?P<toolchain_version>\d+)/(?P<name>[-\w]+)/$",
views.fork,
name="fork",
),
re_path(
r"^(?P<author_name>\w+)/(?P<toolchain_author_name>[-\w]+)/(?P<toolchain_name>[-\w]+)/(?P<toolchain_version>\d+)/(?P<name>[-\w]+)/$",
views.view,
......
......@@ -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