Beispiel #1
0
def react_fake_view(request, **kwargs):

    username = request.user.username
    guide_enabled = UserOptions.objects.is_user_guide_enabled(username)
    if guide_enabled:
        create_default_library(request)

    try:
        expire_days = seafile_api.get_server_config_int(
            'library_trash', 'expire_days')
    except Exception as e:
        logger.error(e)
        expire_days = -1

    folder_perm_enabled = True if is_pro_version(
    ) and ENABLE_FOLDER_PERM else False

    try:
        max_upload_file_size = seafile_api.get_server_config_int(
            'fileserver', 'max_upload_size')
    except Exception as e:
        logger.error(e)
        max_upload_file_size = -1

    return render(
        request, "react_app.html", {
            "guide_enabled": guide_enabled,
            'trash_repos_expire_days': expire_days if expire_days > 0 else 30,
            'dtable_web_server': DTABLE_WEB_SERVER,
            'max_upload_file_size': max_upload_file_size,
            'seafile_collab_server': SEAFILE_COLLAB_SERVER,
            'storages': get_library_storages(request),
            'enable_repo_snapshot_label': settings.ENABLE_REPO_SNAPSHOT_LABEL,
            'resumable_upload_file_block_size':
            settings.RESUMABLE_UPLOAD_FILE_BLOCK_SIZE,
            'max_number_of_files_for_fileupload':
            settings.MAX_NUMBER_OF_FILES_FOR_FILEUPLOAD,
            'share_link_expire_days_default': SHARE_LINK_EXPIRE_DAYS_DEFAULT,
            'share_link_expire_days_min': SHARE_LINK_EXPIRE_DAYS_MIN,
            'share_link_expire_days_max': SHARE_LINK_EXPIRE_DAYS_MAX,
            'upload_link_expire_days_default': UPLOAD_LINK_EXPIRE_DAYS_DEFAULT,
            'upload_link_expire_days_min': UPLOAD_LINK_EXPIRE_DAYS_MIN,
            'upload_link_expire_days_max': UPLOAD_LINK_EXPIRE_DAYS_MAX,
            'enable_encrypted_library': config.ENABLE_ENCRYPTED_LIBRARY,
            'enable_repo_history_setting': config.ENABLE_REPO_HISTORY_SETTING,
            'enable_reset_encrypted_repo_password':
            ENABLE_RESET_ENCRYPTED_REPO_PASSWORD,
            'enableFileComment': settings.ENABLE_FILE_COMMENT,
            'is_email_configured': IS_EMAIL_CONFIGURED,
            'can_add_public_repo':
            request.user.permissions.can_add_public_repo(),
            'folder_perm_enabled': folder_perm_enabled,
            'file_audit_enabled': FILE_AUDIT_ENABLED,
            'custom_nav_items': json.dumps(CUSTOM_NAV_ITEMS),
            'enable_show_contact_email_when_search_user':
            settings.ENABLE_SHOW_CONTACT_EMAIL_WHEN_SEARCH_USER,
            'additional_share_dialog_note': ADDITIONAL_SHARE_DIALOG_NOTE,
            'additional_app_bottom_links': ADDITIONAL_APP_BOTTOM_LINKS,
            'additional_about_dialog_links': ADDITIONAL_ABOUT_DIALOG_LINKS
        })
Beispiel #2
0
def sysadmin_react_fake_view(request, **kwargs):

    try:
        expire_days = seafile_api.get_server_config_int('library_trash', 'expire_days')
    except Exception as e:
        logger.error(e)
        expire_days = -1

    multi_institution = getattr(dj_settings, 'MULTI_INSTITUTION', False)
    institutions = None
    if multi_institution:
        institutions = [inst.name for inst in Institution.objects.all()]

    return render(request, 'sysadmin/sysadmin_react_app.html', {
        'constance_enabled': dj_settings.CONSTANCE_ENABLED,
        'multi_tenancy': MULTI_TENANCY,
        'multi_institution': multi_institution,
        'institutions': institutions,
        'send_email_on_adding_system_member': SEND_EMAIL_ON_ADDING_SYSTEM_MEMBER,
        'sysadmin_extra_enabled': ENABLE_SYSADMIN_EXTRA,
        'enable_guest_invitation': ENABLE_GUEST_INVITATION,
        'enable_terms_and_conditions': config.ENABLE_TERMS_AND_CONDITIONS,
        'enable_file_scan': ENABLE_FILE_SCAN,
        'enable_work_weixin': ENABLE_WORK_WEIXIN,
        'enable_dingtalk': ENABLE_DINGTALK,
        'enable_sys_admin_view_repo': ENABLE_SYS_ADMIN_VIEW_REPO,
        'trash_repos_expire_days': expire_days if expire_days > 0 else 30,
        'available_roles': get_available_roles(),
        'available_admin_roles': get_available_admin_roles(),
        'have_ldap': get_ldap_info(),
        'two_factor_auth_enabled': has_two_factor_auth(),
        'enable_share_link_report_abuse': ENABLE_SHARE_LINK_REPORT_ABUSE,
    })
