Exemple #1
0
def registration_pricing_and_button(context, event, user):
    pricing_context = []
    limit = event.registration_configuration.limit
    spots_taken = 0
    spots_left = limit - spots_taken
    registration = event.registration_configuration
    
    pricing = RegConfPricing.objects.filter(
        reg_conf=event.registration_configuration,
        status=True,
    )
    
    reg_started = registration_has_started(event, pricing=pricing)
    reg_ended = registration_has_ended(event, pricing=pricing)
    earliest_time = registration_earliest_time(event, pricing=pricing)
    
    # setting for allowing anonymous members to choose prices
    anonpricing = get_setting('module', 'events', 'anonymousmemberpricing')
    
    # dictionary with helpers, not a queryset
    # see get_pricing
    q_pricing = get_pricing(user, event, pricing=pricing)
    
    # spots taken
    if limit > 0:
        spots_taken = get_event_spots_taken(event)
    
    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,
        'registration': registration,
        'reg_started': reg_started,
        'reg_ended': reg_ended,
        'earliest_time': earliest_time,
        'pricing': q_pricing,
        'user': user,
        'is_registrant': is_registrant,
        'anonpricing': anonpricing,
    })

    return context
Exemple #2
0
def reg_status(event, user):
    """
    Determines if a registration is open, closed or full.
    """
    
    # check available spots left
    limit = event.registration_configuration.limit
    spots_taken = 0
    if limit > 0: # 0 is no limit
        spots_taken = get_event_spots_taken(event)
        if spots_taken >= limit:
            return 'FULL'
    
    # check if pricings are still open
    if get_setting('module', 'events', 'anonymousmemberpricing'):
        pricings = get_active_pricings(event)
    else:
        pricings = get_available_pricings(event, user)
    
    if not pricings:
        return 'CLOSED'
        
    return 'OPEN'