def board_story_move(request, id, to_column): if request.is_ajax(): try: story = models.Story.objects.get(id=id) except models.Story.DoesNotExist: raise Http404 previous_story_state = story.state story.state = to_column story.save() # Move all the tasks too if story.state == 'DONE' or story.state == 'FIRE': for task in story.task_set.all(): if task.state != 'TO_CLOSED': story_action = models.StoryAction() story_action.action = 'TO_CLOSED' story_action.task = task story_action.actor = request.user story_action.save() task.state = 'TO_CLOSED' task.save() elif previous_story_state == 'DONE' or previous_story_state == 'FIRE': for task in story.task_set.all(): if task.state == 'TO_CLOSED': story_action = models.StoryAction() if to_column == 'WAITING': story_action.action = 'TO_WAITING' else: story_action.action = 'TO_WORKING' story_action.task = task story_action.actor = request.user story_action.save() task.state = story_action.action task.save() action = models.BoardAction() action.story = story action.board_from = previous_story_state # Save previous state action.board_to = story.state # Save new state action.actor = request.user action.save() return HttpResponse('OK') else: raise Http404
def my_stuff_story_task_change_state(request, id, state): try: task = models.Task.objects.get(id=id) except models.Task.DoesNotExist: raise Http404 state = 'TO_%s' % state.upper() story_action = models.StoryAction() story_action.action = state story_action.task = task story_action.actor = request.user story_action.save() task.state = state task.save() return HttpResponseRedirect(request.GET.get('return-to', reverse('web.index')))
def board_story_next(request, id): try: story = models.Story.objects.get(id=id) except models.Story.DoesNotExist: raise Http404 sprint = story.sprint board = sprint.board_set.all()[0] if story.state != 'DONE' and story.state != 'FIRE': current_column = board.boardcolumn_set.get(tag=story.state) next_column_tag = board.boardcolumn_set.get( order=current_column.order + 1).tag if story.is_burning and next_column_tag == 'DONE': story.state = 'FIRE' else: story.state = next_column_tag story.save() # Move all the tasks too if story.state == 'DONE' or story.state == 'FIRE': for task in story.task_set.all(): if task.state != 'TO_CLOSED': story_action = models.StoryAction() story_action.action = 'TO_CLOSED' story_action.task = task story_action.actor = request.user story_action.save() task.state = 'TO_CLOSED' task.save() action = models.BoardAction() action.story = story action.board_from = current_column.tag # Save previous state action.board_to = story.state # Save new state action.actor = request.user action.save() return HttpResponseRedirect( request.GET.get('return-to', reverse('web.board')))