Skip to content

Commit

Permalink
Convert TestRun edit page to Patternfly
Browse files Browse the repository at this point in the history
NOTES:

- estimated_time is scheduled for removal so not shown in the form
- product_version is scheduled for removal in favor of
  TR.plan.product_version
- Product & Version can't be editted anymore. Must be set on the
  parent TestPlan instead.
- TestRun still allows specifying builds
- environment is scheduled for deprecation (see #484) and is not
  shown anymore. Fix #445
  • Loading branch information
atodorov committed Aug 23, 2018
1 parent 24db12e commit a43d5a1
Show file tree
Hide file tree
Showing 12 changed files with 109 additions and 212 deletions.
4 changes: 4 additions & 0 deletions tcms/static/js/tcms_actions.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
if (!jQ) {
var jQ = $;
}

// Create a dictionary to avoid polluting the global namespace:
var Nitrate = window.Nitrate || {}; // Ironically, this global name is not respected. So u r on ur own.
window.Nitrate = Nitrate;
Expand Down
1 change: 1 addition & 0 deletions tcms/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Kiwi TCMS - {% block title %}{% trans "the leading open source test case management system" %}{% endblock %}</title>
{% include 'patternfly.html' %}
{% block head %}{% endblock %}
</head>
<body class="{% block body_class %}{% endblock %}">
{% include 'navbar.html' %}
Expand Down
6 changes: 3 additions & 3 deletions tcms/templates/run/clone.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ <h2>Clone TestRun - {{ test_run.summary }}</h2>
<tr>
<td width="15%"><label for="">Product</label></td>
<td>
{{ clone_form.product }}
{{ test_run.plan.product.name }}
</td>
</tr>
<tr>
<td><label>Product Version</label></td>
<td>{{ clone_form.product_version }}<span class="errors">{{ clone_form.product_version.errors }}</span>
<a href="{% url 'admin:management_version_add' %}" class="addlink" id="add_id_product_version">Add Product Version</a>
<td>
{{ test_run.plan.product_version.value }}
</td>
</tr>
<tr>
Expand Down
147 changes: 0 additions & 147 deletions tcms/templates/run/edit.html

This file was deleted.

10 changes: 2 additions & 8 deletions tcms/templates/run/get.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<!-- Store some values for easier javascript acccess -->
<div id="tcms_values" class="hidden">
<input id="value_run_id" type="hidden" name="run_id" value="{{ test_run.run_id }}" />
<input id="value_product_id" type="hidden" name="product_id" value="{{ test_run.build.product_id }}" />
<input id="value_product_id" type="hidden" name="product_id" value="{{ test_run.plan.product_id }}" />
</div>
<div class="control">
{% if perms.testruns.change_testcaserun %}
Expand Down Expand Up @@ -64,7 +64,7 @@ <h2 id="display_title">{{ test_run.summary }}</h2>
<div class="listinfo">
<div class="title grey">Product Version&nbsp;:</div>
<div class="name">
<a href="{% url "testruns-all" %}?product={{ test_run.build.product_id }}&product_version={{ test_run.product_version_id }}" title="Search test runs of {{ test_run.product_version }}">{{ test_run.product_version }}</a>
<a href="{% url "testruns-all" %}?product={{ test_run.plan.product_id }}&product_version={{ test_run.plan.product_version_id }}" title="Search test runs of {{ test_run.plan.product_version.value }}">{{ test_run.plan.product_version.value }}</a>
</div>
</div>
<div class="listinfo">
Expand All @@ -73,12 +73,6 @@ <h2 id="display_title">{{ test_run.summary }}</h2>
<a href="{% url "tcms-profile" test_run.manager.username %}">{{ test_run.manager.username }}</a>
</div>
</div>
<div class="listinfo">
<div class="title grey">Estimated Time&nbsp;:</div>
<div class="name">
{{ test_run.estimated_time }}
</div>
</div>
<div class="listinfo">
<div class="title grey">Started at&nbsp;:</div>
<div class="name">
Expand Down
8 changes: 3 additions & 5 deletions tcms/templates/run/new.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,13 @@ <h2>Create New Test Run</h2>
</td>
</tr>
<tr>
<td width="15%" valign="top"><label for="">Product</label></td>
<td>{{ form.product }}</td>
<td width="15%" valign="top"><label>Product</label></td>
<td>{{ test_plan.product.name }}</td>
</tr>
<tr>
<td valign="top"><label>Product Version</label></td>
<td>
{{ form.product_version }}
<span class="errors">{{ form.product_version.errors }}</span>
<a href="{% url 'admin:management_version_add' %}" class="addlink" id="add_id_product_version">Add Product Version</a>
{{ test_plan.product_version.value }}
</td>
</tr>
<tr>
Expand Down
30 changes: 4 additions & 26 deletions tcms/testruns/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,18 @@


class BaseRunForm(forms.Form):
summary = forms.CharField(label='Summary', max_length=255)
manager = UserField(label='Manager')
default_tester = UserField(
label='Default Tester',
required=False
)
product = forms.ModelChoiceField(
label='Product',
queryset=Product.objects.all(),
empty_label=None,
)
summary = forms.CharField(max_length=255)
manager = UserField()
default_tester = UserField(required=False)
estimated_time = forms.DurationField(required=False)
product_version = forms.ModelChoiceField(
label='Product Version',
queryset=Version.objects.none(),
empty_label=None,
)
build = forms.ModelChoiceField(
label='Build',
queryset=Build.objects.none(),
)
notes = forms.CharField(
label='Notes',
widget=forms.Textarea,
required=False
)
# todo: what are these 2 fields
keep_status = forms.BooleanField(
label='Reserve Status', widget=forms.CheckboxInput(),
required=False
Expand All @@ -75,8 +61,6 @@ def populate(self, product_id):
# django-choicefield-queryset (Chinese)
# Is this documented elsewhere?
query = {'product_id': product_id}
self.fields['product_version'].queryset = Version.objects.filter(
product__id=product_id)
self.fields['build'].queryset = Build.list_active(query)

def clean_estimated_time(self):
Expand All @@ -94,12 +78,6 @@ class NewRunForm(BaseRunForm):
)


class EditRunForm(BaseRunForm):
finished = forms.BooleanField(label='Finished', required=False)


# =========== Forms for XML-RPC functions ==============

class XMLRPCNewRunForm(BaseRunForm):
plan = forms.ModelChoiceField(
label='Test Plan',
Expand Down
4 changes: 4 additions & 0 deletions tcms/testruns/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,17 @@ class TestRun(TCMSActionModel):

run_id = models.AutoField(primary_key=True)

# todo: this field should be removed in favor of plan.product_version
# no longer shown in edit forms
product_version = models.ForeignKey('management.Version', related_name='version_run',
on_delete=models.CASCADE)

start_date = models.DateTimeField(auto_now_add=True, db_index=True)
stop_date = models.DateTimeField(null=True, blank=True, db_index=True)
summary = models.TextField()
notes = models.TextField(blank=True)
# todo: schedule for removal, after the migration to Patternfly this
# field is no longer shown in the edit form
estimated_time = models.DurationField(default=datetime.timedelta(0))

plan = models.ForeignKey('testplans.TestPlan', related_name='run',
Expand Down
5 changes: 5 additions & 0 deletions tcms/testruns/static/testruns/js/mutable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$(window).on('load', function() {
$('#add_id_build').click(function() {
return showRelatedObjectPopup(this);
});
});
73 changes: 73 additions & 0 deletions tcms/testruns/templates/testruns/mutable.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{% extends "base.html" %}
{% load i18n %}
{% load static %}

{% block title %}{% trans "Edit TestRun" %}{% endblock %}
{% block head %}
{{ block.super }}

<script src="{% static "grappelli/jquery/jquery.min.js" %}" type="text/javascript"></script>
<script src="{% static "grappelli/js/grappelli.min.js" %}" type="text/javascript"></script>
<script src="{% static "admin/js/admin/RelatedObjectLookups.js" %}" type="text/javascript"></script>

<script src="{% static 'testruns/js/mutable.js' %}"></script>
{% endblock %}

{% block contents %}
<div class="container-fluid container-cards-pf">
<form class="form-horizontal" action="{% url "testruns-edit" test_run.run_id %}" method="post">
{% csrf_token %}
<div class="form-group">
<label class="col-md-1 col-lg-1" for="id_summary">{% trans "Summary" %}</label>
<div class="col-md-11 col-lg-11">
<input type="text" id="id_summary" name="summary" value="{{ form.summary.value }}" class="form-control" required>
<p class="help-block"><a href="{% url 'test_plan_url_short' test_run.plan_id %}">TP-{{ test_run.plan_id }}: {{ test_run.plan.name }}</a></p>
</div>
</div>

<div class="form-group">
<div class="col-md-1 col-lg-1">
<label for="id_build">{% trans "Build" %}</label>
<a href="{% url 'admin:management_build_add' %}?_popup=1&product={{ test_run.plan.product_id }}"
id="add_id_build"
alt="{% trans 'add new Build' %}"
title="{% trans 'add new Build' %}">+</a>
</div>
<div class="col-md-3 col-lg-3">
<select class="form-control" id="id_build" name="build">
{% for option in form.build.field.queryset %}
<option value="{{ option.pk }}" {% if option.pk == form.build.value %}selected{% endif %}>{{ option.name }}</option>
{% endfor %}
</select>
<p class="help-block">
{% trans "Product" %}: {{ test_run.plan.product.name }}, {% trans "version" %} {{ test_run.plan.product_version.value }}
</p>
</div>

<label class="col-md-1 col-lg-1" for="id_manager">{% trans "Manager" %}</label>
<div class="col-md-3 col-lg-3 {% if form.manager.errors %}has-error{% endif %}">
<input id="id_manager" name="manager" value="{{ form.manager.value }}" type="text"
class="form-control" placeholder="{% trans 'Username or email' %}" required>
{{ form.manager.errors }}
</div>

<label class="col-md-1 col-lg-1" for="id_default_tester">{% trans "Default&nbsp;tester" %}</label>
<div class="col-md-3 col-lg-3 {% if form.default_tester.errors %}has-error{% endif %}">
<input id="id_default_tester" name="default_tester" value="{{ form.default_tester.value }}" type="text"
class="form-control" placeholder="{% trans 'Username or email' %}">
{{ form.default_tester.errors }}
</div>
</div>

<div class="form-group">
<label class="col-lg-12" for="id_notes">{% trans "Notes" %}</label>
<div class="col-lg-12">
<textarea class="form-control" id="id_notes" name="notes">{{ form.notes.value }}</textarea>
</div>
</div>

<button type="submit" class="btn btn-default">{% trans "Save" %}</button>
</form>

</div><!-- /container -->
{% endblock %}
Loading

0 comments on commit a43d5a1

Please sign in to comment.