diff --git a/tcms/testruns/migrations/0014_remove_auto_setting_start_date.py b/tcms/testruns/migrations/0014_remove_auto_setting_start_date.py new file mode 100644 index 0000000000..754d0b7403 --- /dev/null +++ b/tcms/testruns/migrations/0014_remove_auto_setting_start_date.py @@ -0,0 +1,23 @@ +# Generated by Django 3.1.6 on 2021-04-03 10:29 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("testruns", "0013_remove_product_version"), + ] + + operations = [ + migrations.AlterField( + model_name="historicaltestrun", + name="start_date", + field=models.DateTimeField(blank=True, db_index=True, null=True), + ), + migrations.AlterField( + model_name="testrun", + name="start_date", + field=models.DateTimeField(blank=True, db_index=True, null=True), + ), + ] diff --git a/tcms/testruns/models.py b/tcms/testruns/models.py index a23c02f0e2..b64cb85f4e 100755 --- a/tcms/testruns/models.py +++ b/tcms/testruns/models.py @@ -26,7 +26,7 @@ class TestRun(models.Model, UrlMixin): history = KiwiHistoricalRecords() - start_date = models.DateTimeField(auto_now_add=True, db_index=True) + start_date = models.DateTimeField(db_index=True, null=True, blank=True) stop_date = models.DateTimeField(null=True, blank=True, db_index=True) planned_start = models.DateTimeField(db_index=True, null=True, blank=True) planned_stop = models.DateTimeField(db_index=True, null=True, blank=True) diff --git a/tcms/testruns/static/testruns/js/get.js b/tcms/testruns/static/testruns/js/get.js index d908db97ea..741039bc03 100644 --- a/tcms/testruns/static/testruns/js/get.js +++ b/tcms/testruns/static/testruns/js/get.js @@ -10,6 +10,10 @@ const allExecutionStatuses = {}, $(document).ready(() => { + $('[data-toggle="tooltip"]').tooltip({ + trigger: 'hover' + }); + permissions.removeTag = $('#test_run_pk').data('perm-remove-tag') === 'True' permissions.addComment = $('#test_run_pk').data('perm-add-comment') === 'True' permissions.removeComment = $('#test_run_pk').data('perm-remove-comment') === 'True' @@ -19,23 +23,29 @@ $(document).ready(() => { const testRunId = $('#test_run_pk').data('pk') - $('#status_button').on('switchChange.bootstrapSwitch', (_event, state) => { - if (state) { - jsonRPC('TestRun.update', [testRunId, { 'stop_date': null }], () => { - $('.stop-date').html('-') - $('#test_run_pk').parent('h1').css({ 'text-decoration': 'none' }) - }) - } else { - const timeZone = $('#clock').data('time-zone') - const now = currentTimeWithTimezone(timeZone) - - jsonRPC('TestRun.update', [testRunId, { 'stop_date': now }], testRun => { - const stopDate = moment(testRun.stop_date).format("DD MMM YYYY, HH:mm a") - $('.stop-date').html(stopDate) - $('#test_run_pk').parent('h1').css({ 'text-decoration': 'line-through' }) - }) - } - }) + $('#start-button').on('click', function () { + const timeZone = $('#clock').data('time-zone') + const now = currentTimeWithTimezone(timeZone) + + jsonRPC('TestRun.update', [testRunId, { 'start_date': now }], testRun => { + const startDate = moment(testRun.start_date).format("DD MMM YYYY, HH:mm a") + $('.start-date').html(startDate); + $(this).hide(); + }) + }); + + $('#stop-button').on('click', function () { + const timeZone = $('#clock').data('time-zone') + const now = currentTimeWithTimezone(timeZone) + + jsonRPC('TestRun.update', [testRunId, { 'stop_date': now }], testRun => { + const stopDate = moment(testRun.stop_date).format("DD MMM YYYY, HH:mm a") + $('.stop-date').html(stopDate); + $(this).hide(); + $('#test_run_pk').parent('h1').css({ 'text-decoration': 'line-through' }) + }) + }); + $('.add-comment-bulk').click(function () { $(this).parents('.dropdown').toggleClass('open') diff --git a/tcms/testruns/templates/testruns/get.html b/tcms/testruns/templates/testruns/get.html index fa2260bc8a..8a928e69df 100644 --- a/tcms/testruns/templates/testruns/get.html +++ b/tcms/testruns/templates/testruns/get.html @@ -63,13 +63,6 @@

{% endif %} -

- {% trans 'Status' %}: - -

{% trans 'Planned start' %}: @@ -79,6 +72,16 @@

{% trans 'Started at' %}: {{ object.start_date }} + + {{ object.start_date|default:'-' }} + + {% if not object.start_date %} + + {% endif %}

@@ -86,15 +89,17 @@

{{ object.planned_stop|default:'-' }}

-

+

{% trans 'Finished at' %}: - {% if object.stop_date %} - {{ object.stop_date }} - {% else %} - - - {% endif %} + {{ object.stop_date|default:'-' }} + {% if not object.stop_date %} + + {% endif %}