Enable 'delete task'

This commit is contained in:
Thierry Carrez 2013-07-10 18:10:52 +02:00
parent aec2fd76f3
commit 0338aeaef1
3 changed files with 41 additions and 4 deletions

View File

@ -49,7 +49,7 @@
<td>{{ task.milestone.name }}</td>
<td>
<a href="#edittask{{ task.id }}" class="btn btn-micro" data-toggle="modal"><i class="icon-edit"></i></a>
<button class="btn btn-micro disabled" type="button"><i class="icon-remove"></i></button>
<a href="#deletetask{{ task.id }}" class="btn btn-micro" data-toggle="modal"><i class="icon-remove"></i></a>
</td>
</tr>
{% endfor %}
@ -230,7 +230,7 @@
{% endfor %}
</div>
<label class="after-buttongroup">Comment</label>
<textarea class="input-block-level" rows="3"
<textarea class="input-block-level" name="comment" rows="3"
placeholder="Add a comment"></textarea>
<input type="hidden" id="ms{{task.id}}" name="milestone" value="{{ task.milestone.id }}">
<input type="hidden" id="status{{task.id}}" name="status" value="{{ task.status }}">
@ -242,6 +242,28 @@
</div>
</form>
{% endfor %}
<!-- Removetask Modals -->
{% for task in story.task_set.all %}
<form method="POST" action="/story/task/{{ task.id }}/delete">
<div id="deletetask{{ task.id }}" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="deleteTaskLabel" aria-hidden="true">
{% csrf_token %}
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="editTaskLabel">Delete
{{task.project.name}}/{{task.series.name}} task ?</h3>
</div>
<div class="modal-body">
<label>Comment</label>
<textarea class="input-block-level" name="comment" rows="3"
placeholder="Add a comment"></textarea>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<input class="btn btn-primary" type="submit" value="Delete task">
</div>
</div>
</form>
{% endfor %}
{% endblock %}
{% block moarscript %}
$(".series").click(function() {

View File

@ -24,4 +24,5 @@ urlpatterns = patterns('stories.views',
(r'^(\d+)/comment$', 'comment'),
(r'^(\d+)/priority$', 'set_priority'),
(r'^task/(\d+)$', 'edit_task'),
(r'^task/(\d+)/delete$', 'delete_task'),
)

View File

@ -91,7 +91,7 @@ def add_task(request, storyid):
newcomment = Comment(story=story,
action=msg,
author=request.user,
comment_type="indent-left",
comment_type="plus-sign",
content=request.POST.get('comment', ''))
newcomment.save()
except KeyError as e:
@ -126,13 +126,27 @@ def edit_task(request, taskid):
newcomment = Comment(story=task.story,
action=msg,
author=request.user,
comment_type="align-left",
comment_type="tasks",
content=request.POST.get('comment', ''))
newcomment.save()
except KeyError as e:
pass
return HttpResponseRedirect('/story/%s' % task.story.id)
@login_required
@require_POST
def delete_task(request, taskid):
task = Task.objects.get(id=taskid)
task.delete()
msg = "Deleted %s/%s task" % (task.project.name, task.series.name)
newcomment = Comment(story=task.story,
action=msg,
author=request.user,
comment_type="remove-sign",
content=request.POST.get('comment', ''))
newcomment.save()
return HttpResponseRedirect('/story/%s' % task.story.id)
@login_required
@require_POST
def edit_story(request, storyid):