Exemplo n.º 1
0
def reorder_story(request, group_slug, story_id):
    story = get_object_or_404(Story, id=story_id)
    project = get_object_or_404(Project, slug=group_slug)
    write_access_or_403(project, request.user)
    if request.method == 'POST':
        old_story = story.__dict__.copy()

        rank = 0
        target_iteration = request.POST.get("iteration", "")

        try:
            iteration = get_object_or_404(Iteration, id=target_iteration)
        except:
            iteration = story.iteration

        if request.POST.get("action", "") == "reorder":
            old_story = story.__dict__.copy()
            reorderStory(story, request.POST.get("before"),
                         request.POST.get("after"), iteration)
            diffs = utils.model_differences(old_story,
                                            story.__dict__,
                                            dicts=True)
            signals.story_updated.send(sender=request,
                                       story=story,
                                       user=request.user,
                                       diffs=diffs)
            # story.activity_signal.send(sender=story, user=request.user, story=story, action="reordered", project=project)

        if request.POST.get("epic", "-1") != "-1":
            epic_id = request.POST.get("epic")
            epic = Epic.objects.get(id=epic_id)
            if epic and epic.project == project:
                story.epic = epic
        elif request.POST.get("epic", "") == "-1":
            # Explicitly moving it out of any epic
            story.epic = None

        story.iteration = iteration
        story.save()
        diffs = utils.model_differences(old_story, story.__dict__, dicts=True)

        return HttpResponse("OK")
    return HttpResponse("Fail")
Exemplo n.º 2
0
def story(request, group_slug, story_id):
    story = get_object_or_404( Story, id=story_id )
    project = get_object_or_404( Project, slug=group_slug )
    return_type = request.GET.get("return_type","mini")

    if request.method == 'POST': # If the form has been submitted...
        old_story = story.__dict__.copy()
        write_access_or_403(project,request.user)
        form = StoryForm( project, request.POST, project, instance=story) # A form bound to the POST data

        if form.is_valid(): # All validation rules pass
            story = form.save()
            diffs = utils.model_differences(old_story, story.__dict__, dicts=True)
            activities = 0
            if diffs.has_key("points"):
                story.activity_signal.send(sender=story, user=request.user, story=story, pointschange=True, action="changed point value", project=project, old=diffs['points'][0], new=diffs['points'][1])
                activities = activities + 1
            # to do other stories based on specific changes, simply add more if clauses like the one above

            if len(diffs) > activities:
                # this means that we have not accounted for all the changes above, so add a generic story edited activity
                story.activity_signal.send(sender=story, user=request.user, story=story, action="edited", project=project)

            signals.story_updated.send( sender=request, story=story, user=request.user )
            onDemandCalculateVelocity( project )

        if( request.POST['return_type'] == 'mini'):
            return render_to_response("stories/single_mini_story.html", {
                "story": story,
                "return_type": return_type,
              }, context_instance=RequestContext(request))
        if( request.POST['return_type'] == 'block'):
            return render_to_response("stories/single_block_story.html", {
                "story": story,
                "return_type": return_type,
                "project": story.project
              }, context_instance=RequestContext(request))
        if( request.POST['return_type'] == 'queue'):
            return render_to_response("stories/single_queue_story.html", {
                "story": story,
                "return_type": return_type,
              }, context_instance=RequestContext(request))

    else:
        read_access_or_403(project,request.user)
        form = StoryForm(project, instance=story )

    tags = project.tags.all().order_by("name")
    return   render_to_response("stories/story.html", {
        "story": story,
        "form": form,
        "project": project,
        "tags": tags,
        "return_type": return_type
      }, context_instance=RequestContext(request))
Exemplo n.º 3
0
def story(request, group_slug, story_id):
    story = get_object_or_404( Story, id=story_id )
    project = get_object_or_404( Project, slug=group_slug )
    return_type = request.GET.get("return_type","mini")

    if request.method == 'POST': # If the form has been submitted...
        old_story = story.__dict__.copy()
        write_access_or_403(project,request.user)
        form = StoryForm( project, request.POST, project, instance=story) # A form bound to the POST data

        if form.is_valid(): # All validation rules pass
            story = form.save()
            diffs = utils.model_differences(old_story, story.__dict__, dicts=True)
            activities = 0
            if diffs.has_key("points"):
                story.activity_signal.send(sender=story, user=request.user, story=story, pointschange=True, action="changed point value", project=project, old=diffs['points'][0], new=diffs['points'][1])
                activities = activities + 1
            # to do other stories based on specific changes, simply add more if clauses like the one above

            if len(diffs) > activities:
                # this means that we have not accounted for all the changes above, so add a generic story edited activity
                story.activity_signal.send(sender=story, user=request.user, story=story, action="edited", project=project)

            signals.story_updated.send( sender=request, story=story, user=request.user )
            onDemandCalculateVelocity( project )

        if( request.POST['return_type'] == 'mini'):
            return render_to_response("stories/single_mini_story.html", {
                "story": story,
                "return_type": return_type,
              }, context_instance=RequestContext(request))
        if( request.POST['return_type'] == 'block'):
            return render_to_response("stories/single_block_story.html", {
                "story": story,
                "return_type": return_type,
                "project": story.project
              }, context_instance=RequestContext(request))
        if( request.POST['return_type'] == 'queue'):
            return render_to_response("stories/single_queue_story.html", {
                "story": story,
                "return_type": return_type,
              }, context_instance=RequestContext(request))

    else:
        read_access_or_403(project,request.user)
        form = StoryForm(project, instance=story )

    tags = project.tags.all().order_by("name")
    return   render_to_response("stories/story.html", {
        "story": story,
        "form": form,
        "project": project,
        "tags": tags,
        "return_type": return_type
      }, context_instance=RequestContext(request))
