Skip to content

Commit

Permalink
Allow closing of bugs via comment. Refs #699
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
atodorov committed Sep 18, 2019
1 parent d9d4b9a commit b77ecac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
8 changes: 6 additions & 2 deletions tcms/bugs/templates/bugs/get.html
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ <h2 class="card-pf-title">
</div>
{% endfor %}

{% if perms.django_comments.add_comment %}
{% if perms.django_comments.add_comment and object.status %}
<div class="row row-cards-pf">
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="card-pf">
Expand All @@ -163,7 +163,11 @@ <h2 class="card-pf-title">

<div class="form-group">
<div>
<button type="submit" class="btn btn-default btn-lg">{% trans "Save" %}</button>
<button type="submit" name="action" value="comment" class="btn btn-default btn-lg">{% trans "Save" %}</button>

<button type="submit" name="action" value="close" class="btn btn-danger btn-lg" style="float:right">
{% trans "Close" %}
</button>
</div>
</div>
</form>
Expand Down
9 changes: 8 additions & 1 deletion tcms/bugs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]))

Expand Down

0 comments on commit b77ecac

Please sign in to comment.