Пример #1
0
def setup_featured(request, authentication_key):
    account = request.account
    event = Event.events.get(authentication_key__exact=authentication_key)

    featured_event = FeaturedEvent(
        event=event,
        owner=account,
        start_time=datetime.date.today(),
        end_time=event.last_occurrence.end_time
    )

    payments_module = request.POST.get("payments_module", "paypal")

    form = SetupFeaturedForm(account, instance=featured_event, initial = {
        "bonus": (0, CAD)
    })

    venue_account_featured_stats = FeaturedEvent.objects.filter(event__venue_id=event.venue.id)    

    if request.method == 'POST':
        form = SetupFeaturedForm(account, instance=featured_event, data=request.POST)

        if form.is_valid():
            featured_event = form.save()

            return process_setup_featured(account, featured_event, request)

    return render_to_response('events/setup_featured_event.html', {
            'form': form,
            'featured_events_stats': venue_account_featured_stats,
            'account': account,
            'payments_module': payments_module
        }, context_instance=RequestContext(request))
Пример #2
0
def admin_setup_featured(request, event_id):
    account = request.account
    event = Event.events.get(id=event_id)    

    featured_event = FeaturedEvent(
        event=event,
        owner=account,
        start_time=datetime.date.today(),
        end_time=datetime.date.today() + datetime.timedelta(days=15),
        active=True,
        owned_by_admin=True
    )

    form = SetupFeaturedForm(
        instance=featured_event
    )

    if request.method == 'POST':
        form = SetupFeaturedForm(instance=featured_event, data=request.POST)

        if form.is_valid():
            featured_event = form.save()

            return HttpResponseRedirect(reverse('admin_featured'))

    return render_to_response('cf-admin/admin-setup-featured-event.html', {
            'form': form,
            'event': event
        }, context_instance=RequestContext(request))
Пример #3
0
def setup_featured(request, authentication_key):
    account = request.account
    event = Event.events.get(authentication_key__exact=authentication_key)    

    featured_event = FeaturedEvent(
        event=event,
        owner=account,
        start_time=datetime.date.today(),
        end_time=datetime.date.today() + datetime.timedelta(days=15)
    )

    venue_account_featured_stats = FeaturedEvent.objects.filter(event__venue_id=event.venue.id)

    form = SetupFeaturedForm(
        instance=featured_event
    )

    if request.method == 'POST':
        form = SetupFeaturedForm(instance=featured_event, data=request.POST)

        if form.is_valid():
            featured_event = form.save()

            cost = (featured_event.end_time - featured_event.start_time).days * Money(2, CAD)
            total_price = cost

            for tax in account.taxes():
                total_price = total_price + (cost * tax.tax)

            order = FeaturedEventOrder(
                cost=cost,
                total_price=total_price,
                featured_event=featured_event,
                account=account
            )

            order.save()

            for tax in account.taxes():
                account_tax_cost = AccountTaxCost(account_tax=tax, cost=cost*tax.tax, tax_name=tax.name)
                account_tax_cost.save()
                order.taxes.add(account_tax_cost)
            

            return HttpResponseRedirect(reverse('setup_featured_payment', args=(str(order.id),)))

    return render_to_response('events/setup_featured_event.html', {
            'form': form,
            'featured_events_stats': venue_account_featured_stats
        }, context_instance=RequestContext(request))
Пример #4
0
def admin_edit_featured(request, featured_event_id):
    featured_event = FeaturedEvent.objects.get(id=featured_event_id)
    form = SetupFeaturedForm(
        instance=featured_event
    )
    
    if request.method == 'POST':
        form = SetupFeaturedForm(instance=featured_event, data=request.POST)

        if form.is_valid():
            featured_event = form.save()

            return HttpResponseRedirect(reverse('admin_featured'))

    return render_to_response('cf-admin/admin-setup-featured-event.html', {
            'form': form,
            'event': featured_event.event
        }, context_instance=RequestContext(request))
Пример #5
0
def setup_featured(request, authentication_key):
    account = request.account
    event = Event.events.get(authentication_key__exact=authentication_key)

    featured_event = FeaturedEvent(event=event,
                                   owner=account,
                                   start_time=datetime.date.today(),
                                   end_time=event.last_occurrence.end_time)

    payments_module = request.POST.get("payments_module", "paypal")

    form = SetupFeaturedForm(account,
                             instance=featured_event,
                             initial={"bonus": (0, CAD)})

    venue_account_featured_stats = FeaturedEvent.objects.filter(
        event__venue_id=event.venue.id)

    if request.method == 'POST':
        form = SetupFeaturedForm(account,
                                 instance=featured_event,
                                 data=request.POST)

        if form.is_valid():
            featured_event = form.save()

            return process_setup_featured(account, featured_event, request)

    return render_to_response('events/setup_featured_event.html', {
        'form': form,
        'featured_events_stats': venue_account_featured_stats,
        'account': account,
        'payments_module': payments_module
    },
                              context_instance=RequestContext(request))