def pyramids(request, caller_context, container_user, group, active_page=1, active_position=1):
    '''
    get page of pyramid by taking a pyramid id and finding its page
    '''
    pyramidController = PyramidController()
    pyramid_ids = None
    if (group == "joined"):
        pyramid_ids = pyramidController.get_character_pyramid_ids(container_user.character, True)
    elif (group == "friends"):
        pyramid_ids = pyramidController.get_friend_pyramid_ids(container_user.character, True)
    elif (group == "invited"):
        pyramid_ids, invites = pyramidController.get_invited_pyramid_ids(container_user, True)
    elif (group == "open"):
        character = None
        if container_user:
            character = container_user.character
        pyramid_ids = pyramidController.find_open_pyramid_ids(character, 1000)
        if len(pyramid_ids) < 10: # if there are fewer than 10 open pyramids, create one 
            pyramid = pyramidController.create_new_pyramid(4, 3, 100) # 4 total levels, fill 3 levels, $100 price
            pyramid_ids.append(pyramid.key().id())
            logging.debug('created new pyramid: ' + pyramid.to_xml())
        else:
            logging.debug('found open pyramids')
        #controller.set_game_invite(pyramid, container_user.character)
    elif (group == 'condemned'):
        pyramid_ids = pyramidController.get_character_pyramid_ids(container_user.character, active=False, paid=False)
        
    if pyramid_ids:
        pyramid_display, paginator, pyramid_page = get_paged_pyramids(caller_context.config, pyramid_ids, container_user, 10, int(active_page), int(active_position))

    return render_to_response('pyramids.html', locals())
def get_client_actions(request, caller_context, container_user):
    actions = {}
    
    #make sure we have a character
    if not container_user.character:
        actions['promptForCharacter'] = container_user.display_name
        return json_response(caller_context, container_user, actions, False)

    # check for daily gold bonus
    characterController = CharacterController()
    daily_gold = characterController.check_daily_reward(container_user)
    if daily_gold > 0:
        actions['dailyGold'] = daily_gold

    # get invites
    pyramidController = PyramidController()
    invited_pyramid_ids, invites = pyramidController.get_invited_pyramid_ids(container_user, True)
    if invites:
        actions['invites'] = {}
        for invite in invites:
            actions['invites'][invite.key().name()] = { "character_name" : invite.inviter_character.character_name, 
                                                        "inviterUrl" : invite.inviter_character.image_url }
            #startupJs += 'addToInviteQueue("%s", "%s", "%s");\n' % (invite.key().name(), invite.inviter_character.character_name, invite.inviter_character.image_url)
            
    # check for messages to player
    popup_messages = characterController.get_messages(container_user.character, 20, popup=True, unread=True)
    if popup_messages:
        actions['messages'] = {}
        for message in popup_messages:
            actions['messages'][message.key().name()] = { "title": message.title, 
                                                          "body" : message.body}
    characterController.mark_messages_read(popup_messages) # messages may not have actually been read, this would be better if confirmed via ajax callback
    
    if container_user.character.tutorial_on:
        actions["showTutorial"] = True

    include_experience_data = True
    return json_response(caller_context, container_user, actions, include_experience_data)