Beispiel #1
0
def planning_sprint_stories_owner(request, id, story_id):
    last_post = utils.get_session_data(request) or {}

    try:
        sprint = models.Sprint.objects.get(id=id)
    except models.Sprint.DoesNotExist:
        raise Http404

    try:
        story = models.Story.objects.get(id=story_id)
    except models.Sprint.DoesNotExist:
        raise Http404

    ctx = {
        'sidebar_selected':
        'planning',
        'sprint':
        sprint,
        'story':
        story,
        'availabilities':
        sprint.availability_set.all(),
        'task_owner_formset':
        utils.init_formset(
            request,
            reverse('web.planning_sprint_stories_owner_submit',
                    args=['%sPARAM_SEPARATOR%s' % (sprint.id, story.id)]),
            forms.TaskOwnerForm, last_post,
            story.task_set.all().values()),
    }

    return render_to_response(
        'pages/planning_sprint_stories_availability.html', ctx,
        RequestContext(request))
Beispiel #2
0
def backlog_tasks(request, story_id):
    last_post = utils.get_session_data(request) or {}

    story = None
    try:
        story = models.Story.objects.get(id=story_id)
    except models.Story.DoesNotExist:
        raise Http404

    open_stories = list(models.Story.objects.filter(state='BACKLOG'))
    open_stories.sort(story_comparator)

    ctx = {
        'story':
        story,
        'sidebar_selected':
        'backlog',
        'open_stories':
        open_stories,
        'task_formset':
        utils.init_formset(
            request, reverse('web.backlog_tasks_submit', args=[story_id]),
            forms.TaskForm, last_post,
            story.task_set.all().values())
    }

    return render_to_response('pages/tasks.html', ctx, RequestContext(request))
Beispiel #3
0
def backlog_tasks(request, story_id):
    last_post = utils.get_session_data(request) or {}

    story = None
    try:
        story = models.Story.objects.get(id=story_id)
    except models.Story.DoesNotExist:
        raise Http404

    open_stories = list(models.Story.objects.filter(state="BACKLOG"))
    open_stories.sort(story_comparator)

    ctx = {
        "story": story,
        "sidebar_selected": "backlog",
        "open_stories": open_stories,
        "task_formset": utils.init_formset(
            request,
            reverse("web.backlog_tasks_submit", args=[story_id]),
            forms.TaskForm,
            last_post,
            story.task_set.all().values(),
        ),
    }

    return render_to_response("pages/tasks.html", ctx, RequestContext(request))
Beispiel #4
0
def backlog(request, id=None, delete_selected=False):
    last_post = utils.get_session_data(request) or {}

    if delete_selected:
        ctx = {}
        if id:
            try:
                models.Story.objects.get(id=id).delete()
                return HttpResponseRedirect(reverse('web.backlog'))
            except models.Story.DoesNotExist:
                raise Http404
    else:
        open_stories = list(models.Story.objects.filter(state='BACKLOG'))
        open_stories.sort(story_comparator)
        ctx = {'sidebar_selected': 'backlog', 'open_stories': open_stories}

        if id:
            try:
                ctx['form'] = utils.init_form(
                    request, reverse('web.backlog_story_edit_submit',
                                     args=[id]), forms.StoryForm, last_post,
                    model_to_dict(models.Story.objects.get(id=id)))
            except models.Story.DoesNotExist:
                raise Http404
        else:
            ctx['form'] = utils.init_form(
                request, reverse('web.backlog_story_submit', args=[]),
                forms.StoryForm, last_post, {})

    return render_to_response('pages/backlog.html', ctx,
                              RequestContext(request))
