예제 #1
0
def add_task(request, storyid):
    story = Story.objects.get(id=storyid)
    try:
        if request.POST['project']:
            milestone = None
            if request.POST['milestone']:
                milestone = Milestone.objects.get(id=request.POST['milestone'])
            if not milestone or milestone.branch.status != 'M':
                milestone = Milestone.objects.get(branch__status='M',
                                                  undefined=True)
            newtask = Task(
                story=story,
                title=request.POST['title'],
                project=Project.objects.get(name=request.POST['project']),
                milestone=milestone,
            )
            newtask.save()
            msg = "Added %s task " % format_taskname(newtask)
            newcomment = Comment(story=story,
                                 action=msg,
                                 author=request.user,
                                 comment_type="plus-sign",
                                 content=request.POST.get('comment', ''))
            newcomment.save()
    except KeyError:
        pass
    return HttpResponseRedirect('/story/%s' % story.id)
예제 #2
0
파일: views.py 프로젝트: emonty/storyboard
def add_task(request, storyid):
    story = Story.objects.get(id=storyid)
    try:
        if request.POST['project']:
            if request.POST['series']:
                series = Series.objects.get(name=request.POST['series'])
            else:
                series = Series.objects.get(status=2)
            newtask = Task(
                story=story,
                title=request.POST['title'],
                project=Project.objects.get(name=request.POST['project']),
                series=series,
            )
            newtask.save()
            msg = "Added %s/%s task " % (
                newtask.project.name, newtask.series.name)
            newcomment = Comment(story=story,
                                 action=msg,
                                 author=request.user,
                                 comment_type="plus-sign",
                                 content=request.POST.get('comment', ''))
            newcomment.save()
    except KeyError:
        pass
    return HttpResponseRedirect('/story/%s' % story.id)
예제 #3
0
def comment(request, storyid):
    story = Story.objects.get(id=storyid)
    if request.POST.get('content', False):
        newcomment = Comment(story=story,
                             author=request.user,
                             comment_type="comment",
                             content=request.POST['content'])
        newcomment.save()
    return HttpResponseRedirect('/story/%s' % storyid)
예제 #4
0
def delete_task(request, taskid):
    task = Task.objects.get(id=taskid)
    task.delete()
    msg = "Deleted %s task" % format_taskname(task)
    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)
예제 #5
0
def set_priority(request, storyid):
    story = Story.objects.get(id=storyid)
    if 'priority' in request.POST:
        priority = request.POST['priority']
        if int(priority) != story.priority:
            pr = story.get_priority_display()
            story.priority = priority
            story.save()
            # We need to refresh the story to get get_priority_display to work
            story = Story.objects.get(id=storyid)
            msg = "Set priority: %s -> %s" % (pr, story.get_priority_display())
            newcomment = Comment(story=story,
                                 action=msg,
                                 author=request.user,
                                 comment_type="random",
                                 content=request.POST.get('comment', ''))
            newcomment.save()
    return HttpResponseRedirect('/story/%s' % storyid)
예제 #6
0
파일: views.py 프로젝트: emonty/storyboard
def edit_task(request, taskid):
    task = Task.objects.get(id=taskid)
    try:
        actions = []
        if (task.title != request.POST['title']):
            actions.append("title")
            task.title = request.POST['title']
        if not request.POST['milestone']:
            milestone = None
            milestonename = "None"
        else:
            milestone = Milestone.objects.get(
                id=int(request.POST['milestone']))
            milestonename = milestone.name
        if (milestone != task.milestone):
            actions.append("milestone -> %s" % milestonename)
            task.milestone = milestone
        status = request.POST['status']
        if (task.status != status):
            task.status = status
            actions.append("status -> %s" % task.get_status_display())
        if not request.POST['assignee']:
            assignee = None
            assigneename = "None"
        else:
            assignee = User.objects.get(username=request.POST['assignee'])
            assigneename = assignee.username
        if (assignee != task.assignee):
            actions.append("assignee -> %s" % assigneename)
            task.assignee = assignee
        if actions:
            msg = "Updated %s/%s task " % (task.project.name, task.series.name)
            msg += ", ".join(actions)
            task.save()
            newcomment = Comment(story=task.story,
                                 action=msg,
                                 author=request.user,
                                 comment_type="tasks",
                                 content=request.POST.get('comment', ''))
            newcomment.save()
    except KeyError:
        pass
    return HttpResponseRedirect('/story/%s' % task.story.id)
예제 #7
0
def add_story(request):
    try:
        newstory = Story(
            title=request.POST['title'],
            description=request.POST['description'],
            creator=request.user,
            is_bug=bool(request.POST['story_type']),
            priority=0,
        )
        newstory.save()
        proposed_projects = request.POST['projects'].split()
        if proposed_projects:
            master_undefined_milestone = Milestone.objects.get(
                branch__status='M', undefined=True)
            tasks = []
            for project in proposed_projects:
                tasks.append(Task(
                    story=newstory,
                    project=Project.objects.get(name=project),
                    milestone=master_undefined_milestone,
                ))
            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:
        pass
    return HttpResponseRedirect('/story/%s' % newstory.id)
예제 #8
0
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.description = request.POST['description']
        proposed_tags = set(request.POST['tags'].split())
        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)