Skip to content

Commit

Permalink
Remove deprecated estimated_time. Fix #514
Browse files Browse the repository at this point in the history
We haven't received feedback that this field is in use so
removing it!

Migrations for 'testcases':
  tcms/testcases/migrations/0022
    - Remove field estimated_time from historicaltestcase
    - Remove field estimated_time from testcase
Migrations for 'testruns':
  tcms/testruns/migrations/0018
    - Remove field estimated_time from historicaltestrun
    - Remove field estimated_time from testrun
  • Loading branch information
atodorov committed Oct 3, 2018
1 parent a5d2b39 commit 9348d74
Show file tree
Hide file tree
Showing 20 changed files with 44 additions and 119 deletions.
24 changes: 0 additions & 24 deletions tcms/static/js/tcms_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,30 +196,6 @@ function checkCookie() {
}
}

function removeItem(item, tc_estimated_time) {
var tr_estimated_time = parseInt(jQ('#estimated_time').data('time'));
var remain_estimated_time = tr_estimated_time - tc_estimated_time;
var second_value = remain_estimated_time % 60;
var minute = parseInt(remain_estimated_time / 60);
var minute_value = minute % 60;
var hour = parseInt(minute / 60);
var hour_value = hour % 24;
var day_value = parseInt(hour / 24);

var remain_estimated_time_value = day_value ? day_value + ' ' : '';
remain_estimated_time_value += hour_value + ':';
remain_estimated_time_value += minute_value + ':';
remain_estimated_time_value += second_value;

if (!remain_estimated_time_value.length) {
remain_estimated_time_value = '0';
}

jQ('#estimated_time').data('time', remain_estimated_time);
document.getElementById('id_estimated_time').value = remain_estimated_time_value;
jQ('#' + item).remove();
}

function splitString(str, num) {
cut_for_dot = num - 3;

Expand Down
9 changes: 0 additions & 9 deletions tcms/templates/case/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,6 @@
<span >{{ form.default_tester }}</span>
<div class="errors">{{ form.default_tester.errors }}</div>
</div>

<div class="data_row">
<label>Estimated Time</label>
<div id="form_estimated_time" >
<span id="form_estimated_time">{{ form.estimated_time }}</span>
<span class="grey">(eg. 3 04:30:00)</span>
<div class="errors">{{ form.estimated_time.errors }}</div>
</div>
</div>
<div class="data_row">
<label >Status</label>
<span id="form_status" >{{ form.case_status }}</span>
Expand Down
4 changes: 0 additions & 4 deletions tcms/templates/case/get.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ <h2 id="display_title">{{ test_case.summary }}</h2>
<span id="display_category" >{{ test_case.category }}</span>
</div>
</div>
<div class="listinfo">
<div class="title grey">Estimated Time&nbsp;:</div>
<div id="display_estimated_time" class="name">{{ test_case.estimated_time }}</div>
</div>
<div class="listinfo">
<div class="title grey">Priority&nbsp;:</div>
<div class="name"><span id="display_priority" >{{ test_case.priority }}</span></div>
Expand Down
8 changes: 0 additions & 8 deletions tcms/templates/case/new.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,6 @@
{{ form.default_tester }}<div class="errors">{{ form.default_tester.errors }}</div>
</div>

<div class="data_row">
<label >Estimated Time</label>
<div class="time">
{{ form.estimated_time }}
<span class="grey">(eg. 3 04:30:00)</span>
<div class="errors">{{ form.estimated_time.errors }}</div>
</div>
</div>
<div class="data_row">
<label>Priority</label>
{{ form.priority }}<div class="errors">{{ form.priority.errors }}</div>
Expand Down
3 changes: 0 additions & 3 deletions tcms/templates/run/report.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
<div class="listinfo">
<span class="title">Manager:</span>{{ test_run.manager.username }}
</div>
<div class="listinfo">
<span class="title">Estimated Time:</span>{{ test_run.estimated_time }}
</div>
</div>
<div class="rightlistinfo">
<div class="listinfo">
Expand Down
2 changes: 0 additions & 2 deletions tcms/testcases/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ class BaseCaseForm(forms.Form):
widget=forms.Textarea,
required=False
)
estimated_time = forms.DurationField(label='Estimated Time', initial='0', required=False)
setup = forms.CharField(label="Setup", widget=SimpleMDE(), required=False)
action = forms.CharField(label="Actions", widget=SimpleMDE(), required=False)
effect = forms.CharField(label="Expect results", widget=SimpleMDE(), required=False)
Expand Down Expand Up @@ -200,7 +199,6 @@ class CaseNotifyForm(forms.Form):


class XMLRPCBaseCaseForm(BaseCaseForm):
estimated_time = forms.DurationField(required=False)
is_automated = forms.ChoiceField(
choices=FULL_AUTOMATED_CHOICES,
widget=forms.CheckboxSelectMultiple(),
Expand Down
21 changes: 21 additions & 0 deletions tcms/testcases/migrations/0022_remove_estimated_time.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 2.1.2 on 2018-10-03 08:51

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('testcases', '0021_convert_cc_list_to_string'),
]