Exemplo n.º 4
0
def reorder_story(request, group_slug, story_id):
    story = get_object_or_404(Story, id=story_id)
    project = get_object_or_404(Project, slug=group_slug)
    write_access_or_403(project, request.user)
    if request.method == 'POST':
        old_story = story.__dict__.copy()

        rank = 0
        target_iteration = request.POST.get("iteration", "")

        try:
            iteration = get_object_or_404(Iteration, id=target_iteration)
        except:
            iteration = story.iteration

        if request.POST.get("action", "") == "reorder":
            old_story = story.__dict__.copy()
            reorderStory(story, request.POST.get(
                "before"), request.POST.get("after"), iteration)
            diffs = utils.model_differences(
                old_story, story.__dict__, dicts=True)
            signals.story_updated.send(
                sender=request, story=story, user=request.user, diffs=diffs)
            # story.activity_signal.send(sender=story, user=request.user, story=story, action="reordered", project=project)

        if request.POST.get("epic", "-1") != "-1":
            epic_id = request.POST.get("epic")
            epic = Epic.objects.get(id=epic_id)
            if epic and epic.project == project:
                story.epic = epic
        elif request.POST.get("epic", "") == "-1":
            # Explicitly moving it out of any epic
            story.epic = None

        story.iteration = iteration
        story.save()
        diffs = utils.model_differences(old_story, story.__dict__, dicts=True)

        return HttpResponse("OK")
    return HttpResponse("Fail")
Exemplo n.º 5
0
def story_edit(request, group_slug, story_id):
    story = get_object_or_404( Story, id=story_id )
    project = get_object_or_404( Project, slug=group_slug )
    return_type = request.GET.get("return_type","mini")

    if request.method == 'POST': # If the form has been submitted...
        old_story = story.__dict__.copy()
        write_access_or_403(project,request.user)
        form = StoryForm( project, request.POST, project, instance=story) # A form bound to the POST data

        if form.is_valid(): # All validation rules pass
            story = form.save(commit=False)
            

            if request.POST.get("category_name","") != "":
                try:
                    category_name = request.POST.get("category_name")
                    category_name = category_name.replace(",","").strip()
                    category_name = category_name[:50]
                    if not category_name in project.getCategoryList():
                        project.categories = "%s, %s" % (project.categories, category_name)
                        if len(project.categories) <= 1024:
                            project.save()
                        else:
                            request.user.message_set.create(message="Too many categories")
                    story.category = category_name
                except:
                    pass # no category to use
                
            story.save()
            
            diffs = utils.model_differences(old_story, story.__dict__, dicts=True)
            activities = 0

            signals.story_updated.send( sender=request, story=story, diffs=diffs, user=request.user )
            onDemandCalculateVelocity( project )

        organization = _organizationOrNone( project )
        if( request.POST['return_type'] == 'mini'):
            return render_to_response("stories/single_mini_story.html", {
                "story": story,
                "return_type": return_type,
              }, context_instance=RequestContext(request))
        if( request.POST['return_type'] == 'scrumboard'):
            return render_to_response("stories/single_scrum_board_story.html", {
                "story": story,
                "return_type": return_type,
                "project": story.project,
                "organization": organization
              }, context_instance=RequestContext(request))
        if( request.POST['return_type'] == 'block'):
            return render_to_response("stories/single_block_story.html", {
                "story": story,
                "return_type": return_type,
                "project": story.project,
                "organization": organization
              }, context_instance=RequestContext(request))
        if( request.POST['return_type'] == 'queue'):
            return render_to_response("stories/single_queue_story.html", {
                "story": story,
                'project': story.project,
                "organization": organization,
                "return_type": return_type,
              }, context_instance=RequestContext(request))

    else:
        read_access_or_403(project,request.user)
        form = StoryForm(project, instance=story )

    tags = project.unique_tags()

    return   render_to_response("stories/story.html", {
        "story": story,
        "form": form,
        "project": project,
        "return_type": return_type
      }, context_instance=RequestContext(request))
