Enable Modify story
This commit is contained in:
parent
23b1afa383
commit
23553a6ba5
|
@ -88,7 +88,8 @@
|
|||
<button class="btn btn-mini" type="submit">Add comment</button>
|
||||
</form>
|
||||
</div>
|
||||
<!-- Modal -->
|
||||
<!-- Modify Story modal -->
|
||||
<form method="POST" action="/story/{{story.id}}/edit">{% csrf_token %}
|
||||
<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>
|
||||
|
@ -96,24 +97,24 @@
|
|||
</div>
|
||||
<div class="modal-body">
|
||||
<label>Title</label>
|
||||
<input class="input-block-level" type="text" value="{{ story.title }}">
|
||||
<input class="input-block-level" name="title"
|
||||
type="text" value="{{ story.title }}">
|
||||
<label>Description <small>(can use Markdown)</small></label>
|
||||
<textarea class="input-block-level" rows="9">{{ story.description }}
|
||||
</textarea>
|
||||
<textarea class="input-block-level" name="description" rows="9">{{ story.description }}</textarea>
|
||||
<label>Tags</label>
|
||||
<div class="input-prepend">
|
||||
<span class="add-on"><i class="icon-tags"></i></span>
|
||||
<input class="input-block-level" id="prependedInput" type="text"
|
||||
<input class="input-block-level" name="tags" id="prependedInput" type="text"
|
||||
value="{% for tag in story.storytag_set.all %}{{ tag.name }} {% endfor %}">
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
|
||||
<button class="btn btn-primary">Save changes</button>
|
||||
<input class="btn btn-primary" type="submit" value="Save changes">
|
||||
</div>
|
||||
</div>
|
||||
<!-- Modal -->
|
||||
<!-- Set priority Modal -->
|
||||
<form method="POST" action="/story/{{ story.id }}/priority">
|
||||
<div id="editprio" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="editPriolLabel" aria-hidden="true">
|
||||
{% csrf_token %}
|
||||
|
|
|
@ -19,6 +19,7 @@ from django.conf.urls.defaults import *
|
|||
urlpatterns = patterns('stories.views',
|
||||
(r'^$', 'dashboard'),
|
||||
(r'^(\d+)$', 'view'),
|
||||
(r'^(\d+)/edit$', 'edit_story'),
|
||||
(r'^(\d+)/comment$', 'comment'),
|
||||
(r'^(\d+)/priority$', 'set_priority'),
|
||||
(r'^task/(\d+)$', 'edit_task'),
|
||||
|
|
|
@ -19,7 +19,7 @@ from django.http import HttpResponseRedirect, HttpResponseForbidden
|
|||
from django.shortcuts import render
|
||||
from django.contrib.auth.models import User
|
||||
from projects.models import Milestone
|
||||
from stories.models import Story, Task, Comment
|
||||
from stories.models import Story, Task, Comment, StoryTag
|
||||
|
||||
def dashboard(request):
|
||||
return render(request, "stories.dashboard.html")
|
||||
|
@ -63,7 +63,7 @@ def edit_task(request, taskid):
|
|||
try:
|
||||
actions = []
|
||||
if (task.title != request.POST['title']):
|
||||
actions.append("task title")
|
||||
actions.append("title")
|
||||
task.title = request.POST['title']
|
||||
milestone = Milestone.objects.get(id=request.POST['milestone'])
|
||||
if (milestone != task.milestone):
|
||||
|
@ -78,7 +78,8 @@ def edit_task(request, taskid):
|
|||
actions.append("assignee -> %s" % assignee.username)
|
||||
task.assignee = assignee
|
||||
if actions:
|
||||
msg = "Updated " + ", ".join(actions)
|
||||
msg = "Updated %s/%s task " % (task.project.name, task.series.name)
|
||||
msg += ", ".join(actions)
|
||||
task.save()
|
||||
newcomment = Comment(story=task.story,
|
||||
action=msg,
|
||||
|
@ -87,5 +88,47 @@ def edit_task(request, taskid):
|
|||
content=request.POST.get('comment', ''))
|
||||
newcomment.save()
|
||||
except KeyError as e:
|
||||
print e
|
||||
pass
|
||||
return HttpResponseRedirect('/story/%s' % task.story.id)
|
||||
|
||||
@login_required
|
||||
@require_POST
|
||||
def edit_story(request, storyid):
|
||||
story = Story.objects.get(id=storyid)
|
||||
storytags = set(x.name for x in StoryTag.objects.filter(story=story))
|
||||
onlytags = True
|
||||
try:
|
||||
actions = []
|
||||
if (story.title != request.POST['title']):
|
||||
onlytags = False
|
||||
actions.append("title")
|
||||
story.title = request.POST['title']
|
||||
if (story.description != request.POST['description']):
|
||||
onlytags = False
|
||||
actions.append("description")
|
||||
story.title = request.POST['title']
|
||||
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()
|
||||
tags = []
|
||||
for tag in proposed_tags:
|
||||
tags.append(StoryTag(story=story, name=tag))
|
||||
StoryTag.objects.bulk_create(tags)
|
||||
if actions:
|
||||
msg = "Updated story " + ", ".join(actions)
|
||||
story.save()
|
||||
if onlytags:
|
||||
comment_type = "tags"
|
||||
else:
|
||||
comment_type = "align-left"
|
||||
newcomment = Comment(story=story,
|
||||
action=msg,
|
||||
author=request.user,
|
||||
comment_type=comment_type)
|
||||
newcomment.save()
|
||||
except KeyError as e:
|
||||
print e
|
||||
return HttpResponseRedirect('/story/%s' % story.id)
|
||||
|
|
Loading…
Reference in New Issue