operations = [
migrations.RemoveField(
model_name='historicaltestcase',
name='estimated_time',
),
migrations.RemoveField(
model_name='testcase',
name='estimated_time',
),
]
4 changes: 1 addition & 3 deletions tcms/testcases/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from datetime import datetime, timedelta
from datetime import datetime

from django.conf import settings
from django.urls import reverse
Expand Down Expand Up @@ -107,7 +107,6 @@ class TestCase(TCMSActionModel):
summary = models.CharField(max_length=255)
requirement = models.CharField(max_length=255, blank=True, null=True)
alias = models.CharField(max_length=255, blank=True)
estimated_time = models.DurationField(default=timedelta(0))
notes = models.TextField(blank=True, null=True)

case_status = models.ForeignKey(TestCaseStatus, on_delete=models.CASCADE)
Expand Down Expand Up @@ -170,7 +169,6 @@ def create(cls, author, values):
summary=values['summary'],
requirement=values['requirement'],
alias=values['alias'],
estimated_time=values['estimated_time'],
case_status=values['case_status'],
category=values['category'],
priority=values['priority'],
Expand Down
1 change: 0 additions & 1 deletion tcms/testcases/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,6 @@ def setUpTestData(cls):
'product': cls.case_1.category.product.pk,
'category': cls.case_1.category.pk,
'default_tester': '',
'estimated_time': '0',
'case_status': cls.case_status_confirmed.pk,
'arguments': '',
'extra_link': '',
Expand Down
4 changes: 0 additions & 4 deletions tcms/testcases/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -915,8 +915,6 @@ def update_testcase(request, tc, tc_form):
except ObjectDoesNotExist:
pass

# FIXME: Bug here, timedelta from form cleaned data need to convert.
tc.estimated_time = tc_form.cleaned_data['estimated_time']
# IMPORTANT! tc.current_user is an instance attribute,
# added so that in post_save, current logged-in user info
# can be accessed.
Expand Down Expand Up @@ -1041,7 +1039,6 @@ def edit(request, case_id, template_name='case/edit.html'):
'category': tc.category_id,
'notes': tc.notes,
'component': [c.pk for c in tc.component.all()],
'estimated_time': tc.estimated_time,
'setup': tctxt.setup,
'action': tctxt.action,
'effect': tctxt.effect,
Expand Down Expand Up @@ -1130,7 +1127,6 @@ def clone(request, template_name='case/clone.html'):
summary=tc_src.summary,
requirement=tc_src.requirement,
alias=tc_src.alias,
estimated_time=tc_src.estimated_time,
case_status=TestCaseStatus.get_PROPOSED(),
category=tc_src.category,
priority=tc_src.priority,
Expand Down
1 change: 0 additions & 1 deletion tcms/testplans/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ def clone(self, new_name=None, product=None, version=None,
summary=tpcase_src.summary,
requirement=tpcase_src.requirement,
alias=tpcase_src.alias,
estimated_time=tpcase_src.estimated_time,
case_status=TestCaseStatus.get_PROPOSED(),
category=tc_category,
priority=tpcase_src.priority,
Expand Down
7 changes: 0 additions & 7 deletions tcms/testplans/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,6 @@ def _add_cases_to_runs(request, plan_id):
if test_case.case_id not in existing_cases:
test_run.add_case_run(case=test_case)

estimated_time = datetime.timedelta(0)
for case in to_be_added_cases:
estimated_time += case.estimated_time

test_run.estimated_time = test_run.estimated_time + estimated_time
test_run.save()

if not cases_selected:
messages.add_message(request,
messages.ERROR,
Expand Down
10 changes: 0 additions & 10 deletions tcms/testruns/forms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
from datetime import timedelta

from django import forms
from django.contrib.auth.models import User

Expand All @@ -16,7 +14,6 @@ class BaseRunForm(forms.Form):
summary = forms.CharField(max_length=255)
manager = UserField()
default_tester = UserField(required=False)
estimated_time = forms.DurationField(required=False)
build = forms.ModelChoiceField(
queryset=Build.objects.none(),
)
Expand All @@ -29,13 +26,6 @@ def populate(self, product_id):
query = {'product_id': product_id}
self.fields['build'].queryset = Build.list_active(query)

def clean_estimated_time(self):
estimated_time = self.cleaned_data.get('estimated_time', timedelta(0))
# can be either None, '', 0 or timedelta(0)
if not estimated_time:
estimated_time = timedelta(0)
return estimated_time


class NewRunForm(BaseRunForm):
case = forms.ModelMultipleChoiceField(
Expand Down
21 changes: 21 additions & 0 deletions tcms/testruns/migrations/0018_remove_estimated_time.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 2.1.2 on 2018-10-03 08:51

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('testruns', '0017_remove_env'),
]

operations = [
migrations.RemoveField(
model_name='historicaltestrun',
name='estimated_time',
),
migrations.RemoveField(
model_name='testrun',
name='estimated_time',
),
]
3 changes: 0 additions & 3 deletions tcms/testruns/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ class TestRun(TCMSActionModel):
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',
on_delete=models.CASCADE)
Expand Down
3 changes: 0 additions & 3 deletions tcms/testruns/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# pylint: disable=invalid-name

from http import HTTPStatus
from datetime import timedelta

from django.utils import formats
from django.urls import reverse
Expand Down Expand Up @@ -157,7 +156,6 @@ def test_create_a_new_run(self):
self.assertEqual(self.version, new_run.product_version)
self.assertEqual(None, new_run.stop_date)
self.assertEqual('Clone new run', new_run.notes)
self.assertEqual(timedelta(0), new_run.estimated_time)
self.assertEqual(self.build_fast, new_run.build)
self.assertEqual(self.tester, new_run.manager)
self.assertEqual(self.tester, new_run.default_tester)
Expand Down Expand Up @@ -245,7 +243,6 @@ def test_clone_a_run(self):
'errata_id': '',
'manager': self.test_run.manager.email,
'default_tester': self.test_run.default_tester.email,
'estimated_time': '0',
'notes': '',
'case': [self.case_run_1.case.pk, self.case_run_2.case.pk],
'case_run_id': [self.case_run_1.pk, self.case_run_2.pk],
Expand Down
11 changes: 1 addition & 10 deletions tcms/testruns/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from datetime import datetime
from http import HTTPStatus
from functools import reduce

from django.conf import settings
from django.contrib import messages
Expand Down Expand Up @@ -95,7 +94,6 @@ def new(request):
build=form.cleaned_data['build'],
manager=form.cleaned_data['manager'],
default_tester=default_tester,
estimated_time=form.cleaned_data['estimated_time'],
)