Exemplo n.º 6
0
def story(request, group_slug, story_id):
    story = get_object_or_404( Story, id=story_id )
    project = get_object_or_404( Project, slug=group_slug )
    return_type = request.GET.get("return_type","mini")

    if request.method == 'POST': # If the form has been submitted...
        old_story = story.__dict__.copy()
        write_access_or_403(project,request.user)
        form = StoryForm( project, request.POST, project, instance=story) # A form bound to the POST data

        if form.is_valid(): # All validation rules pass
            story = form.save(commit=False)
            
            if request.POST.get("category_name") != "":
                category_name = request.POST.get("category_name")
                category_name = category_name.replace(",","").strip()
                category_name = category_name[:25]
                if not category_name in project.getCategoryList():
                    project.categories = "%s, %s" % (project.categories, category_name)
                    if len(project.categories) <= 512:
                        project.save()
                    else:
                        request.user.message_set.create(message="Too many categories")
                        
                    
                story.category = category_name
                
            story.save()
            
            diffs = utils.model_differences(old_story, story.__dict__, dicts=True)
            activities = 0
            if diffs.has_key("points"):
                story.activity_signal.send(sender=story, user=request.user, story=story, pointschange=True, action="changed point value", project=project, old=diffs['points'][0], new=diffs['points'][1])
                activities = activities + 1
            # to do other stories based on specific changes, simply add more if clauses like the one above

            if len(diffs) > activities:
                # this means that we have not accounted for all the changes above, so add a generic story edited activity
                story.activity_signal.send(sender=story, user=request.user, story=story, action="edited", project=project)

            signals.story_updated.send( sender=request, story=story, user=request.user )
            onDemandCalculateVelocity( project )

        organization = _organizationOrNone( project )
        if( request.POST['return_type'] == 'mini'):
            return render_to_response("stories/single_mini_story.html", {
                "story": story,
                "return_type": return_type,
              }, context_instance=RequestContext(request))
        if( request.POST['return_type'] == 'scrumboard'):
            return render_to_response("stories/single_scrum_board_story.html", {
                "story": story,
                "return_type": return_type,
                "project": story.project,
                "organization": organization
              }, context_instance=RequestContext(request))
        if( request.POST['return_type'] == 'block'):
            return render_to_response("stories/single_block_story.html", {
                "story": story,
                "return_type": return_type,
                "project": story.project,
                "organization": organization
              }, context_instance=RequestContext(request))
        if( request.POST['return_type'] == 'queue'):
            return render_to_response("stories/single_queue_story.html", {
                "story": story,
                "return_type": return_type,
              }, context_instance=RequestContext(request))

    else:
        read_access_or_403(project,request.user)
        form = StoryForm(project, instance=story )

    tags = project.unique_tags()

    return   render_to_response("stories/story.html", {
        "story": story,
        "form": form,
        "project": project,
        "return_type": return_type
      }, context_instance=RequestContext(request))
Exemplo n.º 7
0
def story_edit(request, group_slug, story_id):
    story = get_object_or_404(Story, id=story_id)
    project = get_object_or_404(Project, slug=group_slug)
    return_type = request.GET.get("return_type", "mini")

    if request.method == 'POST':  # If the form has been submitted...
        old_story = story.__dict__.copy()
        write_access_or_403(project, request.user)
        form = StoryForm(project, request.POST, project,
                         instance=story)  # A form bound to the POST data

        if form.is_valid():  # All validation rules pass
            story = form.save(commit=False)

            if request.POST.get("category_name", "") != "":
                try:
                    category_name = request.POST.get("category_name")
                    category_name = category_name.replace(",", "").strip()
                    category_name = category_name[:50]
                    if not category_name in project.getCategoryList():
                        project.categories = "%s, %s" % (project.categories,
                                                         category_name)
                        if len(project.categories) <= 1024:
                            project.save()
                        else:
                            request.user.message_set.create(
                                message="Too many categories")
                    story.category = category_name
                except:
                    pass  # no category to use

            story.save()

            diffs = utils.model_differences(old_story,
                                            story.__dict__,
                                            dicts=True)
            activities = 0

            signals.story_updated.send(sender=request,
                                       story=story,
                                       diffs=diffs,
                                       user=request.user)
            onDemandCalculateVelocity(project)

        organization = _organizationOrNone(project)
        if (request.POST['return_type'] == 'mini'):
            return render_to_response("stories/single_mini_story.html", {
                "story": story,
                "return_type": return_type,
            },
                                      context_instance=RequestContext(request))
        if (request.POST['return_type'] == 'scrumboard'):
            return render_to_response("stories/single_scrum_board_story.html",
                                      {
                                          "story": story,
                                          "return_type": return_type,
                                          "project": story.project,
                                          "organization": organization
                                      },
                                      context_instance=RequestContext(request))
        if (request.POST['return_type'] == 'block'):
            return render_to_response("stories/single_block_story.html", {
                "story": story,
                "return_type": return_type,
                "project": story.project,
                "organization": organization
            },
                                      context_instance=RequestContext(request))
        if (request.POST['return_type'] == 'queue'):
            return render_to_response("stories/single_queue_story.html", {
                "story": story,
                'project': story.project,
                "organization": organization,
                "return_type": return_type,
            },
                                      context_instance=RequestContext(request))

    else:
        read_access_or_403(project, request.user)
        form = StoryForm(project, instance=story)

    tags = project.unique_tags()

    return render_to_response("stories/story.html", {
        "story": story,
        "form": form,
        "project": project,
        "return_type": return_type
    },
                              context_instance=RequestContext(request))