Beispiel #5
0
def backlog(request, id = None, delete_selected=False, sprint=False):
	last_post = utils.get_session_data(request) or {}

	if delete_selected:
		ctx = {}
		if id:
			try:
				models.Story.objects.get(id=id).delete()
				return HttpResponseRedirect(reverse('web.backlog'))
			except models.Story.DoesNotExist:
				raise Http404
	else:
		open_stories = list(models.Story.objects.filter(state='BACKLOG'))
		open_stories.sort(story_comparator)
		ctx = {
			'sidebar_selected': 'backlog',
			'open_stories': open_stories
		}

		if id:
			try:
				if sprint:
					story = models.Story.objects.get(id=id)
					ctx['form'] = utils.init_form(request, reverse('web.backlog_story_storyparser_edit_submit_planning', args=[story.sprint.id]), forms.StoryParserForm, last_post, story)
				else:
					ctx['form'] = utils.init_form(request, reverse('web.backlog_story_storyparser_edit_submit', args=[id]), forms.StoryParserForm, last_post, models.Story.objects.get(id=id))
			except models.Story.DoesNotExist:
				raise Http404
		else:
			ctx['form'] = utils.init_form(request, reverse('web.backlog_story_submit', args=[]), forms.StoryParserForm, last_post, {})

	return render_to_response('pages/backlog.html', ctx, RequestContext(request))
Beispiel #6
0
def planning_sprint_stories_owner(request, id, story_id):
    last_post = utils.get_session_data(request) or {}

    try:
        sprint = models.Sprint.objects.get(id=id)
    except models.Sprint.DoesNotExist:
        raise Http404

    try:
        story = models.Story.objects.get(id=story_id)
    except models.Sprint.DoesNotExist:
        raise Http404

    ctx = {
        "sidebar_selected": "planning",
        "sprint": sprint,
        "story": story,
        "availabilities": sprint.availability_set.all(),
        "task_owner_formset": utils.init_formset(
            request,
            reverse("web.planning_sprint_stories_owner_submit", args=["%sPARAM_SEPARATOR%s" % (sprint.id, story.id)]),
            forms.TaskOwnerForm,
            last_post,
            story.task_set.all().values(),
        ),
    }

    return render_to_response("pages/planning_sprint_stories_availability.html", ctx, RequestContext(request))
Beispiel #7
0
def planning_new_sprint(request):
	last_post = utils.get_session_data(request) or {}

	ctx = {
		'sidebar_selected': 'planning',
	    'form': utils.init_form(request, reverse('web.planning_new_sprint_submit', args=[]), forms.SprintForm, last_post, {})
	}
	return render_to_response('pages/planning_new_sprint.html', ctx, RequestContext(request))
Beispiel #8
0
def planning_new_sprint(request):
	last_post = utils.get_session_data(request) or {}

	ctx = {
		'sidebar_selected': 'planning',
	    'form': utils.init_form(request, reverse('web.planning_new_sprint_submit', args=[]), forms.SprintForm, last_post, {})
	}
	return render_to_response('pages/planning_new_sprint.html', ctx, RequestContext(request))
Beispiel #9
0
def planning_new_sprint(request):
    last_post = utils.get_session_data(request) or {}

    ctx = {
        "sidebar_selected": "planning",
        "form": utils.init_form(
            request, reverse("web.planning_new_sprint_submit", args=[]), forms.SprintForm, last_post, {}
        ),
    }
    return render_to_response("pages/planning_new_sprint.html", ctx, RequestContext(request))
Beispiel #10
0
def my_stuff_story_fire(request, id=None):
    last_post = utils.get_session_data(request) or {}

    current_sprint_queryset = models.Sprint.objects.all().order_by(
        '-date_ends')
    if current_sprint_queryset.count():
        current_sprint = current_sprint_queryset[0]
        open_stories = list(
            models.Story.objects.filter(sprint=current_sprint).filter(
                task__owner=request.user).distinct())
        open_stories.sort(story_comparator)
    else:
        current_sprint = None
        open_stories = None

    initial = {
        'sprint_id': current_sprint.id if current_sprint else -1,
    }

    args = []

    if id:
        try:
            fire = models.Story.objects.get(id=id)
            initial.update({
                'id': fire.id,
                'title': fire.title,
                'story_description': fire.story_description,
                'tags': fire.tags,
                'score': fire.task_set.all()[0].score,
                'owner': fire.task_set.all()[0].owner,
            })
        except models.Story.DoesNotExist:
            raise Http404

    ctx = {
        'form':
        utils.init_form(request, reverse('web.my_stuff_fire_submit',
                                         args=args), forms.FireForm, last_post,
                        initial),
        'open_stories':
        open_stories,
        'current_sprint':
        current_sprint,
        'sidebar_selected':
        'mystuff',
    }

    return render_to_response('pages/my_stuff_fire.html', ctx,
                              RequestContext(request))