try:
Expand Down Expand Up @@ -302,7 +300,6 @@ def edit(request, run_id):
test_run.build = form.cleaned_data['build']
test_run.product_version = test_run.plan.product_version
test_run.notes = form.cleaned_data['notes']
test_run.estimated_time = form.cleaned_data['estimated_time']
test_run.save()

return HttpResponseRedirect(reverse('testruns-get', args=[run_id, ]))
Expand All @@ -316,7 +313,6 @@ def edit(request, run_id):
'version': test_run.product_version_id,
'build': test_run.build_id,
'notes': test_run.notes,
'estimated_time': test_run.estimated_time,
})
form.populate(test_run.plan.product_id)

Expand Down Expand Up @@ -649,14 +645,9 @@ def post(self, request, run_id):

test_plan = test_run.plan
test_cases = test_run.plan.case.filter(case_status__name='CONFIRMED').select_related(
'default_tester').only('default_tester__id', 'estimated_time').filter(
'default_tester').only('default_tester__id').filter(
case_id__in=test_cases_ids)

estimated_time = reduce(lambda x, y: x + y,
(test_case.estimated_time for test_case in test_cases))
test_run.estimated_time = test_run.estimated_time + estimated_time
test_run.save(update_fields=['estimated_time'])

if request.POST.get('_use_plan_sortkey'):
test_case_pks = (test_case.pk for test_case in test_cases)
query_set = TestCasePlan.objects.filter(
Expand Down
10 changes: 0 additions & 10 deletions tcms/xmlrpc/api/testcase.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-

from django.utils.dateparse import parse_duration
from django.forms import EmailField, ValidationError

from modernrpc.core import rpc_method, REQUEST_KEY
Expand Down Expand Up @@ -263,9 +262,6 @@ def create(values, **kwargs):
if not (values.get('category') or values.get('summary')):
raise ValueError()

if values.get('estimated_time'):
values['estimated_time'] = parse_duration(values.get('estimated_time'))

form = NewCaseForm(values)
form.populate(values.get('product'))

Expand Down Expand Up @@ -305,9 +301,6 @@ def filter(query): # pylint: disable=redefined-builtin
:class:`tcms.testcases.models.TestCaseText` object!
:rtype: list(dict)
"""
if query.get('estimated_time'):
query['estimated_time'] = parse_duration(query.get('estimated_time'))

results = []
for case in TestCase.objects.filter(**query).distinct():
serialized_case = case.serialize()
Expand Down Expand Up @@ -337,9 +330,6 @@ def update(case_id, values, **kwargs):
:raises: TestCase.DoesNotExist if object specified by PK doesn't exist
:raises: PermissionDenied if missing *testcases.change_testcase* permission
"""
if values.get('estimated_time'):
values['estimated_time'] = parse_duration(values.get('estimated_time'))

form = UpdateCaseForm(values)

if values.get('category') and not values.get('product'):
Expand Down
Loading

0 comments on commit 9348d74

Please sign in to comment.