Skip to content

Commit

Permalink
Use case/edit.html template for testcases.views.new(). Closes #565
Browse files Browse the repository at this point in the history
everywhere else Kiwi TCMS doesn't allow editting of many-to-many
relationships when creating or editting objects. For example tags,
bugs, components, test plans can be added via separate tabs once
the object has been created. This commit makes creating TestCase
objects to behave in similar fashion.

Added bonus is that it also reuses one of the existing templates.
  • Loading branch information
atodorov committed Nov 14, 2018
1 parent 06a8a58 commit 8ba63a0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
3 changes: 3 additions & 0 deletions tcms/static/js/testcase_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ Nitrate.TestCases.Create.on_load = function() {

Nitrate.TestCases.Edit.on_load = function() {
configure_product_on_load();
if ($('#id_category').val() === null || !$('#id_category').val().length) {
update_category_select_from_product();
}

jQ('.js-back-button').bind('click', function() {
window.history.go(-1);
Expand Down
37 changes: 23 additions & 14 deletions tcms/templates/case/edit.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{% extends "tcms_base.html" %}
{% load static %}
{% block subtitle %}Edit test case - {{ test_case.summary }}{% endblock %}
{% block subtitle %}
{% if test_case %}
Edit test case - {{ test_case.summary }}
{% else %}
Add new test case
{% endif %}
{% endblock %}

{% block extra_head %}
{{ form.media }}
Expand Down Expand Up @@ -34,21 +40,31 @@
{% endblock %}

{% block content_type %}
{% if test_case %}
<input type="hidden" name="content_type" value="testcases.testcase" />
<input type="hidden" name="object_pk" value="{{ test_case.pk }}" />
<input type="hidden" name="name" value="{{ test_case.summary }}" />
<input type="hidden" name="description" value="{{ test_case.notes }}" />
{% endif %}
{% endblock %}

{% block contents %}
<div id="content">
<span class="right-action">
{% if test_case %}
<a href="{% url "testcases-text_history" test_case.case_id %}?from_plan={{ test_plan.plan_id }}" class="historylink">
Edit History
</a>
{% endif %}
</span>
<form action="{% url "testcases-edit" test_case.case_id %}" method="post">
<input type="hidden" name="from_plan" value="{{ test_plan.plan_id }}">
{% if test_case %}
<form action="{% url "testcases-edit" test_case.case_id %}" method="post">
{% else %}
<form action="{% url "testcases-new" %}{% if test_plan %}?from_plan={{ test_plan.plan_id }}{% endif %}" method="POST">
{% endif %}
{% if test_plan %}
<input type="hidden" name="from_plan" value="{{ test_plan.plan_id }}" />
{% endif %}
<div class="Detailform border-1" >
<fieldset class="no-border background-light-grey">
<div class="editor-side">
Expand Down Expand Up @@ -90,16 +106,7 @@

</div>
<div class="editor-side">
{% if testplan %}
<div class="data_row">
<label >Product </label>
<div id="display_product">{{ testplan.product }}</div>
</div>
<div class="data_row">
<label>Plan</label>
<p>{{ testplan.name }}</p>
</div>
{% endif %}
{% if test_case %}
<div class="data_row">
<label>Author</label>
<div class="name">
Expand Down Expand Up @@ -128,7 +135,7 @@
<label >Last Modified</label>
<div id="display_modify_date" >{{ test_case.latest_text.create_date }}</div>
</div>
{% endif %}

<div class="data_row">
<label>Automated</label>
Expand Down Expand Up @@ -174,6 +181,7 @@ <h4 class="strong">Expected Results</h4>
<div class="" id="form_effect">{{ form.effect }}</div>
</div>
</fieldset>
{% if notify_form %}
<fieldset class="no-border notification">
<label class="strong">Send new case instance after editing <label class="grey">(The author of this case will receive the notification by default)</label>:</label>
<div>
Expand All @@ -192,6 +200,7 @@ <h4 class="strong">Expected Results</h4>
<span>{{ notify_form.cc_list.help_text }}</span>
</div>
</fieldset>
{% endif %}
<div id="control_box" class="submit-row">
<div class="errors">{{ form.errors }}{{ notify_form.errors }}</div>
<input type="submit" value="Save"/>
Expand Down
2 changes: 1 addition & 1 deletion tcms/testcases/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def create_testcase(request, form, test_plan):


@permission_required('testcases.add_testcase')
def new(request, template_name='case/new.html'):
def new(request, template_name='case/edit.html'):
"""New testcase"""
test_plan = plan_from_request_or_none(request)
# Initial the form parameters when write new case from plan
Expand Down

0 comments on commit 8ba63a0

Please sign in to comment.