Ejemplo n.º 1
0
def _create_challenge(club_class,
                      club_id,
                      form,
                      request,
                      template,
                      parent=None,
                      image=None,
                      youtube_video_id=None):
    donation_accept = form.cleaned_data.get('donation_with_challenge')
    donation_reject = form.cleaned_data.get('donation_without_challenge')
    recipient_entity_type = EntityController.ENTITY_CLUB
    if club_class == TempClub:
        recipient_entity_type = EntityController.ENTITY_TEMP_CLUB
    challenge = Challenge(template=template,
                          name=template.name,
                          description=template.description,
                          creator_entity_id=request.current_role.entity.id,
                          creator_entity_type=request.current_role.entity_type,
                          recipient_entity_id=club_id,
                          recipient_entity_type=recipient_entity_type,
                          proposed_donation_amount=donation_accept,
                          proposed_donation_amount_decline=donation_reject)
    challenge.save()
    if parent or image or youtube_video_id:
        if parent:
            challenge.parent = parent
        if image:
            challenge.image = image
        if youtube_video_id:
            challenge.youtube_video_id = youtube_video_id
        challenge.save()
    return challenge
Ejemplo n.º 2
0
def _create_challenge(club_class, club_id, form, request, template, parent=None, image=None, youtube_video_id=None):
    donation_accept = form.cleaned_data.get('donation_with_challenge')
    donation_reject = form.cleaned_data.get('donation_without_challenge')
    recipient_entity_type = EntityController.ENTITY_CLUB
    if club_class == TempClub:
        recipient_entity_type = EntityController.ENTITY_TEMP_CLUB
    challenge = Challenge(
        template=template,
        name=template.name,
        description=template.description,
        creator_entity_id=request.current_role.entity.id,
        creator_entity_type=request.current_role.entity_type,
        recipient_entity_id=club_id,
        recipient_entity_type=recipient_entity_type,
        proposed_donation_amount=donation_accept,
        proposed_donation_amount_decline=donation_reject)
    challenge.save()
    if parent or image or youtube_video_id:
        if parent:
            challenge.parent = parent
        if image:
            challenge.image = image
        if youtube_video_id:
            challenge.youtube_video_id = youtube_video_id
        challenge.save()
    return challenge
Ejemplo n.º 3
0
def _state_engine_process_upload_thanks(request, challenge, engine, state,
                                        template_data):
    template = challenge.template
    beneficiary = EntityController.GetWrappedEntityByTypeAndId(
        challenge.recipient_entity_type, challenge.recipient_entity_id,
        EntityBase.EntityWrapperByEntityType(challenge.recipient_entity_type))
    participation = ChallengeParticipation.objects.get(
        challenge=challenge,
        participating_entity_id=request.current_role.entity.id,
        participating_entity_type=request.current_role.entity_type)
    if request.GET.get('video_id'):
        participation.youtube_video_id = request.GET['video_id']
        participation.state_engine_state = state
        participation.state_engine = engine
        participation.save()
        challenge = Challenge(
            template=template,
            name=template.name,
            parent=challenge,
            description=challenge.description,
            creator_entity_id=request.current_role.entity.id,
            creator_entity_type=request.current_role.entity_type,
            recipient_entity_id=challenge.recipient_entity_id,
            recipient_entity_type=challenge.recipient_entity_type,
            proposed_donation_amount=challenge.proposed_donation_amount,
            proposed_donation_amount_decline=challenge.
            proposed_donation_amount_decline,
            creating_participant=participation,
            youtube_video_id=participation.youtube_video_id)
        challenge.save()
        template_data['challenge'] = challenge
        template_data['just_uploaded'] = True
        participation.state_engine_state = _StateEngineStates.PLEDGE
        participation.state_engine = engine
        participation.save()
    template_data['template'] = template
    template_data['beneficiary'] = beneficiary
    template_data['participation'] = participation
    response = render(
        request,
        'spudderspuds/challenges/pages_ajax/challenge_accept_upload_thanks.html',
        template_data)
    return response, state
Ejemplo n.º 4
0
def _state_engine_process_upload_thanks(request, challenge, engine, state, template_data):
    template = challenge.template
    beneficiary = EntityController.GetWrappedEntityByTypeAndId(
        challenge.recipient_entity_type,
        challenge.recipient_entity_id,
        EntityBase.EntityWrapperByEntityType(challenge.recipient_entity_type))
    participation = ChallengeParticipation.objects.get(
        challenge=challenge,
        participating_entity_id=request.current_role.entity.id,
        participating_entity_type=request.current_role.entity_type)
    if request.GET.get('video_id'):
        participation.youtube_video_id = request.GET['video_id']
        participation.state_engine_state = state
        participation.state_engine = engine
        participation.save()
        challenge = Challenge(
            template=template,
            name=template.name,
            parent=challenge,
            description=challenge.description,
            creator_entity_id=request.current_role.entity.id,
            creator_entity_type=request.current_role.entity_type,
            recipient_entity_id=challenge.recipient_entity_id,
            recipient_entity_type=challenge.recipient_entity_type,
            proposed_donation_amount=challenge.proposed_donation_amount,
            proposed_donation_amount_decline=challenge.proposed_donation_amount_decline,
            creating_participant=participation,
            youtube_video_id=participation.youtube_video_id)
        challenge.save()
        template_data['challenge'] = challenge
        template_data['just_uploaded'] = True
        participation.state_engine_state = _StateEngineStates.PLEDGE
        participation.state_engine = engine
        participation.save()
    template_data['template'] = template
    template_data['beneficiary'] = beneficiary
    template_data['participation'] = participation
    response = render(
        request,
        'spudderspuds/challenges/pages_ajax/challenge_accept_upload_thanks.html',
        template_data)
    return response, state