Beispiel #11
0
def planning_sprint_availability(request, id):
	last_post = utils.get_session_data(request) or {}

	try:
		sprint = models.Sprint.objects.get(id=id)
	except models.Sprint.DoesNotExist:
		raise Http404

	ctx = {
		'sidebar_selected': 'planning',
		'sprint': sprint,
	    'availability_formset': utils.init_formset(request, reverse('web.planning_sprint_availability_submit', args=[sprint.id]), forms.AvailabilityForm, last_post, sprint.availability_set.all().values())
	}

	return render_to_response('pages/planning_sprint_availability.html', ctx, RequestContext(request))
Beispiel #12
0
def planning_sprint_availability(request, id):
	last_post = utils.get_session_data(request) or {}

	try:
		sprint = models.Sprint.objects.get(id=id)
	except models.Sprint.DoesNotExist:
		raise Http404

	ctx = {
		'sidebar_selected': 'planning',
		'sprint': sprint,
	    'availability_formset': utils.init_formset(request, reverse('web.planning_sprint_availability_submit', args=[sprint.id]), forms.AvailabilityForm, last_post, sprint.availability_set.all().values())
	}

	return render_to_response('pages/planning_sprint_availability.html', ctx, RequestContext(request))
Beispiel #13
0
def game_event_handler(game_event, data=None):
    try:
        game_code_raw, client_id = get_session_data(session)
    except ValueError as err:
        emit('error', str(err))
        return

    game_code = GameCode(game_code_raw)
    if not game_store.contains_game(game_code):
        ErrorHandler.game_code_dne(GameEvent.UPDATE, game_code)
        return

    game_manager = game_store.get_game(game_code)

    #try:
    game, events = game_manager.handle_game_event(client_id, game_event, data)
    for event in events: event.emit()
    return game
Beispiel #14
0
def my_stuff_story_fire(request, id=None):
    last_post = utils.get_session_data(request) or {}

    current_sprint_queryset = models.Sprint.objects.all().order_by("-date_ends")
    if current_sprint_queryset.count():
        current_sprint = current_sprint_queryset[0]
        open_stories = list(
            models.Story.objects.filter(sprint=current_sprint).filter(task__owner=request.user).distinct()
        )
        open_stories.sort(story_comparator)
    else:
        current_sprint = None
        open_stories = None

    initial = {"sprint_id": current_sprint.id if current_sprint else -1}

    args = []

    if id:
        try:
            fire = models.Story.objects.get(id=id)
            initial.update(
                {
                    "id": fire.id,
                    "title": fire.title,
                    "story_description": fire.story_description,
                    "tags": fire.tags,
                    "score": fire.task_set.all()[0].score,
                    "owner": fire.task_set.all()[0].owner,
                }
            )
        except models.Story.DoesNotExist:
            raise Http404

    ctx = {
        "form": utils.init_form(
            request, reverse("web.my_stuff_fire_submit", args=args), forms.FireForm, last_post, initial
        ),
        "open_stories": open_stories,
        "current_sprint": current_sprint,
        "sidebar_selected": "mystuff",
    }

    return render_to_response("pages/my_stuff_fire.html", ctx, RequestContext(request))
Beispiel #15
0
def player_turn(message):
    try:
        game_code_raw, client_id = get_session_data(session)
    except ValueError as err:
        emit('error', str(err))
        return

    game_code = GameCode(game_code_raw)
    game_manager = game_store.get_game_bundle(game_code)
    game = game_manager.get_game()

    client_id = session[CLIENT_ID_KEY]
    client = game_manager.get_client(client_id)
    # TODO figure out which player's turn it is
    player = list(client.get_players().values())[0]

    if player.role == PlayerRole.SPYMASTER:
        # data = {"Clue" : clueword, "Num" : #guesses}
        clue = message['Clue']
        num_guesses = message['Num']

        # TODO: Verification on clue and num_guesses

        # Construct clue object and add to game state
        game.set_current_clue(clue, num_guesses)

    else:
        # data = {"Word" : word}
        guessed_word = message['Word']
        card = game.get_card_by_word(guessed_word)
        current_turn = game.current_turn

        is_correct, card_status = game.make_guess(guessed_word)
        if (is_correct):
            # Proceed with turn
            pass
        elif (card_status == CardStatus.BOMB):
            # End game, bomb uncovered
            pass
        else:
            # Flip card, end turn
            pass
