From eda96d1d4c8512759aef328aacd413653ae243c1 Mon Sep 17 00:00:00 2001 From: "Mr. Senko" Date: Fri, 17 Aug 2018 11:53:01 +0300 Subject: [PATCH] Don't use get_full_url where not needed. Closes #380 --- tcms/static/js/testcase_actions.js | 2 +- tcms/static/js/testplan_actions.js | 12 ++++++------ tcms/templates/case/clone_select_plan.html | 10 ++++------ tcms/templates/case/get.html | 2 +- tcms/templates/case/get_case_run.html | 2 +- tcms/templates/case/get_plan.html | 8 +++----- tcms/templates/case/new.html | 2 +- tcms/templates/dashboard.html | 2 +- tcms/templates/plan/choose_testrun.html | 4 ++-- tcms/templates/plan/common/json_plans.txt | 8 ++++---- .../plan/common/plans_advance_filtered.html | 8 ++++---- tcms/templates/plan/get.html | 2 +- .../report/custom_details_case_runs.html | 2 +- .../report/custom_details_status_matrix.html | 4 ++-- .../by_plan_build_with_rates.html | 2 +- .../report/testing-report/per_plan_build.html | 4 ++-- .../report/testing-report/per_plan_tag.html | 4 ++-- tcms/templates/run/assign_case.html | 2 +- .../run/common/run_advance_filtered.html | 2 +- tcms/templates/run/edit.html | 2 +- tcms/templates/run/get.html | 2 +- tcms/templates/run/new.html | 3 ++- tcms/testcases/tests/test_views.py | 11 +++++------ tcms/testplans/tests/tests.py | 19 ++++++++++++++----- tcms/testplans/views.py | 8 ++++---- 25 files changed, 66 insertions(+), 61 deletions(-) diff --git a/tcms/static/js/testcase_actions.js b/tcms/static/js/testcase_actions.js index 2450161f56..4c23e753db 100644 --- a/tcms/static/js/testcase_actions.js +++ b/tcms/static/js/testcase_actions.js @@ -156,6 +156,7 @@ Nitrate.TestCases.List.on_load = function() { {"sClass": "expandable"} ] }); + jQ("#testcases_table tbody tr td.expandable").live("click", function() { var tr = jQ(this).parent(); var caseRowContainer = tr; @@ -773,7 +774,6 @@ function constructPlanCaseZone(container, case_id, parameters) { "bAutoWidth": false, "aaSorting": [[ 0, "desc" ]], "aoColumns": [ - {"sType": "num-html"}, null, {"sType": "html"}, {"sType": "html"}, diff --git a/tcms/static/js/testplan_actions.js b/tcms/static/js/testplan_actions.js index 4e177c64e9..8942dd3a57 100644 --- a/tcms/static/js/testplan_actions.js +++ b/tcms/static/js/testplan_actions.js @@ -212,7 +212,7 @@ Nitrate.TestPlans.TreeView = { } var li = jQ('
  • '); - var title = '[' + data[i].pk + '] '; + var title = '[' + data[i].pk + '] '; if (data[i].num_children && data[i].children) { title = icon_expand + title; @@ -235,12 +235,12 @@ Nitrate.TestPlans.TreeView = { } // Construct the items - title += '' + data[i].name + ''; + title += '' + data[i].name + ''; title += ' ('; if (data[i].num_cases && data[i].is_current) { title += '' + data[i].num_cases + ' cases, '; } else if (data[i].num_cases && !(data[i].is_current)) { - title += '' + data[i].num_cases + ' cases, '; + title += '' + data[i].num_cases + ' cases, '; } else { title += '0 case, '; } @@ -248,7 +248,7 @@ Nitrate.TestPlans.TreeView = { if (data[i].num_runs && data[i].is_current) { title += '' + data[i].num_runs + ' runs, '; } else if (data[i].num_runs && !data[i].is_current) { - title += '' + data[i].num_runs + ' runs, '; + title += '' + data[i].num_runs + ' runs, '; } else { title += '0 runs, '; } @@ -271,10 +271,10 @@ Nitrate.TestPlans.TreeView = { title += '0 child'; break; case 1: - title += '' + '1 child'; + title += '' + '1 child'; break; default: - title += '' + data[i].num_children + ' children'; + title += '' + data[i].num_children + ' children'; break; } diff --git a/tcms/templates/case/clone_select_plan.html b/tcms/templates/case/clone_select_plan.html index b32c3ebdb4..59af16b916 100644 --- a/tcms/templates/case/clone_select_plan.html +++ b/tcms/templates/case/clone_select_plan.html @@ -3,21 +3,19 @@ {{ testplan.name }} - - + + - {% for test_plan in test_plans %} - - + + - {% empty %} diff --git a/tcms/templates/case/get.html b/tcms/templates/case/get.html index 98cf400a6b..8256760ba5 100644 --- a/tcms/templates/case/get.html +++ b/tcms/templates/case/get.html @@ -60,7 +60,7 @@ {% endif %} {% if test_plan %} - Back to Test Plan + Back to Test Plan {% endif %} diff --git a/tcms/templates/case/get_case_run.html b/tcms/templates/case/get_case_run.html index 6450ecb621..674df257c3 100644 --- a/tcms/templates/case/get_case_run.html +++ b/tcms/templates/case/get_case_run.html @@ -7,7 +7,7 @@ diff --git a/tcms/templates/case/get_plan.html b/tcms/templates/case/get_plan.html index 06d7d45c64..7840f0b793 100644 --- a/tcms/templates/case/get_plan.html +++ b/tcms/templates/case/get_plan.html @@ -1,8 +1,7 @@
     ID Plan Summary Plan Type Author Is ActivePlan Summary
    {{ test_plan.plan_id }}TP-{{ test_plan.pk }} - {{ test_plan }} {{ test_plan.type }} {{ test_plan.author }} {% if test_plan.is_active %} Yes {% else %} No {% endif %}{{ test_plan }}
     There are no plans
    - Plan:[{{ plan.pk }}] {{ plan.name }} + Plan:TP-{{ plan.pk }}: {{ plan.name }}
    - - + @@ -13,8 +12,7 @@ {% for test_plan in test_plans %} - - + @@ -36,7 +34,7 @@ {% if perms.testcases.add_testcaseplan %} - - + diff --git a/tcms/templates/plan/choose_testrun.html b/tcms/templates/plan/choose_testrun.html index 71ae23c77f..63ba3d445b 100644 --- a/tcms/templates/plan/choose_testrun.html +++ b/tcms/templates/plan/choose_testrun.html @@ -1,7 +1,7 @@ {% extends "tcms_base.html" %} {% load static %} -{% block subtitle %}Choose test run to assign case{% endblock %} +{% block subtitle %}Add TestCase(s) to TestRun(s){% endblock %} {% block custom_stylesheet %} {% endblock %} @@ -17,7 +17,7 @@ {% block contents %}
    -

    Plan:{{ plan.name }}

    +

    TestPlan: {{ plan.name }}

    IDNameName Author Type Product
    {{ test_plan.plan_id }}{{ test_plan.name }}TP-{{ test_plan.pk }}: {{ test_plan.name }} {{ test_plan.author.username }} {{ test_plan.type }} {{ test_plan.product }}
    +
    Add into another Plan diff --git a/tcms/templates/case/new.html b/tcms/templates/case/new.html index a020c7485b..ff92a2391f 100644 --- a/tcms/templates/case/new.html +++ b/tcms/templates/case/new.html @@ -154,7 +154,7 @@

    Expected Results

    {% if test_plan %} - + {% else %} {% endif %} diff --git a/tcms/templates/dashboard.html b/tcms/templates/dashboard.html index dcfd685336..3140df1667 100644 --- a/tcms/templates/dashboard.html +++ b/tcms/templates/dashboard.html @@ -62,7 +62,7 @@ {% for test_plan in last_15_test_plans %} {% if test_plan.is_active %}
    {{ test_plan.name }}{{ test_plan.name }} {{ test_plan.product }} {{ test_plan.type }} {{ test_plan.num_runs }}
    diff --git a/tcms/templates/plan/common/json_plans.txt b/tcms/templates/plan/common/json_plans.txt index aac86029cb..73e7769d1e 100644 --- a/tcms/templates/plan/common/json_plans.txt +++ b/tcms/templates/plan/common/json_plans.txt @@ -7,8 +7,8 @@ { "DT_RowId": "plan_{{test_plan.pk}}", "DT_RowClass": {% if not test_plan.is_active %}"line-through inactive"{%else%}""{% endif %}, - "0":"{{ test_plan.plan_id }}", - "1":"{{ test_plan|escapejs|escape }} ", + "0":"{{ test_plan.plan_id }}", + "1":"{{ test_plan|escapejs|escape }} ", "2":"{{ test_plan.author }}", {% if test_plan.owner %} "3":"{{ test_plan.owner }}" @@ -18,8 +18,8 @@ "4":"{{ test_plan.product }}", "5":"{{ test_plan.product_version }}", "6":"{{ test_plan.type }}", - "7":"{{ test_plan.cal_cases_count }}", - "8":"{{ test_plan.cal_runs_count }}", + "7":"{{ test_plan.cal_cases_count }}", + "8":"{{ test_plan.cal_runs_count }}", {% if perms.testplans.change_testplan %} "9":"Edit" {% else %} diff --git a/tcms/templates/plan/common/plans_advance_filtered.html b/tcms/templates/plan/common/plans_advance_filtered.html index e40b76425d..fa431708b7 100644 --- a/tcms/templates/plan/common/plans_advance_filtered.html +++ b/tcms/templates/plan/common/plans_advance_filtered.html @@ -17,8 +17,8 @@ {% for test_plan in test_plans %} - - + + - - + + {% for test_case_run, bugs, comments in case_runs %} - + diff --git a/tcms/templates/report/custom_details_status_matrix.html b/tcms/templates/report/custom_details_status_matrix.html index 60348513de..fe416208de 100644 --- a/tcms/templates/report/custom_details_status_matrix.html +++ b/tcms/templates/report/custom_details_status_matrix.html @@ -20,10 +20,10 @@ {% ifnotequal plan None %} {% endifnotequal %} - + diff --git a/tcms/templates/report/testing-report/by_plan_build_with_rates.html b/tcms/templates/report/testing-report/by_plan_build_with_rates.html index b857f333e4..65abbed5d0 100644 --- a/tcms/templates/report/testing-report/by_plan_build_with_rates.html +++ b/tcms/templates/report/testing-report/by_plan_build_with_rates.html @@ -38,7 +38,7 @@ {% for plan, builds_count, runs_count, status_subtotal in report_data.reports %} - + diff --git a/tcms/templates/report/testing-report/per_plan_build.html b/tcms/templates/report/testing-report/per_plan_build.html index 7f51289cde..d1d36ce0d3 100644 --- a/tcms/templates/report/testing-report/per_plan_build.html +++ b/tcms/templates/report/testing-report/per_plan_build.html @@ -25,7 +25,7 @@ {% for plan, builds_count, runs_count, caseruns_count, status_matrix in report_data.reports %}
    - +
    • Builds:{{ builds_count }}
    • Runs:{{ runs_count }}
    • @@ -55,7 +55,7 @@ {% ifnotequal build.1 None %}
    {% endifnotequal %} - + diff --git a/tcms/templates/report/testing-report/per_plan_tag.html b/tcms/templates/report/testing-report/per_plan_tag.html index 90857612ce..08a4a64bd7 100644 --- a/tcms/templates/report/testing-report/per_plan_tag.html +++ b/tcms/templates/report/testing-report/per_plan_tag.html @@ -54,10 +54,10 @@ {% endifnotequal %} {% ifnotequal plan.1 None %} {% endifnotequal %} - + diff --git a/tcms/templates/run/assign_case.html b/tcms/templates/run/assign_case.html index 42e5b64d11..92a881e045 100644 --- a/tcms/templates/run/assign_case.html +++ b/tcms/templates/run/assign_case.html @@ -29,7 +29,7 @@

    Add TestCase(s) to

    - + diff --git a/tcms/templates/run/common/run_advance_filtered.html b/tcms/templates/run/common/run_advance_filtered.html index 64aa20a865..cb5f570fab 100644 --- a/tcms/templates/run/common/run_advance_filtered.html +++ b/tcms/templates/run/common/run_advance_filtered.html @@ -21,7 +21,7 @@ - + diff --git a/tcms/templates/run/edit.html b/tcms/templates/run/edit.html index adf564f98e..aa2f2a525d 100644 --- a/tcms/templates/run/edit.html +++ b/tcms/templates/run/edit.html @@ -113,7 +113,7 @@

    Edit Test Run

    Environment group must be set for this test plan ({{ test_run.plan.product }}: {{ test_run.product_version }}: - {{ test_run.plan }} + {{ test_run.plan }} ) before you will be able to select environments for this test run.If you do not have permission to edit this plan, please contact the author of this plan {{ test_run.plan.author.username }} diff --git a/tcms/templates/run/get.html b/tcms/templates/run/get.html index 2e77ffdd45..db80c9c8b2 100644 --- a/tcms/templates/run/get.html +++ b/tcms/templates/run/get.html @@ -59,7 +59,7 @@

    {{ test_run.summary }}

    diff --git a/tcms/templates/run/new.html b/tcms/templates/run/new.html index 4db34669fe..21d0fadff1 100644 --- a/tcms/templates/run/new.html +++ b/tcms/templates/run/new.html @@ -103,7 +103,8 @@

    Create New Test Run

    {% empty%}

    - Environment group must be set for this test plan ({{ test_plan.product.name }}:{{ test_plan.product_version.value }}:{{ test_plan }}) before you will be able to select environments for this test run.If you do not have permission to edit this plan, please contact the author of this plan + Environment group must be set for this test plan ({{ test_plan.product.name }}:{{ test_plan.product_version.value }}: + {{ test_plan }}) before you will be able to select environments for this test run.If you do not have permission to edit this plan, please contact the author of this plan {{ test_plan.author.username }}

    diff --git a/tcms/testcases/tests/test_views.py b/tcms/testcases/tests/test_views.py index bd1bf1b152..953623980c 100644 --- a/tcms/testcases/tests/test_views.py +++ b/tcms/testcases/tests/test_views.py @@ -3,6 +3,7 @@ import json import unittest +from uuslug import slugify from http import HTTPStatus import xml.etree.ElementTree # nosec:B405:blacklist from datetime import datetime @@ -411,12 +412,10 @@ def assert_list_case_plans(self, response, case): plan = case_plan_rel.plan self.assertContains( response, - '{1}'.format(plan.get_full_url(), plan.pk), - html=True) - - self.assertContains( - response, - '{}'.format(plan.get_full_url(), plan.name), + 'TP-{1}: {2}'.format( + reverse('test_plan_url', args=[plan.pk, slugify(plan.name)]), + plan.pk, + plan.name), html=True) def test_list_plans(self): diff --git a/tcms/testplans/tests/tests.py b/tcms/testplans/tests/tests.py index 2c5221a9ba..3575c467e0 100644 --- a/tcms/testplans/tests/tests.py +++ b/tcms/testplans/tests/tests.py @@ -154,7 +154,8 @@ def test_plan_treeview(self): data = json.loads(str(response.content, encoding=settings.DEFAULT_CHARSET)) self.assertEqual(1, len(data)) self.assertEqual(self.test_plan.pk, data[0]['pk']) - self.assertEqual(self.test_plan.get_full_url(), data[0]['get_full_url']) + self.assertEqual(reverse('test_plan_url_short', args=[self.test_plan.pk]), + data[0]['plan_url']) self.assertEqual(None, data[0]['parent']) self.assertEqual(1, data[0]['num_children']) @@ -704,7 +705,9 @@ def test_search_all_runs(self): self.assertEqual(TestPlan.objects.count(), data['iTotalDisplayRecords']) for i, plan in enumerate(TestPlan.objects.all().order_by('pk')): self.assertEqual( - "{}".format(plan.get_full_url(), plan.pk), + "{}".format( + reverse('test_plan_url', args=[plan.pk, slugify(plan.name)]), + plan.pk), data['aaData'][i]['0']) def test_emtpy_plans(self): @@ -734,7 +737,9 @@ def test_get_first_page_order_by_pk(self): for i, plan in enumerate(expected_plans): self.assertEqual( - "{}".format(plan.get_full_url(), plan.pk), + "{}".format( + reverse('test_plan_url', args=[plan.pk, slugify(plan.name)]), + plan.pk), data['aaData'][i]['0']) def test_get_last_page_order_by_name(self): @@ -759,7 +764,9 @@ def test_get_last_page_order_by_name(self): for i, plan in enumerate(expected_plans): self.assertEqual( - "{}".format(plan.get_full_url(), plan.pk), + "{}".format( + reverse('test_plan_url', args=[plan.pk, slugify(plan.name)]), + plan.pk), data['aaData'][i]['0']) def test_get_second_page_order_by_pk_desc(self): @@ -782,5 +789,7 @@ def test_get_second_page_order_by_pk_desc(self): for i, plan in enumerate(expected_plans): self.assertEqual( - "{}".format(plan.get_full_url(), plan.pk), + "{}".format( + reverse('test_plan_url', args=[plan.pk, slugify(plan.name)]), + plan.pk), data['aaData'][i]['0']) diff --git a/tcms/testplans/views.py b/tcms/testplans/views.py index 0f7427746e..d4c7aeb1fb 100644 --- a/tcms/testplans/views.py +++ b/tcms/testplans/views.py @@ -162,7 +162,7 @@ def get_all(request, template_name='plan/all.html'): for attr in ['pk', 'num_cases', 'num_cases', 'num_runs', 'num_children']: dict_obj[attr] = getattr(obj, attr) - dict_obj['get_full_url'] = obj.get_full_url() + dict_obj['plan_url'] = reverse('test_plan_url_short', args=[obj.pk]) results.append(dict_obj) return JsonResponse(results, safe=False) @@ -342,9 +342,9 @@ def get(request, plan_id, slug=None, template_name='plan/get.html'): except ObjectDoesNotExist: raise Http404 - # redirect if has a cheated slug - if slug != slugify(test_plan.name): - return HttpResponsePermanentRedirect(test_plan.get_full_url()) + if slug is None: + return HttpResponsePermanentRedirect(reverse('test_plan_url', + args=[plan_id, slugify(test_plan.name)])) # Initial the case counter confirm_status_name = 'CONFIRMED'
    {{ test_plan.plan_id }}{{ test_plan }} {{ test_plan.plan_id }}{{ test_plan }} {{ test_plan.author }} {% if test_plan.owner %} @@ -30,8 +30,8 @@ {{ test_plan.product }} {{ test_plan.type }}{{ test_plan.num_cases }}{{ test_plan.num_runs }}{{ test_plan.num_cases }}{{ test_plan.num_runs }} {% if perms.testplans.change_testplan %} Edit diff --git a/tcms/templates/plan/get.html b/tcms/templates/plan/get.html index 07a7246313..639e07d5e5 100644 --- a/tcms/templates/plan/get.html +++ b/tcms/templates/plan/get.html @@ -121,7 +121,7 @@

    Parent :
    {% if test_plan.parent.pk %} - {{ test_plan.parent.pk }} + {{ test_plan.parent.pk }} {% else %} None {% endif %} diff --git a/tcms/templates/report/custom_details_case_runs.html b/tcms/templates/report/custom_details_case_runs.html index a9f8757628..939798c129 100644 --- a/tcms/templates/report/custom_details_case_runs.html +++ b/tcms/templates/report/custom_details_case_runs.html @@ -11,7 +11,7 @@

    {{ test_case_run.case.pk }}{{ test_case_run.case.pk }} {{ test_case_run.pk }} {{ test_case_run.case.summary }} {{ test_case_run.case.category }}
    - [{{ plan.0.plan_id }}] {{ plan.0.name }} + TP-{{ plan.0.pk }}: {{ plan.0.name }} [{{ run.run_id }}] {{ run.summary }}TR-{{ run.pk }}: {{ run.summary }} {{ status_count.IDLE|default:'' }} {{ status_count.RUNNING|default:'' }} {{ status_count.PAUSED|default:'' }}
    {{ plan.name }}{{ plan.name }} {{ builds_count }} {{ runs_count }} {{ status_subtotal.PASSED|default:0 }}{{ build.0 }}{{ run.summary }}{{ run.summary }} {{ status_subtotal.IDLE|default:0 }} {{ status_subtotal.RUNNING|default:0 }} {{ status_subtotal.PAUSED|default:0 }} - [{{ plan.0.pk }}] {{ plan.0.name }} + TP-{{ plan.0.pk }}: {{ plan.0.name }} {{ run.summary }}{{ run.summary }} {{ status_subtotal.IDLE|default:0 }} {{ status_subtotal.RUNNING|default:0 }} {{ status_subtotal.PAUSED|default:0 }}
    Test Plan{{ test_run.plan.name }}{{ test_run.plan.name }} All Confirmed Cases {{ confirmed_cases_count }}
    {{ test_run.summary }} {{ test_run.manager }} {% if test_run.default_tester_id %}{% endif %}{{ test_run.default_tester }}{% if test_run.default_tester_id %}{% endif %} {{ test_run.build.product }} {{ test_run.product_version }} {{ test_run.env_values_str }}