Enable 'add bug'

This commit is contained in:
Thierry Carrez 2013-07-11 14:48:18 +02:00
parent 91f7c5603e
commit 16df3b46bf
6 changed files with 84 additions and 6 deletions

View File

@ -22,6 +22,8 @@
</div><!--/span-->
</div>
{% endblock %}
{% block script %}
{% block postscript %}
<script type="text/javascript">$("#tab-projects").addClass('active')</script>
{% block modals %}
{% endblock %}
{% endblock %}

View File

@ -3,7 +3,7 @@
<div class="well sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header">Nova</li>
<li class="disabled"><a href="#">Report a bug</a></li>
<li><a href="#addstory" data-toggle="modal">Report a bug</a></li>
<li class="disabled"><a href="#">Triage bugs
<span class="badge badge-important">34</span></a></li>
<li class="disabled"><a href="#">Propose feature</a></li>
@ -17,3 +17,6 @@
</div>
</div>
{% endblock %}
{% block modals %}
{% include "stories.modal_addstory.html" with project="nova" %}
{% endblock %}

View File

@ -5,7 +5,7 @@
<div class="well sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header">Stories</li>
<li class="disabled"><a href="#">Add new bug</a></li>
<li><a href="#addstory" data-toggle="modal">Add new bug</a></li>
<li class="disabled"><a href="#">Add new feature</a></li>
<li class="disabled"><a href="#">Search stories</a></li>
<li class="nav-header">Reports</li>
@ -25,6 +25,7 @@
<script type="text/javascript">
$("#tab-tasks").addClass('active');
</script>
{% include "stories.modal_addstory.html" %}
{% block modals %}
{% endblock %}
{% endblock %}

View File

@ -0,0 +1,34 @@
<form method="POST" action="/story/new">{% csrf_token %}
<div id="addstory" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="addstoryLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="addstoryLabel">Create new bug</h3>
</div>
<div class="modal-body">
<label>Affected projects <small>(optional)</small></label>
<div class="input-prepend">
<span class="add-on"><i class="icon-cog"></i></span>
<input class="input-block-level" name="projects" id="prependedInput"
type="text" value="{{ project }}">
</span>
</div>
<label>Title</label>
<input class="input-block-level" name="title"
type="text" placeholder="Short description of the bug" value="">
<label>Description <small>(can use Markdown)</small></label>
<textarea class="input-block-level" name="description"
placeholder="Enter bug description here. Please include the version of the software used and detailed steps to reproduce." rows="7"></textarea>
<label>Tags <small>(optional)</small></label>
<div class="input-prepend">
<span class="add-on"><i class="icon-tags"></i></span>
<input class="input-block-level" name="tags" id="prependedInput"
type="text" value="">
</span>
</div>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<input class="btn btn-primary" type="submit" value="Create bug">
</div>
</div>
</form>

View File

@ -20,6 +20,7 @@ urlpatterns = patterns('stories.views',
(r'^$', 'dashboard'),
(r'^(\d+)$', 'view'),
(r'^(\d+)/addtask$', 'add_task'),
(r'^new$', 'add_story'),
(r'^(\d+)/edit$', 'edit_story'),
(r'^(\d+)/comment$', 'comment'),
(r'^(\d+)/priority$', 'set_priority'),

View File

@ -70,6 +70,45 @@ def set_priority(request, storyid):
newcomment.save()
return HttpResponseRedirect('/story/%s' % storyid)
@login_required
@require_POST
def add_story(request):
try:
newstory = Story(
title=request.POST['title'],
description=request.POST['description'],
creator=request.user,
priority=0,
)
newstory.save()
proposed_projects = request.POST['projects'].split()
if proposed_projects:
series=Series.objects.get(status=2)
tasks = []
for project in proposed_projects:
tasks.append(Task(
story=newstory,
project=Project.objects.get(name=project),
series=series,
))
Task.objects.bulk_create(tasks)
proposed_tags = set(request.POST['tags'].split())
if proposed_tags:
tags = []
for tag in proposed_tags:
tags.append(StoryTag(story=newstory, name=tag))
StoryTag.objects.bulk_create(tags)
msg = 'Story created (%s)' % newstory.title
newcomment = Comment(story=newstory,
action=msg,
author=request.user,
comment_type="star-empty",
content='')
newcomment.save()
except KeyError as e:
pass
return HttpResponseRedirect('/story/%s' % newstory.id)
@login_required
@require_POST
def add_task(request, storyid):
@ -162,10 +201,8 @@ def edit_story(request, storyid):
if (story.description != request.POST['description']):
onlytags = False
actions.append("description")
story.title = request.POST['title']
story.description = request.POST['description']
proposed_tags = set(request.POST['tags'].split())
print storytags
print proposed_tags
if proposed_tags != storytags:
actions.append("tags")
StoryTag.objects.filter(story=story).delete()