Beispiel #3
0
def sysadmin_react_fake_view(request, **kwargs):

    try:
        expire_days = seafile_api.get_server_config_int('library_trash', 'expire_days')
    except Exception as e:
        logger.error(e)
        expire_days = -1

    return render(request, 'sysadmin/sysadmin_react_app.html', {
        'constance_enabled': dj_settings.CONSTANCE_ENABLED,
        'multi_tenancy': MULTI_TENANCY,
        'multi_institution': getattr(dj_settings, 'MULTI_INSTITUTION', False),
        'send_email_on_adding_system_member': SEND_EMAIL_ON_ADDING_SYSTEM_MEMBER,
        'sysadmin_extra_enabled': ENABLE_SYSADMIN_EXTRA,
        'enable_guest_invitation': ENABLE_GUEST_INVITATION,
        'enable_terms_and_conditions': config.ENABLE_TERMS_AND_CONDITIONS,
        'enable_work_weixin': ENABLE_WORK_WEIXIN,
        'trash_repos_expire_days': expire_days if expire_days > 0 else 30,
        'available_roles': get_available_roles(),
        'available_admin_roles': get_available_admin_roles()
    })
Beispiel #4
0
def test_server_config():

    #test_set_server_config_int and get_server_config_int
    t_group = 't_group'
    t_key = 't_key'
    t_value = 1
    api.set_server_config_int(t_group, t_key, t_value)
    t_ret = api.get_server_config_int(t_group, t_key)
    assert t_ret == t_value

    #test_set_server_config_int64 and get_server_config_int64
    t_group = 't_group'
    t_key = 't_key'
    t_value = 9223372036854775807
    api.set_server_config_int64(t_group, t_key, t_value)
    t_ret = api.get_server_config_int64(t_group, t_key)
    assert t_ret == t_value

    #test_set_server_config_string and get_server_config_string
    t_group = 't_group'
    t_key = 't_key'
    t_value = 't_value'
    api.set_server_config_string(t_group, t_key, t_value)
    t_ret = api.get_server_config_string(t_group, t_key)
    assert t_ret == t_value

    #test_set_server_config_boolean and get_server_config_boolean
    t_group = 't_group'
    t_key = 't_key'
    t_value = True
    api.set_server_config_boolean(t_group, t_key, t_value)
    t_ret = api.get_server_config_boolean(t_group, t_key)
    assert t_ret == t_value

    t_value = False
    api.set_server_config_boolean(t_group, t_key, t_value)
    t_ret = api.get_server_config_boolean(t_group, t_key)
    assert t_ret == t_value
