Esempio n. 1
0
def registration_pricing_and_button(context, event, user):
    limit = event.get_limit()
    spots_taken = 0
    spots_left = limit - spots_taken
    registration = event.registration_configuration

    pricing = registration.get_available_pricings(user, is_strict=False)
    pricing = pricing.order_by('display_order', '-price')
    
    reg_started = registration_has_started(event, pricing=pricing)
    reg_ended = registration_has_ended(event, pricing=pricing)
    earliest_time = registration_earliest_time(event, pricing=pricing)
    

    # spots taken
    if limit > 0:
        spots_taken, spots_available = event.get_spots_status()
    else:
        spots_taken, spots_available = (-1, -1)
    
    is_registrant = False
    # check if user has already registered
    if hasattr(user, 'registrant_set'):
        is_registrant = user.registrant_set.filter(
            registration__event=event).exists()
    
    context.update({
        'now': datetime.now(),
        'event': event,
        'limit': limit,
        'spots_taken': spots_taken,
        'spots_available': spots_available,
        'registration': registration,
        'reg_started': reg_started,
        'reg_ended': reg_ended,
        'earliest_time': earliest_time,
        'pricing': pricing,
        'user': user,
        'is_registrant': is_registrant,
    })

    return context
Esempio n. 2
0
def registration_pricing_and_button(context, event, user):
    limit = event.get_limit()
    spots_taken = 0
    spots_left = limit - spots_taken
    registration = event.registration_configuration

    pricing = registration.get_available_pricings(user, is_strict=False)
    pricing = pricing.order_by('position', '-price')
    
    reg_started = registration_has_started(event, pricing=pricing)
    reg_ended = registration_has_ended(event, pricing=pricing)
    earliest_time = registration_earliest_time(event, pricing=pricing)
    

    # spots taken
    if limit > 0:
        spots_taken, spots_available = event.get_spots_status()
    else:
        spots_taken, spots_available = (-1, -1)
    
    is_registrant = False
    # check if user has already registered
    if hasattr(user, 'registrant_set'):
        is_registrant = user.registrant_set.filter(
            registration__event=event).exists()
    
    context.update({
        'now': datetime.now(),
        'event': event,
        'limit': limit,
        'spots_taken': spots_taken,
        'spots_available': spots_available,
        'registration': registration,
        'reg_started': reg_started,
        'reg_ended': reg_ended,
        'earliest_time': earliest_time,
        'pricing': pricing,
        'user': user,
        'is_registrant': is_registrant,
    })

    return context