def get_ballot_options(request, ballot):
    """
        This function returns a dictionary used for creating dynamic forms, it contains:


    :param request: HTTP object containing django state and current user
    :param ballot: ballot object (from models), it is connected to one election and has one ballot question
    :return: dictionary used to create dynamic forms:
        {'type': 'ranked' or 'checkbox' or 'radio',
        'allow_custom': True or False,
        'max_choices': int,
        'option_list':
                [{'type':'normal' or 'write_in',
                  'obj': option_obj or write_in_option_obj (from model)}, ...]
    """

    dynamic_form = {'type': ballot.type, 'allow_custom':ballot.allow_custom, 'max_choices':ballot.max_num}
    dynamic_form['option_list'] = []
    for opt in ballot.option_set.all():

        dynamic_form['option_list'].append({'type':'normal', 'obj':opt})
    if ballot.allow_custom:
        dynamic_form['allow_custom'] = True
        for write_in in request.user.writeinoption_set.filter(ballot_item=ballot.id):

            dynamic_form['option_list'].append({'type':'write_in', 'obj':write_in})

    return dynamic_form