@must_be_valid_project
@must_be_logged_in
@must_have_permission(READ)
def node_setting(auth, node, **kwargs):

    #check institutions:
    try:
        email_domains = [email.split('@')[1] for email in auth.user.emails]
        inst = Institution.find_one(Q('email_domains', 'in', email_domains))
        if inst not in auth.user.affiliated_institutions:
            auth.user.affiliated_institutions.append(inst)
            auth.user.save()
    except (__HOLE__, NoResultsFound):
        pass

    ret = _view_project(node, auth, primary=True)

    addons_enabled = []
    addon_enabled_settings = []

    for addon in node.get_addons():
        addons_enabled.append(addon.config.short_name)
        if 'node' in addon.config.configs:
            config = addon.to_json(auth.user)
            # inject the MakoTemplateLookup into the template context
            # TODO inject only short_name and render fully client side
            config['template_lookup'] = addon.config.template_lookup
            config['addon_icon_url'] = addon.config.icon_url
            addon_enabled_settings.append(config)

    addon_enabled_settings = sorted(addon_enabled_settings, key=lambda addon: addon['addon_full_name'].lower())

    ret['addon_categories'] = settings.ADDON_CATEGORIES
    ret['addons_available'] = sorted([
        addon
        for addon in settings.ADDONS_AVAILABLE
        if 'node' in addon.owners
        and addon.short_name not in settings.SYSTEM_ADDED_ADDONS['node'] and addon.short_name != 'wiki'
    ], key=lambda addon: addon.full_name.lower())

    for addon in settings.ADDONS_AVAILABLE:
        if 'node' in addon.owners and addon.short_name not in settings.SYSTEM_ADDED_ADDONS['node'] and addon.short_name == 'wiki':
            ret['wiki'] = addon
            break

    ret['addons_enabled'] = addons_enabled
    ret['addon_enabled_settings'] = addon_enabled_settings
    ret['addon_capabilities'] = settings.ADDON_CAPABILITIES
    ret['addon_js'] = collect_node_config_js(node.get_addons())

    ret['include_wiki_settings'] = node.include_wiki_settings(auth.user)

    ret['comments'] = {
        'level': node.comment_level,
    }

    ret['categories'] = Node.CATEGORY_MAP
    ret['categories'].update({
        'project': 'Project'
    })

    return ret
dataset/ETHPy150Open CenterForOpenScience/osf.io/website/project/views/node.py/node_setting