Beispiel #16
0
def backlog_tasks(request, story_id):
	last_post = utils.get_session_data(request) or {}

	story = None
	try:
		story = models.Story.objects.get(id=story_id)
	except models.Story.DoesNotExist:
		raise Http404

	open_stories = list(models.Story.objects.filter(state='BACKLOG'))
	open_stories.sort(story_comparator)

	ctx = {
		'story': story,
		'sidebar_selected': 'backlog',
		'open_stories': open_stories,
	    'task_formset': utils.init_formset(request, reverse('web.backlog_tasks_submit', args=[story_id]), forms.TaskForm, last_post, story.task_set.all().values())
	}

	return render_to_response('pages/tasks.html', ctx, RequestContext(request))
Beispiel #17
0
def planning_sprint_availability(request, id):
    last_post = utils.get_session_data(request) or {}

    try:
        sprint = models.Sprint.objects.get(id=id)
    except models.Sprint.DoesNotExist:
        raise Http404

    ctx = {
        "sidebar_selected": "planning",
        "sprint": sprint,
        "availability_formset": utils.init_formset(
            request,
            reverse("web.planning_sprint_availability_submit", args=[sprint.id]),
            forms.AvailabilityForm,
            last_post,
            sprint.availability_set.all().values(),
        ),
    }

    return render_to_response("pages/planning_sprint_availability.html", ctx, RequestContext(request))
Beispiel #18
0
def my_stuff_story_fire(request, id=None):
	last_post = utils.get_session_data(request) or {}

	current_sprint_queryset = models.Sprint.objects.filter(date_begins__lt=datetime.now()).filter(date_ends__gt=datetime.now())
	if current_sprint_queryset.count():
		current_sprint = current_sprint_queryset[0]
		open_stories = list(models.Story.objects.filter(sprint=current_sprint).filter(task__owner=request.user).distinct())
		open_stories.sort(story_comparator)
	else:
		current_sprint = None
		open_stories = None

	initial = {
		'sprint_id': current_sprint.id if current_sprint else -1,
	}

	args = []

	if id:
		try:
			fire = models.Story.objects.get(id=id)
			initial.update({
				'id': fire.id,
			    'title': fire.title,
			    'story_description': fire.story_description,
			    'tags': fire.tags,
			    'score': fire.task_set.all()[0].score,
			    'owner': fire.task_set.all()[0].owner,
			})
		except models.Story.DoesNotExist:
			raise Http404

	ctx = {
		'form': utils.init_form(request, reverse('web.my_stuff_fire_submit', args=args), forms.FireForm, last_post, initial),
		'open_stories': open_stories,
		'current_sprint': current_sprint,
		'sidebar_selected': 'mystuff',
	}

	return render_to_response('pages/my_stuff_fire.html', ctx, RequestContext(request))
Beispiel #19
0
def planning_sprint_stories_owner(request, id, story_id):
	last_post = utils.get_session_data(request) or {}

	try:
		sprint = models.Sprint.objects.get(id=id)
	except models.Sprint.DoesNotExist:
		raise Http404

	try:
		story = models.Story.objects.get(id=story_id)
	except models.Sprint.DoesNotExist:
		raise Http404

	ctx = {
		'sidebar_selected': 'planning',
		'sprint': sprint,
	    'story': story,
	    'availabilities': sprint.availability_set.all(),
	    'task_owner_formset': utils.init_formset(request, reverse('web.planning_sprint_stories_owner_submit', args=['%sPARAM_SEPARATOR%s' % (sprint.id, story.id)]), forms.TaskOwnerForm, last_post, story.task_set.all().values()),
	}

	return render_to_response('pages/planning_sprint_stories_availability.html', ctx, RequestContext(request))