def __init__( self, workspace_id: int = None, complete_path_to_id: int = None, parent_ids: str = None, show_archived: int = 0, show_deleted: int = 0, show_active: int = 1, content_type: str = None, label: str = None, page_nb: int = None, limit: int = None, namespaces_filter: str = None, ) -> None: self.parent_ids = string_to_list(parent_ids, ",", int) self.namespaces_filter = string_to_list(namespaces_filter, ",", ContentNamespaces) self.complete_path_to_id = complete_path_to_id self.workspace_id = workspace_id self.show_archived = bool(show_archived) self.show_deleted = bool(show_deleted) self.show_active = bool(show_active) self.limit = limit self.page_nb = page_nb self.label = label self.content_type = content_type
def __init__(self, acp: str, exclude_user_ids: str = None, exclude_workspace_ids: str = None) -> None: self.acp = acp self.exclude_user_ids = string_to_list(exclude_user_ids, ",", int) self.exclude_workspace_ids = string_to_list(exclude_workspace_ids, ",", int)
def __init__( self, acp: str, exclude_user_ids: str = None, exclude_workspace_ids: str = None ) -> None: self.acp = acp self.exclude_user_ids = string_to_list(exclude_user_ids, ',', int) self.exclude_workspace_ids = string_to_list(exclude_workspace_ids, ',', int) # nopep8
def __init__( self, acp: str, exclude_user_ids: str = None, exclude_workspace_ids: str = None, include_workspace_ids: str = None, limit: int = None, ) -> None: self.acp = acp self.exclude_user_ids = string_to_list(exclude_user_ids, ",", int) self.exclude_workspace_ids = string_to_list(exclude_workspace_ids, ",", int) self.include_workspace_ids = string_to_list(include_workspace_ids, ",", int) self.limit = limit
def _load_search_config(self): self.SEARCH__ENGINE = self.get_raw_config("search.engine", "simple") DEFAULT_INDEX_DOCUMENTS_PATTERN_TEMPLATE = "{index_alias}-{date}" self.SEARCH__ELASTICSEARCH__INDEX_ALIAS = self.get_raw_config( "search.elasticsearch.index_alias") self.SEARCH__ELASTICSEARCH__INDEX_PATTERN_TEMPLATE = self.get_raw_config( "search.elasticsearch.index_pattern_template", DEFAULT_INDEX_DOCUMENTS_PATTERN_TEMPLATE) self.SEARCH__ELASTICSEARCH__USE_INGEST = asbool( self.get_raw_config("search.elasticsearch.use_ingest", "False")) # FIXME - G.M - 2019-05-31 - limit default allowed mimetype to useful list instead of ALLOWED_INGEST_DEFAULT_MIMETYPE = "" self.SEARCH__ELASTICSEARCH__INGEST__MIMETYPE_WHITELIST = string_to_list( self.get_raw_config( "search.elasticsearch.ingest.mimetype_whitelist", ALLOWED_INGEST_DEFAULT_MIMETYPE), separator=",", cast_func=str, do_strip=True, ) self.SEARCH__ELASTICSEARCH__HOST = self.get_raw_config( "search.elasticsearch.host", "localhost") self.SEARCH__ELASTICSEARCH__PORT = int( self.get_raw_config("search.elasticsearch.port", "9200"))
def test_unit__string_to_list__ok__list_of_int_(self): assert string_to_list("1,2,3,4", separator=",", cast_func=int, do_strip=True) == [ 1, 2, 3, 4, ]
def __init__( self, include_event_types: Optional[ List[EventTypeDatabaseParameters]] = None, exclude_event_types: Optional[ List[EventTypeDatabaseParameters]] = None, exclude_author_ids: str = "", include_not_sent: int = 0, workspace_ids: str = "", related_to_content_ids: str = "", ) -> None: self.include_event_types = include_event_types self.exclude_event_types = exclude_event_types self.exclude_author_ids = string_to_list(exclude_author_ids, ",", int) self.include_not_sent = bool(include_not_sent) self.workspace_ids = string_to_list(workspace_ids, ",", int) self.related_to_content_ids = string_to_list(related_to_content_ids, ",", int)
def __init__( self, include_event_types: Optional[ List[EventTypeDatabaseParameters]] = None, exclude_event_types: Optional[ List[EventTypeDatabaseParameters]] = None, exclude_author_ids: str = "", ) -> None: self.include_event_types = include_event_types self.exclude_event_types = exclude_event_types self.exclude_author_ids = string_to_list(exclude_author_ids, ",", int)
def __init__( self, read_status: str, count: int, include_event_types: Optional[ List[EventTypeDatabaseParameters]] = None, exclude_event_types: Optional[ List[EventTypeDatabaseParameters]] = None, page_token: Optional[str] = None, exclude_author_ids: str = "", workspace_ids: str = "", related_to_content_ids: str = "", include_not_sent: int = 0, ) -> None: self.read_status = ReadStatus(read_status) self.count = count self.page_token = page_token self.include_event_types = include_event_types self.exclude_event_types = exclude_event_types self.exclude_author_ids = string_to_list(exclude_author_ids, ",", int) self.workspace_ids = string_to_list(workspace_ids, ",", int) self.include_not_sent = bool(include_not_sent) self.related_to_content_ids = string_to_list(related_to_content_ids, ",", int)
def __init__( self, size: int = 10, page_nb: int = 1, search_string: str = "", content_types: typing.Optional[str] = None, show_deleted: int = 0, show_archived: int = 0, show_active: int = 1, ): self.search_string = search_string self.size = size self.page_nb = page_nb if not content_types: self.content_types = content_type_list.restricted_allowed_types_slug( ) else: self.content_types = string_to_list(content_types, ",", str) self.show_deleted = bool(show_deleted) self.show_archived = bool(show_archived) self.show_active = bool(show_active)
def __init__( self, workspace_id: int = None, complete_path_to_id: int = None, parent_ids: str = None, show_archived: int = 0, show_deleted: int = 0, show_active: int = 1, content_type: str = None, label: str = None, offset: int = None, limit: int = None, ) -> None: self.parent_ids = string_to_list(parent_ids, ',', int) self.complete_path_to_id = complete_path_to_id self.workspace_id = workspace_id self.show_archived = bool(show_archived) self.show_deleted = bool(show_deleted) self.show_active = bool(show_active) self.limit = limit self.offset = offset self.label = label self.content_type = content_type
def _load_global_config(self) -> None: """ Load generic config """ ### # General ### self.SQLALCHEMY__URL = self.get_raw_config("sqlalchemy.url", "") self.DEFAULT_LANG = self.get_raw_config("default_lang", DEFAULT_FALLBACK_LANG) backend_folder = os.path.dirname( os.path.dirname(os.path.abspath(__file__))) tracim_v2_folder = os.path.dirname(backend_folder) default_color_config_file_path = os.path.join(tracim_v2_folder, "color.json") self.COLOR__CONFIG_FILE_PATH = self.get_raw_config( "color.config_file_path", default_color_config_file_path) default_enabled_app = ("contents/thread," "contents/file," "contents/html-document," "contents/folder," "agenda") self.APP__ENABLED = string_to_list( self.get_raw_config("app.enabled", default_enabled_app), separator=",", cast_func=str, do_strip=True, ) self.DEPOT_STORAGE_DIR = self.get_raw_config("depot_storage_dir") self.DEPOT_STORAGE_NAME = self.get_raw_config("depot_storage_name") self.PREVIEW_CACHE_DIR = self.get_raw_config("preview_cache_dir") self.AUTH_TYPES = string_to_list( self.get_raw_config("auth_types", "internal"), separator=",", cast_func=AuthType, do_strip=True, ) self.REMOTE_USER_HEADER = self.get_raw_config("remote_user_header", None) # TODO - G.M - 2018-09-11 - Deprecated param # self.DATA_UPDATE_ALLOWED_DURATION = int(self.get_raw_config( # 'content.update.allowed.duration', # 0, # )) self.API__KEY = self.get_raw_config("api.key", "", secret=True) self.SESSION__REISSUE_TIME = int( self.get_raw_config("session.reissue_time", "120")) self.SESSION__DATA_DIR = self.get_raw_config("session.data_dir") self.SESSION__LOCK_DIR = self.get_raw_config("session.lock_dir") self.WEBSITE__TITLE = self.get_raw_config("website.title", "TRACIM") # base url of the frontend self.WEBSITE__BASE_URL = self.get_raw_config("website.base_url", "") self.API__BASE_URL = self.get_raw_config("api.base_url", self.WEBSITE__BASE_URL) if self.API__BASE_URL != self.WEBSITE__BASE_URL: default_cors_allowed_origin = "{},{}".format( self.WEBSITE__BASE_URL, self.API__BASE_URL) else: default_cors_allowed_origin = self.WEBSITE__BASE_URL self.CORS__ACCESS_CONTROL_ALLOWED_ORIGIN = string_to_list( self.get_raw_config("cors.access-control-allowed-origin", default_cors_allowed_origin), separator=",", cast_func=str, do_strip=True, ) self.USER__AUTH_TOKEN__VALIDITY = int( self.get_raw_config("user.auth_token.validity", "604800")) # TODO - G.M - 2019-03-14 - retrocompat code, # will be deleted in the future (https://github.com/tracim/tracim/issues/1483) defaut_reset_password_validity = "900" self.USER__RESET_PASSWORD__VALIDITY = self.get_raw_config( "user.reset_password.validity") if self.USER__RESET_PASSWORD__VALIDITY: logger.warning( self, "user.reset_password.validity parameter is deprecated ! " "please use user.reset_password.token_lifetime instead.", ) self.USER__RESET_PASSWORD__TOKEN_LIFETIME = self.USER__RESET_PASSWORD__VALIDITY else: self.USER__RESET_PASSWORD__TOKEN_LIFETIME = int( self.get_raw_config("user.reset_password.token_lifetime", defaut_reset_password_validity)) self.DEBUG = asbool(self.get_raw_config("debug", "false")) self.PREVIEW__JPG__RESTRICTED_DIMS = asbool( self.get_raw_config("preview.jpg.restricted_dims", "false")) self.PREVIEW__JPG__ALLOWED_DIMS = string_to_list( self.get_raw_config("preview.jpg.allowed_dims", "256x256"), cast_func=PreviewDim.from_string, separator=",", ) self.FRONTEND__SERVE = asbool( self.get_raw_config("frontend.serve", "false")) # INFO - G.M - 2018-08-06 - we pretend that frontend_dist_folder # is probably in frontend subfolder # of tracim_v2 parent of both backend and frontend backend_folder = os.path.dirname( os.path.dirname(os.path.abspath(__file__))) tracim_v2_folder = os.path.dirname(backend_folder) backend_i18n_folder = os.path.join(backend_folder, "tracim_backend", "locale") self.BACKEND__I18N_FOLDER_PATH = self.get_raw_config( "backend.i18n_folder_path", backend_i18n_folder) frontend_dist_folder = os.path.join(tracim_v2_folder, "frontend", "dist") self.FRONTEND__DIST_FOLDER_PATH = self.get_raw_config( "frontend.dist_folder_path", frontend_dist_folder)
def __init__(self, content_ids: str = None) -> None: self.content_ids = string_to_list(content_ids, ",", int)
def __init__(self, workspace_ids: str = "", agenda_types: str = ""): self.workspace_ids = string_to_list(workspace_ids, ",", int) or None self.agenda_types = string_to_list(agenda_types, ",", str) or None
def __init__( self, content_ids: str = None, ) -> None: self.content_ids = string_to_list(content_ids, ',', int)
def test_unit__string_to_list__ok__list_of_string_stripped(self): assert string_to_list( "one , two,three,fo ur", separator=",", cast_func=str, do_strip=True) == ["one", "two", "three", "fo ur"]