From 96c19101163f6547693c200927475a76068e9ae3 Mon Sep 17 00:00:00 2001 From: Adam Samalik Date: May 30 2014 13:26:03 +0000 Subject: [frontend] running build can not be deleted --- diff --git a/frontend/coprs_frontend/coprs/logic/builds_logic.py b/frontend/coprs_frontend/coprs/logic/builds_logic.py index 4792bdb..d4961fc 100644 --- a/frontend/coprs_frontend/coprs/logic/builds_logic.py +++ b/frontend/coprs_frontend/coprs/logic/builds_logic.py @@ -159,6 +159,10 @@ class BuildsLogic(object): raise exceptions.InsufficientRightsException( "You are not allowed to delete this build.") + if build.state == "running": + raise exceptions.ActionInProgressException( + "You can not delete build which is running.", "Running build") + action = models.Action(action_type=helpers.ActionTypeEnum("delete"), object_type="build", object_id=build.id, diff --git a/frontend/coprs_frontend/coprs/templates/coprs/detail/_builds_forms.html b/frontend/coprs_frontend/coprs/templates/coprs/detail/_builds_forms.html index 4023881..edf0eb5 100644 --- a/frontend/coprs_frontend/coprs/templates/coprs/detail/_builds_forms.html +++ b/frontend/coprs_frontend/coprs/templates/coprs/detail/_builds_forms.html @@ -65,7 +65,7 @@ {% endmacro %} {% macro copr_build_delete_form(build, page) %} - {% if build.ended_on %} + {% if build.ended_on and build.state != "running" %}
diff --git a/frontend/coprs_frontend/coprs/views/coprs_ns/coprs_builds.py b/frontend/coprs_frontend/coprs/views/coprs_ns/coprs_builds.py index 22f5c6b..a39f291 100644 --- a/frontend/coprs_frontend/coprs/views/coprs_ns/coprs_builds.py +++ b/frontend/coprs_frontend/coprs/views/coprs_ns/coprs_builds.py @@ -226,7 +226,7 @@ def copr_delete_build(username, coprname, build_id, page=1): "Build with id {0} does not exist.".format(build_id)) try: builds_logic.BuildsLogic.delete_build(flask.g.user, build) - except InsufficientRightsException as e: + except (InsufficientRightsException, ActionInProgressException) as e: flask.flash(str(e)) else: db.session.commit()