Beispiel #5
0
def react_fake_view(request, **kwargs):

    username = request.user.username

    if resolve(request.path).url_name == 'lib_view':

        repo_id = kwargs.get('repo_id', '')
        path = kwargs.get('path', '')

        if repo_id and path and \
                not check_folder_permission(request, repo_id, path):

            converted_repo_path = seafile_api.convert_repo_path(
                repo_id, path, username)
            if not converted_repo_path:
                error_msg = 'Permission denied.'
                return render_error(request, error_msg)

            repo_path_dict = json.loads(converted_repo_path)

            converted_repo_id = repo_path_dict['repo_id']
            converted_repo = seafile_api.get_repo(converted_repo_id)
            if not converted_repo:
                error_msg = 'Library %s not found.' % converted_repo_id
                return render_error(request, error_msg)

            converted_path = repo_path_dict['path']
            if not seafile_api.get_dirent_by_path(converted_repo_id,
                                                  converted_path):
                error_msg = 'Dirent %s not found.' % converted_path
                return render_error(request, error_msg)

            if not check_folder_permission(request, converted_repo_id,
                                           converted_path):
                error_msg = 'Permission denied.'
                return render_error(request, error_msg)

            next_url = reverse('lib_view',
                               args=[
                                   converted_repo_id, converted_repo.repo_name,
                                   converted_path.strip('/')
                               ])
            return HttpResponseRedirect(next_url)

    guide_enabled = UserOptions.objects.is_user_guide_enabled(username)
    if guide_enabled:
        create_default_library(request)

    try:
        expire_days = seafile_api.get_server_config_int(
            'library_trash', 'expire_days')
    except Exception as e:
        logger.error(e)
        expire_days = -1

    folder_perm_enabled = True if is_pro_version(
    ) and ENABLE_FOLDER_PERM else False

    try:
        max_upload_file_size = seafile_api.get_server_config_int(
            'fileserver', 'max_upload_size')
    except Exception as e:
        logger.error(e)
        max_upload_file_size = -1

    return render(
        request, "react_app.html", {
            "onlyoffice_desktop_editors_portal_login":
            ONLYOFFICE_DESKTOP_EDITORS_PORTAL_LOGIN,
            "guide_enabled": guide_enabled,
            'trash_repos_expire_days': expire_days if expire_days > 0 else 30,
            'dtable_web_server': DTABLE_WEB_SERVER,
            'max_upload_file_size': max_upload_file_size,
            'seafile_collab_server': SEAFILE_COLLAB_SERVER,
            'storages': get_library_storages(request),
            'library_templates': list(LIBRARY_TEMPLATES.keys()),
            'enable_repo_snapshot_label': settings.ENABLE_REPO_SNAPSHOT_LABEL,
            'resumable_upload_file_block_size':
            settings.RESUMABLE_UPLOAD_FILE_BLOCK_SIZE,
            'max_number_of_files_for_fileupload':
            settings.MAX_NUMBER_OF_FILES_FOR_FILEUPLOAD,
            'share_link_expire_days_default': SHARE_LINK_EXPIRE_DAYS_DEFAULT,
            'share_link_expire_days_min': SHARE_LINK_EXPIRE_DAYS_MIN,
            'share_link_expire_days_max': SHARE_LINK_EXPIRE_DAYS_MAX,
            'upload_link_expire_days_default': UPLOAD_LINK_EXPIRE_DAYS_DEFAULT,
            'upload_link_expire_days_min': UPLOAD_LINK_EXPIRE_DAYS_MIN,
            'upload_link_expire_days_max': UPLOAD_LINK_EXPIRE_DAYS_MAX,
            'enable_encrypted_library': config.ENABLE_ENCRYPTED_LIBRARY,
            'enable_repo_history_setting': config.ENABLE_REPO_HISTORY_SETTING,
            'enable_reset_encrypted_repo_password':
            ENABLE_RESET_ENCRYPTED_REPO_PASSWORD,
            'enableFileComment': settings.ENABLE_FILE_COMMENT,
            'is_email_configured': IS_EMAIL_CONFIGURED,
            'can_add_public_repo':
            request.user.permissions.can_add_public_repo(),
            'folder_perm_enabled': folder_perm_enabled,
            'file_audit_enabled': FILE_AUDIT_ENABLED,
            'custom_nav_items': json.dumps(CUSTOM_NAV_ITEMS),
            'enable_show_contact_email_when_search_user':
            settings.ENABLE_SHOW_CONTACT_EMAIL_WHEN_SEARCH_USER,
            'additional_share_dialog_note': ADDITIONAL_SHARE_DIALOG_NOTE,
            'additional_app_bottom_links': ADDITIONAL_APP_BOTTOM_LINKS,
            'additional_about_dialog_links': ADDITIONAL_ABOUT_DIALOG_LINKS,
            'enable_ocm': ENABLE_OCM,
            'ocm_remote_servers': OCM_REMOTE_SERVERS,
            'enable_share_to_department': settings.ENABLE_SHARE_TO_DEPARTMENT,
            'enable_video_thumbnail': settings.ENABLE_VIDEO_THUMBNAIL,
            'group_import_members_extra_msg': GROUP_IMPORT_MEMBERS_EXTRA_MSG,
        })
