Beispiel #1
0
def _state_engine_process_create_team(request, challenge, engine, state, template_data):
    response = None
    beneficiary = EntityController.GetWrappedEntityByTypeAndId(
        challenge.recipient_entity_type,
        challenge.recipient_entity_id,
        EntityBase.EntityWrapperByEntityType(challenge.recipient_entity_type))
    template_data['beneficiary'] = beneficiary
    form = CreateTempClubForm()
    if request.POST:
        form = CreateTempClubForm(request.POST)
        if form.is_valid():
            temp_club = _create_temp_club(form, request.current_role.state)
            challenge.recipient_entity_id = temp_club.id
            challenge.recipient_entity_type = EntityController.ENTITY_TEMP_CLUB
            challenge.save()
            state = _StateEngineStates.SHARE
        elif request.is_ajax():
            response = HttpResponse("%s|%s" % (
                request.path, '<br/>'.join(['<br/>'.join([_e for _e in e]) for e in form.errors.values()])))
    if state == _StateEngineStates.CREATE_TEAM:
        template_data['form'] = form
        response = render(
            request,
            'spudderspuds/challenges/pages_ajax/challenge_accept_beneficiary_create_club.html',
            template_data)
    return response, state
Beispiel #2
0
def _state_engine_process_create_team(request, challenge, engine, state,
                                      template_data):
    response = None
    beneficiary = EntityController.GetWrappedEntityByTypeAndId(
        challenge.recipient_entity_type, challenge.recipient_entity_id,
        EntityBase.EntityWrapperByEntityType(challenge.recipient_entity_type))
    template_data['beneficiary'] = beneficiary
    form = CreateTempClubForm()
    if request.POST:
        form = CreateTempClubForm(request.POST)
        if form.is_valid():
            temp_club = _create_temp_club(form, request.current_role.state)
            challenge.recipient_entity_id = temp_club.id
            challenge.recipient_entity_type = EntityController.ENTITY_TEMP_CLUB
            challenge.save()
            state = _StateEngineStates.SHARE
        elif request.is_ajax():
            response = HttpResponse("%s|%s" % (request.path, '<br/>'.join(
                ['<br/>'.join([_e for _e in e])
                 for e in form.errors.values()])))
    if state == _StateEngineStates.CREATE_TEAM:
        template_data['form'] = form
        response = render(
            request,
            'spudderspuds/challenges/pages_ajax/challenge_accept_beneficiary_create_club.html',
            template_data)
    return response, state
Beispiel #3
0
def challenge_challenge_accept_beneficiary_create_club(request, state):
    form = CreateTempClubForm()
    if request.method == 'POST':
        form = CreateTempClubForm(request.POST)
        if form.is_valid():
            temp_club = _create_temp_club(form, state)
            return redirect('/challenges/challenge_challenge/beneficiary/%s/clubs/t/%s' % (state, temp_club.id))
    template_data = {
        'form': form,
        'state': STATES[state]}
    return render(
        request,
        'spudderspuds/challenges/pages/challenge_challenge_accept_beneficiary_create_club.html',
        template_data)
def challenge_challenge_accept_beneficiary_create_club(request, state):
    form = CreateTempClubForm()
    if request.method == 'POST':
        form = CreateTempClubForm(request.POST)
        if form.is_valid():
            temp_club = _create_temp_club(form, state)
            return redirect(
                '/challenges/challenge_challenge/beneficiary/%s/clubs/t/%s' %
                (state, temp_club.id))
    template_data = {'form': form, 'state': STATES[state]}
    return render(
        request,
        'spudderspuds/challenges/pages/challenge_challenge_accept_beneficiary_create_club.html',
        template_data)
Beispiel #5
0
def create_challenge_choose_club_create_club(request, template_id, state):
    form = CreateTempClubForm()
    if request.method == 'POST':
        form = CreateTempClubForm(request.POST)
        if form.is_valid():
            temp_club = _create_temp_club(form, state)
            return redirect('/challenges/create/%s/%s/t/%s' % (template_id, state, temp_club.id))
    template_data = {
        'form': form,
        'state': STATES[state],
        'template': get_object_or_404(ChallengeTemplate, id=template_id)}
    return render(
        request,
        'spudderspuds/challenges/pages/create_challenge_choose_club_create_club.html',
        template_data)
def create_challenge_choose_club_create_club(request, template_id, state):
    form = CreateTempClubForm()
    if request.method == 'POST':
        form = CreateTempClubForm(request.POST)
        if form.is_valid():
            temp_club = _create_temp_club(form, state)
            return redirect('/challenges/create/%s/%s/t/%s' %
                            (template_id, state, temp_club.id))
    template_data = {
        'form': form,
        'state': STATES[state],
        'template': get_object_or_404(ChallengeTemplate, id=template_id)
    }
    return render(
        request,
        'spudderspuds/challenges/pages/create_challenge_choose_club_create_club.html',
        template_data)
Beispiel #7
0
def challenge_accept_beneficiary_create_club(request, participation_id, state):
    participation = get_object_or_404(ChallengeParticipation, id=participation_id)
    challenge = participation.challenge
    template = challenge.template
    form = CreateTempClubForm()
    if request.method == 'POST':
        form = CreateTempClubForm(request.POST)
        if form.is_valid():
            temp_club = _create_temp_club(form, state)
            return redirect('/challenges/%s/beneficiary/%s/t/%s' % (participation_id, state, temp_club.id))
    template_data = {
        'form': form,
        'state': STATES[state],
        'template': template}
    return render(
        request,
        'spudderspuds/challenges/pages/challenge_accept_beneficiary_create_club.html',
        template_data)
def challenge_accept_beneficiary_create_club(request, participation_id, state):
    participation = get_object_or_404(ChallengeParticipation,
                                      id=participation_id)
    challenge = participation.challenge
    template = challenge.template
    form = CreateTempClubForm()
    if request.method == 'POST':
        form = CreateTempClubForm(request.POST)
        if form.is_valid():
            temp_club = _create_temp_club(form, state)
            return redirect('/challenges/%s/beneficiary/%s/t/%s' %
                            (participation_id, state, temp_club.id))
    template_data = {
        'form': form,
        'state': STATES[state],
        'template': template
    }
    return render(
        request,
        'spudderspuds/challenges/pages/challenge_accept_beneficiary_create_club.html',
        template_data)