(sidebar_items, domain=None, current_url=None)
Formats sidebar_items as dropdown items
    Sample input:
        [(u'Application Users',
          [{'description': u'Create and manage users for CommCare and CloudCare.',
            'show_in_dropdown': True,
            'subpages': [{'title': <function commcare_username at 0x109869488>,
                          'urlname': 'edit_commcare_user'},
                         {'title': u'Bulk Upload',
                          'urlname': 'upload_commcare_users'},
                         {'title': 'Confirm Billing Information',],
            'title': u'Mobile Workers',
            'url': '/a/sravan-test/settings/users/commcare/'},
         (u'Project Users',
          [{'description': u'Grant other CommCare HQ users access
                            to your project and manage user roles.',
            'show_in_dropdown': True,
            'subpages': [{'title': u'Invite Web User',
                          'urlname': 'invite_web_user'},
                         {'title': <function web_username at 0x10982a9b0>,
                          'urlname': 'user_account'},
                         {'title': u'My Information',
                          'urlname': 'domain_my_account'}],
            'title': <django.utils.functional.__proxy__ object at 0x106a5c790>,
            'url': '/a/sravan-test/settings/users/web/'}])]
    Sample output:
        [{'data_id': None,
          'html': None,
          'is_divider': False,
          'is_header': True,
          'title': u'Application Users',
          'url': None},
         {'data_id': None,
          'html': None,
          'is_divider': False,
          'is_header': False,
          'title': u'Mobile Workers',
          'url': '/a/sravan-test/settings/users/commcare/'},
         {'data_id': None,
          'html': None,
          'is_divider': False,
          'is_header': False,
          'title': u'Groups',
          'url': '/a/sravan-test/settings/users/groups/'},
         {'data_id': None,
          'html': None,
          'is_divider': False,
          'is_header': True,
          'title': u'Project Users',
          'url': None},]
Formats sidebar_items as dropdown items
    Sample input:
        [(u'Application Users',
          [{'description': u'Create and manage users for CommCare and CloudCare.',
            'show_in_dropdown': True,
            'subpages': [{'title': <function commcare_username at 0x109869488>,
                          'urlname': 'edit_commcare_user'},
                         {'title': u'Bulk Upload',
                          'urlname': 'upload_commcare_users'},
                         {'title': 'Confirm Billing Information',],
            'title': u'Mobile Workers',
            'url': '/a/sravan-test/settings/users/commcare/'},
         (u'Project Users',
          [{'description': u'Grant other CommCare HQ users access
                            to your project and manage user roles.',
            'show_in_dropdown': True,
            'subpages': [{'title': u'Invite Web User',
                          'urlname': 'invite_web_user'},
                         {'title': <function web_username at 0x10982a9b0>,
                          'urlname': 'user_account'},
                         {'title': u'My Information',
                          'urlname': 'domain_my_account'}],
            'title': <django.utils.functional.__proxy__ object at 0x106a5c790>,
            'url': '/a/sravan-test/settings/users/web/'}])]
    Sample output:
        [{'data_id': None,
          'html': None,
          'is_divider': False,
          'is_header': True,
          'title': u'Application Users',
          'url': None},
         {'data_id': None,
          'html': None,
          'is_divider': False,
          'is_header': False,
          'title': u'Mobile Workers',
          'url': '/a/sravan-test/settings/users/commcare/'},
         {'data_id': None,
          'html': None,
          'is_divider': False,
          'is_header': False,
          'title': u'Groups',
          'url': '/a/sravan-test/settings/users/groups/'},
         {'data_id': None,
          'html': None,
          'is_divider': False,
          'is_header': True,
          'title': u'Project Users',
          'url': None},]
Formats sidebar_items as dropdown items Sample input : [ ( u Application Users [ { description : u Create and manage users for CommCare and CloudCare . show_in_dropdown : True subpages : [ { title : <function commcare_username at 0x109869488 > urlname : edit_commcare_user } { title : u Bulk Upload urlname : upload_commcare_users } { title : Confirm Billing Information ] title : u Mobile Workers url : / a / sravan - test / settings / users / commcare / } ( u Project Users [ { description : u Grant other CommCare HQ users access to your project and manage user roles . show_in_dropdown : True subpages : [ { title : u Invite Web User urlname : invite_web_user } { title : <function web_username at 0x10982a9b0 > urlname : user_account } { title : u My Information urlname : domain_my_account } ] title : <django . utils . functional . __proxy__ object at 0x106a5c790 > url : / a / sravan - test / settings / users / web / } ] ) ] Sample output : [ { data_id : None html : None is_divider : False is_header : True title : u Application Users url : None } { data_id : None html : None is_divider : False is_header : False title : u Mobile Workers url : / a / sravan - test / settings / users / commcare / } { data_id : None html : None is_divider : False is_header : False title : u Groups url : / a / sravan - test / settings / users / groups / } { data_id : None html : None is_divider : False is_header : True title : u Project Users url : None } ]
def sidebar_to_dropdown(sidebar_items, domain=None, current_url=None):
    """
    Formats sidebar_items as dropdown items
    Sample input:
        [(u'Application Users',
          [{'description': u'Create and manage users for CommCare and CloudCare.',
            'show_in_dropdown': True,
            'subpages': [{'title': <function commcare_username at 0x109869488>,
                          'urlname': 'edit_commcare_user'},
                         {'title': u'Bulk Upload',
                          'urlname': 'upload_commcare_users'},
                         {'title': 'Confirm Billing Information',],
            'title': u'Mobile Workers',
            'url': '/a/sravan-test/settings/users/commcare/'},
         (u'Project Users',
          [{'description': u'Grant other CommCare HQ users access
                            to your project and manage user roles.',
            'show_in_dropdown': True,
            'subpages': [{'title': u'Invite Web User',
                          'urlname': 'invite_web_user'},
                         {'title': <function web_username at 0x10982a9b0>,
                          'urlname': 'user_account'},
                         {'title': u'My Information',
                          'urlname': 'domain_my_account'}],
            'title': <django.utils.functional.__proxy__ object at 0x106a5c790>,
            'url': '/a/sravan-test/settings/users/web/'}])]
    Sample output:
        [{'data_id': None,
          'html': None,
          'is_divider': False,
          'is_header': True,
          'title': u'Application Users',
          'url': None},
         {'data_id': None,
          'html': None,
          'is_divider': False,
          'is_header': False,
          'title': u'Mobile Workers',
          'url': '/a/sravan-test/settings/users/commcare/'},
         {'data_id': None,
          'html': None,
          'is_divider': False,
          'is_header': False,
          'title': u'Groups',
          'url': '/a/sravan-test/settings/users/groups/'},
         {'data_id': None,
          'html': None,
          'is_divider': False,
          'is_header': True,
          'title': u'Project Users',
          'url': None},]
    """
    dropdown_items = []
    more_items_in_sidebar = False
    for side_header, side_list in sidebar_items:
        dropdown_header = dropdown_dict(side_header, is_header=True)
        current_dropdown_items = []
        for side_item in side_list:
            show_in_dropdown = side_item.get("show_in_dropdown", False)
            if show_in_dropdown:
                second_level_dropdowns = subpages_as_dropdowns(
                    side_item.get('subpages', []), level=2, domain=domain)
                dropdown_item = dropdown_dict(
                    side_item['title'],
                    url=side_item['url'],
                    second_level_dropdowns=second_level_dropdowns,
                )
                current_dropdown_items.append(dropdown_item)
                first_level_dropdowns = subpages_as_dropdowns(
                    side_item.get('subpages', []), level=1, domain=domain
                )
                current_dropdown_items = current_dropdown_items + first_level_dropdowns
            else:
                more_items_in_sidebar = True
        if current_dropdown_items:
            dropdown_items.extend([dropdown_header] + current_dropdown_items)

    if dropdown_items and more_items_in_sidebar and current_url:
        return dropdown_items + divider_and_more_menu(current_url)
    else:
        return dropdown_items
def sidebar_to_dropdown ( sidebar_items , domain = None , current_url = None ) : dropdown_items = [ ] more_items_in_sidebar = False for side_header , side_list in sidebar_items : dropdown_header = dropdown_dict ( side_header , is_header = True ) current_dropdown_items = [ ] for side_item in side_list : show_in_dropdown = side_item . get ( "show_in_dropdown" , False ) if show_in_dropdown : second_level_dropdowns = subpages_as_dropdowns ( side_item . get ( 'subpages' , [ ] ) , level = 2 , domain = domain ) dropdown_item = dropdown_dict ( side_item [ 'title' ] , url = side_item [ 'url' ] , second_level_dropdowns = second_level_dropdowns , ) current_dropdown_items . append ( dropdown_item ) first_level_dropdowns = subpages_as_dropdowns ( side_item . get ( 'subpages' , [ ] ) , level = 1 , domain = domain ) current_dropdown_items = current_dropdown_items + first_level_dropdowns else : more_items_in_sidebar = True if current_dropdown_items : dropdown_items . extend ( [ dropdown_header ] + current_dropdown_items ) if dropdown_items and more_items_in_sidebar and current_url : return dropdown_items + divider_and_more_menu ( current_url ) else : return dropdown_items