def new_run_with_caseruns(request, run_id, template_name='run/clone.html'): """Clone cases from filter caserun""" tr = get_object_or_404(TestRun, run_id=run_id) if request.POST.get('case_run'): tcrs = tr.case_run.filter(pk__in=request.POST.getlist('case_run')) else: tcrs = [] if not tcrs: messages.add_message(request, messages.ERROR, _('At least one TestCase is required')) return HttpResponseRedirect(reverse('testruns-get', args=[run_id])) estimated_time = reduce(lambda x, y: x + y, [tcr.case.estimated_time for tcr in tcrs]) if not request.POST.get('submit'): form = RunCloneForm( initial={ 'summary': tr.summary, 'notes': tr.notes, 'manager': tr.manager.email, 'product': tr.plan.product_id, 'product_version': tr.product_version_id, 'build': tr.build_id, 'default_tester': tr.default_tester_id and tr.default_tester.email or '', 'estimated_time': format_timedelta(estimated_time), 'use_newest_case_text': True, }) form.populate(product_id=tr.plan.product_id) context_data = { 'clone_form': form, 'test_run': tr, 'cases_run': tcrs, } return render(request, template_name, context_data)
def clear_estimated_time(self): """Converts a integer to time""" return format_timedelta(self.estimated_time)
def timedelta2string(object): from tcms.core.utils.timedeltaformat import format_timedelta return format_timedelta(object)