Skip to content

Commit

Permalink
Enable 'delete task'
Browse files Browse the repository at this point in the history
  • Loading branch information
ttx committed Jul 10, 2013
1 parent aec2fd7 commit 0338aea
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
26 changes: 24 additions & 2 deletions stories/templates/stories.view.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ <h4>{{ story.title }}</h4>
<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 %}
Expand Down Expand Up @@ -230,7 +230,7 @@ <h3 id="editTaskLabel">Edit
{% 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 }}">
Expand All @@ -242,6 +242,28 @@ <h3 id="editTaskLabel">Edit
</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() {
Expand Down
1 change: 1 addition & 0 deletions stories/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@
(r'^(\d+)/comment$', 'comment'),
(r'^(\d+)/priority$', 'set_priority'),
(r'^task/(\d+)$', 'edit_task'),
(r'^task/(\d+)/delete$', 'delete_task'),
)
18 changes: 16 additions & 2 deletions stories/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 0338aea

Please sign in to comment.