Ejemplo n.º 1
0
def spreedly_return(request, user_id, plan_pk=None, extra_context=None, **kwargs):
    try:
        user = User.objects.get(id=user_id)
    except User.DoesNotExist:
        raise Http404
    
    if plan_pk:
        plan = Plan.objects.get(pk=plan_pk)
        
        if plan.plan_type == 'gift':
            Gift.objects.get(to_user=user_id).send_activation_email()
        
        if request.GET.has_key('trial'):
            start_free_trial(plan, user)
        
    subscription = get_subscription(user)
    
    our_context = {
        'subscription': subscription,
        'request': request,
        'login_url': settings.LOGIN_URL
    }
    if extra_context:
        our_context.update(extra_context)
    context = RequestContext(request)
    for key, value in our_context.items():
        context[key] = callable(value) and value() or value
    return render_to_response(
        spreedly_settings.SPREEDLY_RETURN_TEMPLATE,
        kwargs,
        context_instance=context
    )
Ejemplo n.º 2
0
def admin_gift(request):
    if request.method == 'POST':
        form = AdminGiftForm(request.POST)
        if form.is_valid():
            user = form.save(request)
            
            client = Client(settings.SPREEDLY_AUTH_TOKEN, settings.SPREEDLY_SITE_NAME)
            client.create_subscriber(user.pk, user.email)
            client.create_complimentary_subscription(user.pk, form.cleaned_data['time'], form.cleaned_data['units'], form.cleaned_data['feature_level'])
            user.gifts_received.latest('id').send_activation_email()
            get_subscription(user)
    else:
        form = AdminGiftForm()
    
    
    return render_to_response(
        spreedly_settings.SPREEDLY_ADMIN_GIFT_TEMPLATE,
        {'form': form},
        context_instance=RequestContext(request),
    )
Ejemplo n.º 3
0
def spreedly_return(request, user_id, plan_pk):
    try:
        user = User.objects.get(id=user_id)
    except User.DoesNotExist:
        raise Http404

    if request.GET.has_key('trial'):
        plan = Plan.objects.get(pk=plan_pk)
        start_free_trial(plan, user)

    subscription = get_subscription(user)

    return render_to_response(
        spreedly_settings.SPREEDLY_RETURN_TEMPLATE, {
            'subscription': subscription,
            'request': request,
            'login_url': settings.LOGIN_URL
        })
Ejemplo n.º 4
0
def spreedly_return(request, user_id, plan_pk):
    try:
        user = User.objects.get(id=user_id)
    except User.DoesNotExist:
        raise Http404
    
    if request.GET.has_key('trial'):
        plan = Plan.objects.get(pk=plan_pk)
        start_free_trial(plan, user)
    
    subscription = get_subscription(user)
    
    return render_to_response(
        spreedly_settings.SPREEDLY_RETURN_TEMPLATE, {
            'subscription': subscription,
            'request': request,
            'login_url': settings.LOGIN_URL
        }
    )