@@ -0,0 +1,2088 @@
+# -*- coding: utf-8 -*-%0A%0Afrom website.addons.base import generic_views%0Afrom website.addons.figshare.serializer import FigshareSerializer%0Afrom website.addons.figshare.utils import options_to_hgrid%0A%0Afrom website.util import rubeus%0A%0Afrom website.project.decorators import (%0A    must_have_addon, must_be_addon_authorizer,%0A)%0A%0ASHORT_NAME = 'figshare'%0AFULL_NAME = SHORT_NAME%0A%0Afigshare_account_list = generic_views.account_list(%0A    SHORT_NAME,%0A    FigshareSerializer%0A)%0A%0Afigshare_import_auth = generic_views.import_auth(%0A    SHORT_NAME,%0A    FigshareSerializer%0A)%0A%0Afigshare_deauthorize_node = generic_views.deauthorize_node(%0A    SHORT_NAME%0A)%0A%0Afigshare_get_config = generic_views.get_config(%0A    SHORT_NAME,%0A    FigshareSerializer%0A)%0A%0Adef _set_folder(node_addon, folder, auth):%0A    node_addon.set_folder(folder, auth=auth)%0A    node_addon.save()%0A%0Afigshare_set_config = generic_views.set_config(%0A    SHORT_NAME,%0A    FULL_NAME,%0A    FigshareSerializer,%0A    _set_folder%0A)%0A%0A@must_have_addon(SHORT_NAME, 'node')%0A@must_be_addon_authorizer(SHORT_NAME)%0Adef figshare_folder_list(node_addon, **kwargs):%0A    %22%22%22 Returns all the subsequent folders under the folder id passed.%0A    %22%22%22%0A    folders = node_addon.get_folders()%0A    return options_to_hgrid(node_addon.owner, folders) or %5B%5D%0A%0Adef figshare_root_folder(node_settings, auth, **kwargs):%0A    if not node_settings.has_auth or not node_settings.folder_id:%0A        return None%0A    node = node_settings.owner%0A    if node_settings.figshare_type == 'project':%0A        item = node_settings.api.project(node_settings, node_settings.figshare_id)%0A    else:%0A        item = node_settings.api.article(node_settings, node_settings.figshare_id)%0A%0A    return %5B%0A        rubeus.build_addon_root(%0A            node_settings=node_settings,%0A            name=node_settings.fetch_folder_name(),%0A            permissions=auth,%0A            nodeUrl=node.url,%0A            nodeApiUrl=node.api_url,%0A            extra=%7B%0A                'status': (item.get('articles') or item%5B'items'%5D)%5B0%5D%5B'status'%5D.lower()%0A            %7D,%0A            private_key=kwargs.get('view_only', None),%0A        )%0A    %5D%0A

Use generic views when possible