buttons "close and comment" & "comment and reopen"
This commit is contained in:
parent
c0ce90019e
commit
3d097abadb
2 changed files with 45 additions and 4 deletions
|
@ -93,9 +93,11 @@
|
|||
<div class="text-center">
|
||||
{% if perm.manage_issue %}
|
||||
{% if issue.closed %}
|
||||
<a href="{% url 'reopen-issue' project.name issue.id %}" class="btn btn-default"><span class="glyphicon glyphicon-refresh"></span> Reopen this issue</a>
|
||||
<a href="{% url 'reopen-issue' project.name issue.id %}" class="btn btn-default" id="normal-button"><span class="glyphicon glyphicon-refresh"></span> Reopen this issue</a>
|
||||
<button type="submit" class="btn btn-default" style="display: none;" id="comment-button" name="change-state"><span class="glyphicon glyphicon-refresh"></span> Reopen and comment</button>
|
||||
{% else %}
|
||||
<a href="{% url 'close-issue' project.name issue.id %}" class="btn btn-default"><span class="glyphicon glyphicon-ok-circle"></span> Close this issue</a>
|
||||
<a href="{% url 'close-issue' project.name issue.id %}" class="btn btn-default" id="normal-button"><span class="glyphicon glyphicon-ok-circle"></span> Close this issue</a>
|
||||
<button type="submit" class="btn btn-default" style="display: none;" id="comment-button" name="change-state"><span class="glyphicon glyphicon-ok-circle"></span> Comment and close</button>
|
||||
{% endif %}
|
||||
<button type="submit" class="btn btn-success"><span class="glyphicon glyphicon-pencil"></span> Add a comment</button>
|
||||
</div>
|
||||
|
@ -224,6 +226,15 @@
|
|||
{{ block.super }}
|
||||
<script type="text/javascript">
|
||||
var markdown_preview_url = "{% url 'markdown' %}";
|
||||
$('#markdown-content').on('keyup', function () {
|
||||
if ($('#markdown-content').val()) {
|
||||
$('#normal-button').hide();
|
||||
$('#comment-button').show();
|
||||
} else {
|
||||
$('#normal-button').show();
|
||||
$('#comment-button').hide();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<script src="{% static 'js/jquery.cookie.js' %}"></script>
|
||||
<script src="{% static 'js/markdown-preview.js' %}"></script>
|
||||
|
|
|
@ -424,6 +424,14 @@ def issue_comment_edit(request, project, issue, comment=None):
|
|||
|
||||
issue = get_object_or_404(Issue, project=project, id=issue)
|
||||
|
||||
redirect = 'to-issue'
|
||||
change_state = False
|
||||
|
||||
if 'change-state' in request.POST:
|
||||
if not request.user.has_perm('manage_issue', project):
|
||||
raise PermissionDenied()
|
||||
change_state = True
|
||||
|
||||
if comment:
|
||||
if not request.user.has_perm('modify_comment', project):
|
||||
raise PermissionDenied()
|
||||
|
@ -458,9 +466,27 @@ def issue_comment_edit(request, project, issue, comment=None):
|
|||
event.save()
|
||||
issue.subscribers.add(request.user)
|
||||
notify_new_comment(event)
|
||||
if change_state:
|
||||
issue.closed = not issue.closed
|
||||
issue.save()
|
||||
if issue.closed:
|
||||
event = Event(issue=issue, author=request.user, code=Event.CLOSE)
|
||||
event.save()
|
||||
notify_close_issue(event)
|
||||
messages.success(request, 'Comment added successfully and issue closed.')
|
||||
redirect = 'to-list'
|
||||
else:
|
||||
event = Event(issue=issue, author=request.user, code=Event.REOPEN)
|
||||
event.save()
|
||||
notify_reopen_issue(event)
|
||||
messages.success(request, 'Issue reopened and omment added successfully.')
|
||||
else:
|
||||
messages.success(request, 'Comment added successfully.')
|
||||
|
||||
if redirect == 'to-issue':
|
||||
return redirect('show-issue', project.name, issue.id)
|
||||
else:
|
||||
return redirect('list-issue', project.name)
|
||||
|
||||
c = {
|
||||
'project': project,
|
||||
|
@ -498,6 +524,8 @@ def issue_close(request, project, issue):
|
|||
|
||||
notify_close_issue(event)
|
||||
|
||||
messages.success(request, 'Issue closed.')
|
||||
|
||||
return redirect('list-issue', project.name)
|
||||
|
||||
|
||||
|
@ -514,6 +542,8 @@ def issue_reopen(request, project, issue):
|
|||
|
||||
notify_reopen_issue(event)
|
||||
|
||||
messages.success(request, 'Issue reopened.')
|
||||
|
||||
return redirect('show-issue', project.name, issue.id)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue