diff --git a/tcms/static/js/testcase_actions.js b/tcms/static/js/testcase_actions.js index 6085b4ed59..7d422ca59c 100644 --- a/tcms/static/js/testcase_actions.js +++ b/tcms/static/js/testcase_actions.js @@ -25,46 +25,6 @@ Nitrate.TestCases.Clone = {}; Nitrate.TestCases.Clone.on_load = function() { - $('#id_product').change(update_version_select_from_product); - if (!$('#id_version').val().length) { - update_version_select_from_product(); - } - - jQ('#id_form_search_plan').bind('submit', function(e) { - e.stopPropagation(); - e.preventDefault(); - - var url = '/plans/'; - var container = jQ('#id_plan_container'); - container.show(); - - jQ.ajax({ - 'url': url, - 'type': 'GET', - 'data': jQ(this).serialize(), - 'success': function (data, textStatus, jqXHR) { - container.html(data); - } - }); - }); - - jQ('#id_use_filterplan').bind('click', function(e) { - jQ('#id_form_search_plan :input').attr('disabled', false); - jQ('#id_plan_id').val(''); - jQ('#id_plan_id').attr('name', ''); - jQ('#id_copy_case').attr('checked', true); - }); - - jQ('#id_use_sameplan').bind('click', function(e) { - jQ('#id_form_search_plan :input').attr('disabled', true); - jQ('#id_plan_id').val(jQ('#value_plan_id').val()); - jQ('#id_plan_id').attr('name', 'plan'); - jQ('#id_plan_container').html('
').hide(); - jQ('#id_copy_case').attr('checked', false); - }); - - $('#id_use_sameplan').click(); - jQ('.js-cancel-button').bind('click', function() { window.history.go('-1'); }); diff --git a/tcms/templates/case/clone.html b/tcms/templates/case/clone.html index 7486ad9b8b..43f45fb89a 100644 --- a/tcms/templates/case/clone.html +++ b/tcms/templates/case/clone.html @@ -17,77 +17,14 @@ {% endblock %} {% block contents %}
-
- -
- -

{% trans "Clone TestCase(s)" %}

+

{% trans "Clone TestCase(s) into" %} TP-{{ test_plan.pk }}: {{ test_plan.name }}

-
- - {% if test_plan %} -
- - -
- {% endif %} -
- - -
-
- -
- - {{ search_form.pk__in }} -
-
- - {{ search_form.product }} -
-
- - {{ search_form.version }} -
-
- - {{ search_form.type }} -
-
- - {{ search_form.author__email__startswith }} -
-
- - {{ search_form.tag__name__in }} -
-
- - {{ search_form.name__icontains }} -
-
- - {{ search_form.is_active }} -
-
- -
-
-
- {% if submit_action %} - {{ clone_form.plan.errors }} - {% endif %} -
-
{{ form.case_id }}
- - +
diff --git a/tcms/templates/case/clone_select_plan.html b/tcms/templates/case/clone_select_plan.html deleted file mode 100644 index 244892ead9..0000000000 --- a/tcms/templates/case/clone_select_plan.html +++ /dev/null @@ -1,25 +0,0 @@ -{% load i18n %} - - -{{ testplan.name }} - - - - - - - - -{% for test_plan in test_plans %} - - - - - - - -{% empty %} - -{% endfor %} - -
 {% trans "Plan Summary" %}{% trans "Plan Type" %}{% trans "Author" %}{% trans "Is Active" %}
TP-{{ test_plan.pk }} - {{ test_plan }}{{ test_plan.type }}{{ test_plan.author }}{% if test_plan.is_active %} {% trans "Yes" %} {% else %} {% trans "No" %} {% endif %}
 {% trans "There are no plans" %}
diff --git a/tcms/testcases/tests/test_views.py b/tcms/testcases/tests/test_views.py index d6572714b3..fd7079334b 100644 --- a/tcms/testcases/tests/test_views.py +++ b/tcms/testcases/tests/test_views.py @@ -338,13 +338,7 @@ def test_show_clone_page_with_from_plan(self): {'from_plan': self.plan.pk, 'case': [self.case_1.pk, self.case_2.pk]}) - self.assertContains( - response, - """
- - -
""" % (self.plan.pk, _('Use the same Plan'), self.plan.pk, self.plan.name), - html=True) + self.assertContains(response, "TP-%s: %s" % (self.plan.pk, self.plan.name)) for loop_counter, case in enumerate([self.case_1, self.case_2]): self.assertContains( @@ -357,20 +351,7 @@ def test_show_clone_page_with_from_plan(self): def test_show_clone_page_without_from_plan(self): response = self.client.get(self.clone_url, {'case': self.case_1.pk}) - - self.assertNotContains( - response, - 'Use the same Plan -- {0} : {1}'.format(self.plan.pk, - self.plan.name), - ) - - self.assertContains( - response, - ''.format( - self.case_1.pk, self.case_1.summary), - html=True) + self.assertRedirects(response, '/') class TestSearchCases(BasePlanCase): diff --git a/tcms/testcases/views.py b/tcms/testcases/views.py index 88ce56fef1..a942814901 100644 --- a/tcms/testcases/views.py +++ b/tcms/testcases/views.py @@ -27,7 +27,6 @@ from tcms.testruns.models import TestExecutionStatus from tcms.testcases.forms import NewCaseForm, \ SearchCaseForm, CaseNotifyForm, CloneCaseForm -from tcms.testplans.forms import SearchPlanForm from tcms.testcases.fields import MultipleEmailField @@ -763,8 +762,12 @@ def clone(request, template_name='case/clone.html'): return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/')) test_plan_src = plan_from_request_or_none(request) - test_plan = None - search_plan_form = SearchPlanForm() + if not test_plan_src: + messages.add_message(request, + messages.ERROR, + _('TestPlan is required')) + # redirect back where we came from + return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/')) # Do the clone action if request.method == 'POST': @@ -909,18 +912,8 @@ def clone(request, template_name='case/clone.html'): }) clone_form.populate(case_ids=selected_cases) - # Generate search plan form - if request_data.get('from_plan'): - test_plan = TestPlan.objects.get(plan_id=request_data['from_plan']) - search_plan_form = SearchPlanForm( - initial={'product': test_plan.product_id, 'is_active': True}) - search_plan_form.populate(product_id=test_plan.product_id) - - submit_action = request_data.get('submit', None) context = { - 'test_plan': test_plan, - 'search_form': search_plan_form, + 'test_plan': test_plan_src, 'clone_form': clone_form, - 'submit_action': submit_action, } return render(request, template_name, context) diff --git a/tcms/testplans/views.py b/tcms/testplans/views.py index 488818bab5..9ae87fc64f 100644 --- a/tcms/testplans/views.py +++ b/tcms/testplans/views.py @@ -118,15 +118,9 @@ def get_all(request): # pylint: disable=missing-permission-required # Set search active plans only by default search_form = SearchPlanForm(initial={'is_active': True}) - # fixme: this view is scheduled for deletion - # TestCase clone workflow must be redesigned so it uses - # the TestPlan search page - template_name = '' - if request.GET.get('action') == 'clone_case': - template_name = 'case/clone_select_plan.html' - tps = tps.order_by('name') - - # used in tree preview & TestCase add plan + template_name = 'non-existing.html' + + # used in tree preview only # fixme: must be replaced by JSON RPC and the # JavaScript dialog that displays the preview # should be converted to Patternfly