From b77ecac442008bed036d793c7f51aeff05d4a56a Mon Sep 17 00:00:00 2001 From: "Mr. Senko" Date: Sun, 15 Sep 2019 16:48:44 +0300 Subject: [PATCH] Allow closing of bugs via comment. Refs #699 a closed bug doesn't allow any more comments. User will have to open a new one if the issue still persists. This should be very easy to do when opening from a TE since everything is automated. --- tcms/bugs/templates/bugs/get.html | 8 ++++++-- tcms/bugs/views.py | 9 ++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/tcms/bugs/templates/bugs/get.html b/tcms/bugs/templates/bugs/get.html index 9886405033..6df60e82cd 100644 --- a/tcms/bugs/templates/bugs/get.html +++ b/tcms/bugs/templates/bugs/get.html @@ -148,7 +148,7 @@

{% endfor %} - {% if perms.django_comments.add_comment %} + {% if perms.django_comments.add_comment and object.status %}
@@ -163,7 +163,11 @@

- + + +
diff --git a/tcms/bugs/views.py b/tcms/bugs/views.py index 66caa7ae2d..4ae5284247 100644 --- a/tcms/bugs/views.py +++ b/tcms/bugs/views.py @@ -11,6 +11,7 @@ from django.views.generic import DetailView from django.views.generic.base import TemplateView from django.views.generic.base import View +from django.utils.translation import ugettext_lazy as _ from tcms.bugs.models import Bug from tcms.management.models import Component @@ -133,7 +134,13 @@ def post(self, request, *args, **kwargs): if form.is_valid(): bug = form.cleaned_data['bug'] - add_comment([bug], form.cleaned_data['text'], request.user) + if form.cleaned_data['text']: + add_comment([bug], form.cleaned_data['text'], request.user) + + if request.POST.get('action') == 'close': + bug.status = False + bug.save() + add_comment([bug], _('*bug closed*'), request.user) return HttpResponseRedirect(reverse('bugs-get', args=[bug.pk]))