Skip to content

Commit

Permalink
Use JSON-RPC to remove comments when reviewing TestCase. Refs #960
Browse files Browse the repository at this point in the history
  • Loading branch information
atodorov committed Nov 24, 2019
1 parent bf73c87 commit d6fb2ea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
21 changes: 6 additions & 15 deletions tcms/static/js/testplan_actions.js
Expand Up @@ -768,22 +768,13 @@ function bindEventsOnLoadedCases(options) {
if (!window.confirm(default_messages.confirm.remove_comment)) {
return false;
}
var params = Nitrate.Utils.formSerialize(this);
var refresh_case = function(t) {
var returnobj = jQ.parseJSON(t.responseText);
if (returnobj.rc != 0) {
window.alert(returnobj.response);
return false;
}

var td = jQ('<td>', {colspan: 12});
var id = 'id_loading_' + params['object_pk'];
td.append(getAjaxLoading(id));
jQ(content).html(td);
fireEvent(btn, 'click');
fireEvent(btn, 'click');
};
removeComment(this, refresh_case);
const case_id = $(this).find('input[name=object_pk]').val();
const comment_id = $(this).find('input[name=comment_id]').val();
const comment_widget = $(this).parents().find("#comment"+comment_id);
jsonRPC('TestCase.remove_comment', [case_id, comment_id], function(data){
$(comment_widget).hide();
});
};
jQ(content).parent().find('.form_comment').unbind('submit');
jQ(content).parent().find('.form_comment').bind('submit', rc_callback);
Expand Down
6 changes: 3 additions & 3 deletions tcms/templates/case/get_details.html
Expand Up @@ -61,7 +61,7 @@ <h4>{% trans "Notes" %}:</h4>
<td colspan="3" style="border:none; background:none">
<h4>{% trans "Comments" %}:</h4>
{% for comment in case_comments %}
<div>
<div id="comment{{ comment.pk }}">
<div>
<span class="strong">#{{ forloop.counter }}</span>
<span class="strong">
Expand All @@ -73,15 +73,15 @@ <h4>{% trans "Comments" %}:</h4>
</div>
<div>
{% if review_mode and comment.user.pk == user.pk %}
<form action="{% url "comments-delete" %}" method="post" class="form_comment">
<form action="#" method="post" class="form_comment">
<input type="hidden" name="comment_id" value="{{ comment.pk }}" />
<input type="hidden" name="object_pk" value="{{ test_case.pk }}" />
<input class='commentdelete sprites' value='Delete Comment' type='submit' />
</form>
{% endif %}
</div>
</div>
{{ comment.comment|urlize|linebreaksbr }}
</div>
{% endfor %}
</td>
</tr>
Expand Down

0 comments on commit d6fb2ea

Please sign in to comment.