Beispiel #6
0
def libraries(request):
    """
    New URL to replace myhome
    """
    username = request.user.username

    # options
    if request.cloud_mode and request.user.org is None:
        allow_public_share = False
    else:
        allow_public_share = True
    sub_lib_enabled = UserOptions.objects.is_sub_lib_enabled(username)
    max_upload_file_size = get_max_upload_file_size()
    guide_enabled = UserOptions.objects.is_user_guide_enabled(username)
    if guide_enabled:
        create_default_library(request)

    folder_perm_enabled = True if is_pro_version() and ENABLE_FOLDER_PERM else False

    if request.cloud_mode and request.user.org is not None:
        org_id = request.user.org.org_id
        joined_groups = seaserv.get_org_groups_by_user(org_id, username)
    else:
        joined_groups = ccnet_api.get_groups(username, return_ancestors=True)

    if joined_groups:
        try:
            joined_groups.sort(lambda x, y: cmp(x.group_name.lower(), y.group_name.lower()))
        except Exception as e:
            logger.error(e)
            joined_groups = []

    joined_groups_exclude_address_book = [item for item in joined_groups if
            item.parent_group_id == 0]

    try:
        expire_days = seafile_api.get_server_config_int('library_trash', 'expire_days')
    except Exception as e:
        logger.error(e)
        expire_days = -1

    # Whether use new index page
    use_new_page = True
    if request.GET.get('_old', None):
        use_new_page = False

    if use_new_page:
        return react_fake_view(request)

    return render(request, 'libraries.html', {
            "allow_public_share": allow_public_share,
            "guide_enabled": guide_enabled,
            "sub_lib_enabled": sub_lib_enabled,
            'enable_wiki': request.user.permissions.can_use_wiki(),
            'enable_upload_folder': settings.ENABLE_UPLOAD_FOLDER,
            'enable_resumable_fileupload': settings.ENABLE_RESUMABLE_FILEUPLOAD,
            'resumable_upload_file_block_size': settings.RESUMABLE_UPLOAD_FILE_BLOCK_SIZE,
            'max_number_of_files_for_fileupload': settings.MAX_NUMBER_OF_FILES_FOR_FILEUPLOAD,
            'enable_thumbnail': settings.ENABLE_THUMBNAIL,
            'enable_repo_snapshot_label': settings.ENABLE_REPO_SNAPSHOT_LABEL,
            'thumbnail_default_size': settings.THUMBNAIL_DEFAULT_SIZE,
            'thumbnail_size_for_grid': settings.THUMBNAIL_SIZE_FOR_GRID,
            'enable_encrypted_library': config.ENABLE_ENCRYPTED_LIBRARY,
            'enable_repo_history_setting': config.ENABLE_REPO_HISTORY_SETTING,
            'max_upload_file_size': max_upload_file_size,
            'folder_perm_enabled': folder_perm_enabled,
            'is_pro': True if is_pro_version() else False,
            'file_audit_enabled': FILE_AUDIT_ENABLED,
            'can_add_public_repo': request.user.permissions.can_add_public_repo(),
            'joined_groups': joined_groups,
            'joined_groups_exclude_address_book': joined_groups_exclude_address_book,
            'storages': get_library_storages(request),
            'unread_notifications_request_interval': UNREAD_NOTIFICATIONS_REQUEST_INTERVAL,
            'library_templates': LIBRARY_TEMPLATES.keys() if \
                    isinstance(LIBRARY_TEMPLATES, dict) else [],
            'enable_share_to_all_groups': config.ENABLE_SHARE_TO_ALL_GROUPS,
            'enable_group_discussion': settings.ENABLE_GROUP_DISCUSSION,
            'enable_file_comment': settings.ENABLE_FILE_COMMENT,
            'share_link_expire_days_min': SHARE_LINK_EXPIRE_DAYS_MIN,
            'share_link_expire_days_max': SHARE_LINK_EXPIRE_DAYS_MAX,
            'share_link_expire_days_default': SHARE_LINK_EXPIRE_DAYS_DEFAULT,
            'enable_office_web_app': ENABLE_OFFICE_WEB_APP,
            'enable_onlyoffice': ENABLE_ONLYOFFICE,
            'trash_repos_expire_days': expire_days if expire_days > 0 else 30,
            })