Introduce priorities

This commit is contained in:
Thierry Carrez 2013-07-02 15:39:13 +02:00
parent 75edee38c3
commit a35bb5dbda
5 changed files with 97 additions and 17 deletions

View File

@ -23,11 +23,18 @@ class Story(models.Model):
('B', 'Bug'),
('F', 'Feature'),
)
STORY_PRIORITIES = (
(4, 'Critical'),
(3, 'High'),
(2, 'Medium'),
(1, 'Low'),
(0, 'Undefined'),
)
creator = models.ForeignKey(User)
title = models.CharField(max_length=100)
description = models.TextField()
story_type = models.CharField(max_length=1, choices=STORY_TYPES)
importance = models.IntegerField()
priority = models.IntegerField(choices=STORY_PRIORITIES)
class Task(models.Model):

View File

@ -1,9 +1,11 @@
{% extends "stories.base.html" %}
{% load markup %}
{% load storypriofilters %}
{% block extranav %}
<div class="well sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header">This story</li>
<li><a href="#editprio" data-toggle="modal">Change priority</a></li>
<li><a href="#editstory" data-toggle="modal">Modify story</a></li>
<li><a href="#">Add task</a></li>
<li><a href="#">Order tasks</a></li>
@ -16,7 +18,8 @@
<h3>Bug {{ story.id }}</h3>
</div>
<div class="span10">
<span class="badge badge-important">Critical</span><br>
<span class="badge{{ story.priority|priobadge }}">
{{ story.get_priority_display }}</span><br>
<h4>{{ story.title }}</h4>
</div>
</div>
@ -61,7 +64,9 @@
<p><i class="icon-tags"></i>
{% for tag in story.storytag_set.all %}
<span class="label">{{ tag.name }}</span>
{% endfor %}</p>
{% endfor %}
<button class="btn btn-micro" type="button"><i class="icon-plus"></i></button>
</p>
</div>
</div>
<div class="row-fluid">
@ -78,28 +83,20 @@
</table>
<form>
<textarea class="input-block-level" rows="3" placeholder="Add a comment"></textarea>
<button class="btn btn-mini btn-primary" type="button">Add comment</button>
<button class="btn btn-mini" type="button">Add comment</button>
</form>
</div>
<!-- Modal -->
<div id="editstory" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div id="editstory" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="editStoryLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Modify story</h3>
<h3 id="editStoryLabel">Modify story</h3>
</div>
<div class="modal-body">
<label>Title</label>
<input class="input-block-level" type="text" value="{{ story.title }}">
<label>Importance</label>
<div class="btn-group" data-toggle="buttons-radio">
<button type="button" class="btn btn-small btn-danger active">Critical</button>
<button type="button" class="btn btn-small btn-warning">High</button>
<button type="button" class="btn btn-small btn-info">Medium</button>
<button type="button" class="btn btn-small">Low</button>
</div>
<label></label>
<label>Description <small>(can use Markdown)</small></label>
<textarea class="input-block-level" rows="8">{{ story.description }}
<textarea class="input-block-level" rows="9">{{ story.description }}
</textarea>
<label>Tags</label>
<div class="input-prepend">
@ -114,4 +111,28 @@
<button class="btn btn-primary">Save changes</button>
</div>
</div>
<!-- Modal -->
<div id="editprio" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="editPriolLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="editPrioLabel">Change priority</h3>
</div>
<div class="modal-body">
<label>Priority</label>
<div class="btn-group" data-toggle="buttons-radio">
{% for code, prio in priorities %}
<button type="button"
class="btn btn-small{{code|priobutton}}{% if story.priority == code %} active{% endif %}">{{ prio }}</button>
{% endfor %}
</div>
<hr>
<label>Comment</label>
<textarea class="input-block-level" rows="6"
placeholder="Add a comment"></textarea>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button class="btn btn-primary">Save changes</button>
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,14 @@
# Copyright 2011 Thierry Carrez <thierry@openstack.org>
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

View File

@ -0,0 +1,36 @@
# Copyright 2013 Thierry Carrez <thierry@openstack.org>
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from django import template
register = template.Library()
badges = ['', ' badge-info', ' badge-success', ' badge-warning',
' badge-important']
buttons = ['', ' btn-info', ' btn-success', ' btn-warning', ' btn-danger']
@register.filter(name='priobadge')
def priobadge(value):
if value < 5:
return badges[value]
else:
return badges[4]
@register.filter(name='priobutton')
def priobutton(value):
if value < 5:
return buttons[value]
else:
return buttons[4]

View File

@ -29,5 +29,7 @@ def dashboard(request):
def view(request, storyid):
story = Story.objects.get(id=storyid)
return render(request, "stories.view.html",
{'story': story })
return render(request, "stories.view.html", {
'story': story,
'priorities': Story.STORY_PRIORITIES,
})