diff --git a/solidata_api/_core/queries_db/__init__.py b/solidata_api/_core/queries_db/__init__.py index 979d632..e23a802 100644 --- a/solidata_api/_core/queries_db/__init__.py +++ b/solidata_api/_core/queries_db/__init__.py @@ -18,31 +18,35 @@ ### declaring collections as app variables -mongo_users = mongo.db[ app.config["MONGO_COLL_USERS"] ] -mongo_licences = mongo.db[ app.config["MONGO_COLL_LICENCES"] ] -mongo_projects = mongo.db[ app.config["MONGO_COLL_PROJECTS"] ] -mongo_datamodels = mongo.db[ app.config["MONGO_COLL_DATAMODELS"] ] -mongo_datamodels_fields = mongo.db[ app.config["MONGO_COLL_DATAMODELS_FIELDS"] ] -mongo_connectors = mongo.db[ app.config["MONGO_COLL_CONNECTORS"] ] -mongo_datasets_inputs = mongo.db[ app.config["MONGO_COLL_DATASETS_INPUTS"] ] -mongo_datasets_outputs = mongo.db[ app.config["MONGO_COLL_DATASETS_OUTPUTS"] ] -mongo_recipes = mongo.db[ app.config["MONGO_COLL_RECIPES"] ] -mongo_corr_dicts = mongo.db[ app.config["MONGO_COLL_CORR_DICTS"] ] - -mongo_jwt_blacklist = mongo.db[ app.config["MONGO_COLL_JWT_BLACKLIST"] ] +mongo_users = mongo.db[ app.config["MONGO_COLL_USERS"] ] +mongo_projects = mongo.db[ app.config["MONGO_COLL_PROJECTS"] ] +mongo_datamodels_templates = mongo.db[ app.config["MONGO_COLL_DATAMODELS_TEMPLATES"] ] +mongo_datamodels_fields = mongo.db[ app.config["MONGO_COLL_DATAMODELS_FIELDS"] ] +# mongo_connectors = mongo.db[ app.config["MONGO_COLL_CONNECTORS"] ] +mongo_datasets_inputs = mongo.db[ app.config["MONGO_COLL_DATASETS_INPUTS"] ] +mongo_recipes = mongo.db[ app.config["MONGO_COLL_RECIPES"] ] +# mongo_corr_dicts = mongo.db[ app.config["MONGO_COLL_CORR_DICTS"] ] +mongo_datasets_outputs = mongo.db[ app.config["MONGO_COLL_DATASETS_OUTPUTS"] ] + +mongo_jwt_blacklist = mongo.db[ app.config["MONGO_COLL_JWT_BLACKLIST"] ] + + +# mongo_licences = mongo.db[ app.config["MONGO_COLL_LICENCES"] ] + db = { - "mongo_users" : mongo_users, - "mongo_licences" : mongo_licences, - "mongo_projects" : mongo_projects, - "mongo_datamodels" : mongo_datamodels, - "mongo_datamodels_fields" : mongo_datamodels_fields, - "mongo_connectors" : mongo_connectors, - "mongo_datasets_inputs" : mongo_datasets_inputs, - "mongo_datasets_outputs" : mongo_datasets_outputs, - "mongo_recipes" : mongo_recipes, - "mongo_corr_dicts" : mongo_corr_dicts, - "mongo_jwt_blacklist" : mongo_jwt_blacklist, + "mongo_users" : mongo_users, + "mongo_projects" : mongo_projects, + "mongo_datamodels_templates" : mongo_datamodels_templates, + "mongo_datamodels_fields" : mongo_datamodels_fields, + # "mongo_connectors" : mongo_connectors, + "mongo_datasets_inputs" : mongo_datasets_inputs, + "mongo_recipes" : mongo_recipes, + # "mongo_corr_dicts" : mongo_corr_dicts, + + "mongo_datasets_outputs" : mongo_datasets_outputs, + # "mongo_licences" : mongo_licences, + "mongo_jwt_blacklist" : mongo_jwt_blacklist, } def select_collection(coll_name): diff --git a/solidata_api/_core/utils/app_logs.py b/solidata_api/_core/utils/app_logs.py index 2f21431..6c2be3c 100644 --- a/solidata_api/_core/utils/app_logs.py +++ b/solidata_api/_core/utils/app_logs.py @@ -3,7 +3,12 @@ from datetime import datetime, timedelta -def create_modif_log( doc, action, field="log", nested_field="modified_log", dt=datetime.utcnow(), by=None ) : +def create_modif_log( doc, + action, + field="log", + nested_field="modified_log", + dt=datetime.utcnow(), + by=None ) : """ Create a simple dict for modif_log and insert it into document @@ -14,7 +19,7 @@ def create_modif_log( doc, action, field="log", nested_field="modified_log", dt= ### add author of modif if by != None : - modif["by"] = by + modif["modif_by"] = by doc[field][nested_field].insert(0, modif) diff --git a/solidata_api/_models/models_generic.py b/solidata_api/_models/models_generic.py index 626716a..2b49db0 100644 --- a/solidata_api/_models/models_generic.py +++ b/solidata_api/_models/models_generic.py @@ -19,72 +19,150 @@ +### + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ### ### MODEL / BASIC INFOS +### + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ### def create_model_basic_infos(ns_, model_name, - schema=doc_basics, + schema = doc_basics, + is_user_infos = False, ) : - + """ + """ + + schema = doc_basics + + if is_user_infos == True : + schema = user_basics + basic_infos = fields.Nested( - ns_.model( model_name , doc_basics ) + ns_.model( model_name , schema ) ) return basic_infos -### MODEL TEAM +### + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ### +### MODEL / TEAM +### + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ### def create_model_team(ns_, model_name="Collaborator"): - + + """ + """ + collaborator = fields.Nested( ns_.model( model_name, { - 'user_oid' : oid, - 'auth_edit' : edit_auth + 'oid_usr' : oid_usr, + 'edit_auth' : edit_auth, + 'added_at' : added_at, + 'added_by' : oid_usr, }) ) collaborators = fields.List( collaborator, - description = "List of collaborators on this document", + description = "List of {}s on this document".format(model_name), default = [] - ) + ) return collaborators -### MODIFICATIONS LOG -def create_model_modif_log(ns_, model_name, - schema = modification_full, - include_counts = False, - counts_name = "counts", - include_created_by = True, - include_is_running = False, + +### + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ### +### MODEL / DATASETS +### + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ### +def create_model_datasets(ns_, model_name = "Datasets" , + include_fav = False, + display_fullname = False , + schema_list = ["prj", "dmt", "dmf", "dsi", "rec", "dso"], + ) : + """ + """ + + datasets_dict = {} + + for schema in schema_list : + + model_dataset = { + 'oid_usr' : oid_dict[schema]["field"], + 'added_at' : added_at, + 'added_by' : oid_usr, + } + + if include_fav == True : + model_dataset["is_fav"] = is_fav + + dataset = fields.Nested( + ns_.model( schema.title(), model_dataset ) + ) + + dataset_list = fields.List( + dataset, + description = "List of {}s on this document".format(oid_dict[schema]["fullname"]), + default = [] + ) + + datasets_dict[schema] = dataset_list + + datasets = fields.Nested( + ns_.model( model_name, datasets_dict ) + ) + + return datasets + + + +### + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ### +### MODEL / MODIFICATIONS LOG +### + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ### +def create_model_modif_log(ns_, model_name = "Modification", + schema = modification_full, ) : + + """ + """ ### create the list of modifications modifications = fields.List( fields.Nested( - ns_.model('Modifications', schema ) + ns_.model( model_name, schema ) ), - description = "List of the modifications on this document", + description = "List of the {}s on this document".format(model_name), default = [] ) + + return modifications + + + ### + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ### +### MODEL / SPECS +### + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ### +def create_model_specs(ns_, model_name = "Specs", + include_counts = False, + counts_name = "counts", + include_created_by = True, + include_is_running = False, + include_is_loaded = False, + ) : + """ + """ - log_base = { + specs_base = { 'created_at' : created_at, - 'modified_log' : modifications } if include_created_by == True : - log_base['created_by'] = oid + specs_base['created_by'] = oid_usr if include_counts == True : - log_base[ counts_name ] = count + specs_base[ counts_name ] = count if include_is_running == True : - log_base[ "is_running" ] = is_running + specs_base[ "is_running" ] = is_running ### compile the document's log - doc_log = fields.Nested( - ns_.model( model_name, log_base ) + doc_specs = fields.Nested( + ns_.model( model_name, specs_base ) ) - return doc_log \ No newline at end of file + return doc_specs \ No newline at end of file diff --git a/solidata_api/_models/models_projects.py b/solidata_api/_models/models_projects.py index 4ca1241..fb101ba 100644 --- a/solidata_api/_models/models_projects.py +++ b/solidata_api/_models/models_projects.py @@ -18,7 +18,7 @@ from solidata_api._serializers.schema_projects import * ### import generic models functions -from solidata_api._models.models_generic import * +from solidata_api._models.models_generic import * ### create models from serializers # nested models : https://github.com/noirbizarre/flask-restplus/issues/8 @@ -35,50 +35,28 @@ class Project_infos : def __init__(self, ns_) : ### SELF MODULES - # self.basic_infos = fields.Nested( - # ns_.model('Project_infos', doc_basics ) - # ) - self.basic_infos = create_model_basic_infos(ns_, "Project_infos") - - # self.modifications = fields.List( - # fields.Nested( - # ns_.model('Modifications_by', modification_full ) - # ), - # default = [] - # ) - # self.project_log = fields.Nested( - # ns_.model('Project_log', { - # 'created_at' : created_at, - # 'modified_log' : self.modifications - # }) - # ) - - self.project_log = create_model_modif_log(ns_, "Project_log", include_is_running=True) - - # self.collaborator = fields.Nested( - # ns_.model('Collaborator', { - # 'user_oid' : oid, - # 'auth_edit' : edit_auth - # }) - # ) - self.collaborators = create_model_team(ns_) - + self.basic_infos = create_model_basic_infos(ns_, "Project_infos") + self.modif_log = create_model_modif_log(ns_, "Project_modif_log") + self.specs = create_model_specs(ns_, include_is_running=True) + self.collaborators = create_model_team(ns_) + self.datasets = create_model_datasets(ns_, schema_list=["dmt","dsi","rec","dso"]) ### IN / complete data to enter in DB - self.mod_complete_in = ns_.model('Project_in', { + self.mod_complete_in = ns_.model('Project_in', { - 'infos' : self.basic_infos, - 'log' : self.project_log , + 'infos' : self.basic_infos, + 'specs' : self.specs , + 'modif_log' : self.modif_log , ### team and edition levels - # 'proj_team' : fields.List(self.collaborator) , - 'proj_team' : self.collaborators , + 'prj_team' : self.collaborators , ### datasets - 'dm_t' : oid, - 'ds_i' : fields.List(oid), - 'dc_' : fields.List(oid), - 'rec_' : fields.List(oid), + "datasets" : self.datasets , + # 'dmt' : oid_dmt, + # 'dsi' : fields.List(oid_dsi), + # 'rec' : fields.List(oid_rec), + # 'dso' : fields.List(oid_dso), }) ### OUT / complete data to enter in DB @@ -104,8 +82,8 @@ def __init__(self, ns_) : def model_complete_in(self): return self.mod_complete_in - @property - def model_complete_out(self): - return self.mod_complete_out + # @property + # def model_complete_out(self): + # return self.mod_complete_out diff --git a/solidata_api/_models/models_user.py b/solidata_api/_models/models_user.py index e3b017d..6f0e63f 100644 --- a/solidata_api/_models/models_user.py +++ b/solidata_api/_models/models_user.py @@ -139,88 +139,62 @@ def __init__(self, ns_) : ### SELF MODULES - self.basic_infos = fields.Nested( - ns_.model('User_public_data', user_basics ) - ) - - self.profiles = fields.Nested( - ns_.model('User_profiles', user_profiles) - ) - - # self.modifications = fields.List( - # fields.Nested( - # ns_.model('Modifications', modification ) - # ), - # default = [] - # ) - # self.user_log = fields.Nested( - # ns_.model("User_log", { - # 'created_at' : created_at, - # 'login_count' : count, - # 'modified_log' : self.modifications - # }) - # ) - - self.user_log = create_model_modif_log(ns_, "User_log", schema=modification, include_counts=True, counts_name='login_count', include_created_by=False) - - ### favorites - self.fav_ = fields.Nested( - ns_.model("User_fav", { - 'oid' : oid, - 'doc_categ' : doc_categ, - 'added_at' : created_at, - }) + + self.modif_log = create_model_modif_log(ns_) + self.datasets = create_model_datasets(ns_, include_fav=True, schema_list=["prj","dmt", "dmf","dsi","rec"]) + self.specs = create_model_specs(ns_, include_counts=True, counts_name="login_count") + + ### basic infos + self.basic_infos = create_model_basic_infos(ns_, "User_infos", is_user_infos=True) + # self.basic_infos = fields.Nested( + # ns_.model('User_public_data', user_basics ) + # ) + + ### profile + self.profile = fields.Nested( + ns_.model("User_profile", usr_profile_ ) ) - self.favorites = fields.List( - self.fav_ , - description = "list of user's favorite documents", - attribute = "favorites", - default = [] - ) + ### IN / complete data to enter in DB self.mod_complete_in = ns_.model('User_in', { - 'infos' : self.basic_infos, - 'profile' : self.profiles, - 'log' : self.user_log , - 'favorites' : self.favorites, + 'infos' : self.basic_infos, + 'profile' : self.profile, + 'specs' : self.specs , + 'modif_log' : self.modif_log , + "datasets" : self.datasets , 'auth': fields.Nested( ns_.model('User_authorizations', user_auth_in ) ), - 'preferences': fields.Nested( - ns_.model('User_preferences', user_preferences_in ) - ), - 'datasets': fields.Nested( - ns_.model('User_datasets', user_datasets_in ) - ), - 'professional' : fields.Nested( - ns_.model('User_profesional', user_professional_in ) - ), + # 'preferences' : fields.Nested( + # ns_.model('User_preferences', user_preferences_in ) + # ), + # 'professional' : fields.Nested( + # ns_.model('User_profesional', user_professional_in ) + # ), }) ### OUT / complete data to enter in DB self.mod_complete_out = ns_.model('User_out', { - 'infos' : self.basic_infos, - 'profile' : self.profiles, - 'log' : self.user_log , - 'favorites' : self.favorites, + 'infos' : self.basic_infos, + 'profile' : self.profile, + 'specs' : self.specs , + 'modif_log' : self.modif_log , + "datasets" : self.datasets , 'auth' : fields.Nested( ns_.model('User_authorizations', user_auth_out ) ), - 'preferences' : fields.Nested( - ns_.model('User_preferences', user_preferences_out ) - ), - 'datasets' : fields.Nested( - ns_.model('User_datasets', user_datasets_out ) - ), - 'professional' : fields.Nested( - ns_.model('User_profesional', user_professional_out ) - ), + # 'preferences' : fields.Nested( + # ns_.model('User_preferences', user_preferences_out ) + # ), + # 'professional' : fields.Nested( + # ns_.model('User_profesional', user_professional_out ) + # ), }) @@ -236,9 +210,9 @@ def __init__(self, ns_) : 'auth' : fields.Nested( ns_.model('User_authorizations', user_auth_out ) ), - 'preferences': fields.Nested( - ns_.model('User_preferences', user_preferences_out ) - ), + # 'preferences': fields.Nested( + # ns_.model('User_preferences', user_preferences_out ) + # ), }) diff --git a/solidata_api/_serializers/_choices_licences.py b/solidata_api/_serializers/_choices_licences.py new file mode 100644 index 0000000..7257dbe --- /dev/null +++ b/solidata_api/_serializers/_choices_licences.py @@ -0,0 +1,16 @@ +# -*- encoding: utf-8 -*- + +""" +_choices_licences.py +- all choices related to licences UX +""" +# from copy import copy, deepcopy + +from log_config import log, pformat + +log.debug("... loading _choices_licences.py ...") + + +licences_options = [ + "MIT", "GNU", "OGBL" # ... +] \ No newline at end of file diff --git a/solidata_api/_serializers/_choices_user.py b/solidata_api/_serializers/_choices_user.py index 033d171..5d4fc82 100644 --- a/solidata_api/_serializers/_choices_user.py +++ b/solidata_api/_serializers/_choices_user.py @@ -11,16 +11,14 @@ log.debug("... loading _choices_user.py ...") -### TO DO : MULTI LANGUAGE FOR ALL CHOICES - ### + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ### ### CHOICES ONLY FOR ADMIN ### + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ### user_roles = [ "admin", - "staff", - "collective", + "staff", ### can edit all datamodels : dmf + dmt + # "collective", "registred", "guest", "anonymous" @@ -32,10 +30,12 @@ '12345' ] -user_actions = [ - "can_edit_dm", +user_actions_proj = [ + "can_edit_prj", + "can_edit_dmt", + "can_edit_dmf", "can_edit_dsi", - "can_edit_dc", + # "can_edit_dc", "can_edit_rec", "can_only_view" ] diff --git a/solidata_api/_serializers/schema_generic.py b/solidata_api/_serializers/schema_generic.py index 63c538e..f48cd31 100644 --- a/solidata_api/_serializers/schema_generic.py +++ b/solidata_api/_serializers/schema_generic.py @@ -12,7 +12,7 @@ log.debug("... loading schema_generic.py ...") - +from ._choices_licences import * ### generic info for updates generic_data = fields.String( @@ -41,19 +41,79 @@ licence = fields.String( description = "licence of the document", attribute = "licence", - example = "my-licence", - default = 'licence', + example = "MIT", + default = 'MIT', + enum = licences_options, required = True, ) + + +### object ids oid = fields.String( description = "oid of a document", attribute = "oid", example = "5b461ed90a82867e7b114f44", required = True, ) +oid_usr = fields.String( + description = "oid of an user", + attribute = "oid_usr", + example = "5b461ed90a82867e7b114f44", + required = True, + ) +oid_prj = fields.String( + description = "oid of a project", + attribute = "oid_proj", + example = "5b461ed90a82867e7b114f44", + required = True, + ) +oid_dmf = fields.String( + description = "oid of a datamodel field", + attribute = "oid_dm_f", + example = "5b461ed90a82867e7b114f44", + required = True, + ) +oid_dmt = fields.String( + description = "oid of a datamodel template", + attribute = "oid_dm_t", + example = "5b461ed90a82867e7b114f44", + required = True, + ) +oid_dsi = fields.String( + description = "oid of a dataset input", + attribute = "oid_ds_i", + example = "5b461ed90a82867e7b114f44", + required = True, + ) +oid_dso = fields.String( + description = "oid of a dataset output", + attribute = "oid_ds_o", + example = "5b461ed90a82867e7b114f44", + required = True, + ) +oid_rec = fields.String( + description = "oid of a recipe", + attribute = "oid_rec", + example = "5b461ed90a82867e7b114f44", + required = True, + ) + +oid_dict = { + "oid" : { "field" : oid , "fullname" : "oid" } , + "usr" : { "field" : oid_usr , "fullname" : "user" } , + "prj" : { "field" : oid_prj , "fullname" : "project" } , + "dmt" : { "field" : oid_dmt , "fullname" : "datamodel_template" } , + "dmf" : { "field" : oid_dmf , "fullname" : "datamodel_field" } , + "dsi" : { "field" : oid_dsi , "fullname" : "dataset_input" } , + "rec" : { "field" : oid_rec , "fullname" : "recipe" } , + "dso" : { "field" : oid_dso , "fullname" : "dataset_output" } , +} + +doc_categ_list = [ "usr", "prj", "dmt", "dmf", "dsi", "rec", "dso" ] doc_categ = fields.String( - description = "category of a document : usr, dm_t, dm_p, dsi, cd, rec ...", + description = "category of a document", attribute = "doc_categ", + enum = doc_categ_list, example = "usr", default = 'usr', required = True, diff --git a/solidata_api/_serializers/schema_logs.py b/solidata_api/_serializers/schema_logs.py index 7da4b73..5180949 100644 --- a/solidata_api/_serializers/schema_logs.py +++ b/solidata_api/_serializers/schema_logs.py @@ -47,6 +47,16 @@ attribute = "modif_val" , required = False, ) +added_at = fields.DateTime( + description = "date of addition", + attribute = "added_at" , + required = True, + ) +# added_by = fields.String( +# description = "added by an user", +# attribute = "added_by" , +# required = True, +# ) ### FOR GENERIC MODELS modification = { @@ -58,12 +68,12 @@ "modif_at" : modified_at, "modif_for" : modified_for, # "modif_by" : modified_by - "modif_by" : oid + "modif_by" : oid_usr } modification_full = { "modif_at" : modified_at, "modif_for" : modified_for, - "modif_by" : oid, + "modif_by" : oid_usr, "modif_val" : modified_val, } \ No newline at end of file diff --git a/solidata_api/_serializers/schema_users.py b/solidata_api/_serializers/schema_users.py index d2b5aa7..003ad74 100644 --- a/solidata_api/_serializers/schema_users.py +++ b/solidata_api/_serializers/schema_users.py @@ -96,7 +96,8 @@ ) edit_auth = fields.List( fields.String( - description = "edit auth of an user" + description = "edit auth of an user", + enum = user_actions_proj, ), attribute = "edit_auth", default = [] @@ -109,104 +110,47 @@ attribute = "lang", default = "en", ) -fav_list = fields.List( - fields.String( - description = "ids of the favorites projects created by the user" - ), - attribute = "fav_list", - default = [] +# fav_list = fields.List( +# fields.String( +# description = "ids of the favorites projects created by the user" +# ), +# attribute = "fav_list", +# default = [] +# ) +is_fav = fields.Boolean( + description = "is the document a favorite ?", + attribute = "is_fav", + example = False, + required = True, + default = False, ) ### profesional infos -structures = fields.List( - fields.String( +structure = fields.String( description = "structures / organisations the user" - ), - example = ["my structure A", "my structure B"], - attribute = "struct", - default = [] - ) -struct_profiles = fields.List( - fields.String( + ) + # example = ["my structure A", "my structure B"], + # attribute = "struct", + # default = [] +struct_profile = fields.String( description = "structures / organisations profile", example = "public_state", enum = user_structure, - ), - attribute = "struct_profiles", - default = [] - ) -profiles = fields.List( - fields.String( + ) + # attribute = "struct_profiles", + # default = [] +usr_profile = fields.String( description = "profiles of the user", - enum = user_structure, - ), + enum = user_profiles, + ) +usr_profiles = fields.List( + usr_profile, # enum = user_profiles, example = ["organizer"], attribute = "profiles", default = [] ) -### datasets infos -proj_list = fields.List( - oid, - description = "ids of the projects created by the user", - attribute = "proj_list", - default = [] - ) -dm_t_list = fields.List( - oid, - description = "ids of the datamodels templates created by the user", - attribute = "dm_t_list", - default = [] - ) -dm_p_list = fields.List( - oid, - description = "ids of the datamodels parts created by the user", - attribute = "dm_p_list", - default = [] - ) -ds_i_list = fields.List( - oid, - description = "ids of the datasets_in imported by the user", - attribute = "ds_i_list", - default = [] - ) -# dso_list = fields.List( -# oid, -# description = "ids of the datasets_out exported by the user", -# attribute = "dso_list", -# default = [] -# ) -dc_list = fields.List( - oid, - attribute = "dc_list", - description = "ids of the correspondance_dicts created by the user", - default = [] - ) -rec_list = fields.List( - oid, - description = "ids of the recipes created by the user", - attribute = "rec_list", - default = [] - ) - -### USER LOG -# created_at = fields.DateTime( -# description = "creation date", -# attribute = "created_at" , -# required = False, -# ) -# modified_at = fields.DateTime( -# description = "modification date", -# attribute = "modif_at" , -# required = False, -# ) -# modified_for = fields.String( -# description = "modification action", -# attribute = "modif_for" , -# required = False, -# ) - ### FOR GENERIC MODELS user_data = { @@ -243,15 +187,6 @@ "old_refresh_token" : old_refr_tok, } -# user_log = { -# "created_at" : created_at, -# # "modified_log" : modified_log -# } -# modification = { -# "modif_at" : modified_at, -# "modif_for" : modified_for -# } - ### FOR MODELS TO INSERT IN DB user_auth_in = { @@ -263,27 +198,19 @@ "blklst_usr" : blacklisted_usr, } -user_datasets_in = { - "proj_list" : proj_list, - "dm_t_list" : dm_t_list, - "dm_p_list" : dm_p_list, - "ds_i_list" : ds_i_list, - # "ds_o_list" : dso_list, - "dc_list" : dc_list, - "rec_list" : rec_list, -} -user_preferences_in = { - "lang" : language, - # "fav_list" : fav_list -} +# user_preferences_in = { +# "lang" : language, +# # "fav_list" : fav_list +# } -user_professional_in = { - "struct" : structures, - "struct_profiles" : struct_profiles, -} +# user_professional_in = { +# "struct" : structure, +# "struct_profiles" : struct_profile, +# } -user_profiles = { - "profiles" : profiles, +usr_profile_ = { + "lang" : language, + "usr_profiles" : usr_profiles, } ### FOR MODELS TO EXPORT OUT OF DB @@ -294,22 +221,12 @@ # "acc_tok" : acc_tok, } -user_datasets_out = { - "projects" : proj_list, - "datamodels_templates" : dm_t_list, - "datamodels_parts" : dm_p_list, - "datasets_inputs" : ds_i_list, - # "datasets_outputs" : dso_list, - "correspondance_dicts" : dc_list, - "recipes" : rec_list, -} - -user_preferences_out = { - "language" : language, - # "favorites" : fav_list -} +# user_preferences_out = { +# "language" : language, +# # "favorites" : fav_list +# } -user_professional_out = { - "structures" : structures, - "structures_profiles" : struct_profiles, -} +# user_professional_out = { +# "structures" : structures, +# "structures_profiles" : struct_profiles, +# } diff --git a/solidata_api/application.py b/solidata_api/application.py index 349f15f..d556c7a 100644 --- a/solidata_api/application.py +++ b/solidata_api/application.py @@ -99,10 +99,17 @@ def create_app( app_name='SOLIDATA_API', run_mode="dev" ): # access mongodb collections from solidata_api._core.queries_db import ( db, - mongo_users,mongo_licences,mongo_projects,mongo_datamodels, - mongo_datamodels_fields,mongo_connectors, - mongo_datasets_inputs,mongo_datasets_outputs, - mongo_recipes,mongo_corr_dicts + mongo_users, + mongo_projects, + mongo_datamodels_templates, + mongo_datamodels_fields, + # mongo_connectors, ### all cd are treated as ds_i + mongo_datasets_inputs, + mongo_datasets_outputs, + mongo_recipes, + mongo_jwt_blacklist, + # mongo_licences, + # mongo_corr_dicts ### all cd are treated as ds_i ) # import token required @@ -136,9 +143,6 @@ def create_app( app_name='SOLIDATA_API', run_mode="dev" ): # from solidata_api.api.api_datasets_in import blueprint as api_dsi # app.register_blueprint( api_dsi, url_prefix='/api/datasets_input') - # from solidata_api.api.api_corr_dicts import blueprint as api_dc - # app.register_blueprint( api_dc, url_prefix='/api/correspondance_dicts') - # from solidata_api.api.api_datasets_out import blueprint as api_dso # app.register_blueprint( api_dso, url_prefix='/api/datasets_output') diff --git a/solidata_api/config.py b/solidata_api/config.py index 7eca90d..fa44755 100644 --- a/solidata_api/config.py +++ b/solidata_api/config.py @@ -50,17 +50,17 @@ class BaseConfig(object): MONGO_DBNAME = 'solidata' MONGO_URI = 'mongodb://localhost:27017/solidata' # collections - MONGO_COLL_USERS = "users" - MONGO_COLL_LICENCES = "licences" - MONGO_COLL_PROJECTS = "projects" - MONGO_COLL_DATAMODELS = "datamodels" - MONGO_COLL_DATAMODELS_FIELDS = "datamodels_fields" - MONGO_COLL_CONNECTORS = "connectors" - MONGO_COLL_DATASETS_INPUTS = "datasets_inputs" - MONGO_COLL_DATASETS_OUTPUTS = "datasets_outputs" - MONGO_COLL_RECIPES = "recipes" - MONGO_COLL_CORR_DICTS = "corr_dicts" - MONGO_COLL_JWT_BLACKLIST = "jwt_blacklist" + MONGO_COLL_USERS = "users" + MONGO_COLL_LICENCES = "licences" + MONGO_COLL_PROJECTS = "projects" + MONGO_COLL_DATAMODELS_TEMPLATES = "datamodels_templates" + MONGO_COLL_DATAMODELS_FIELDS = "datamodels_fields" + # MONGO_COLL_CONNECTORS = "connectors" + MONGO_COLL_DATASETS_INPUTS = "datasets_inputs" + MONGO_COLL_DATASETS_OUTPUTS = "datasets_outputs" + MONGO_COLL_RECIPES = "recipes" + # MONGO_COLL_CORR_DICTS = "corr_dicts" + MONGO_COLL_JWT_BLACKLIST = "jwt_blacklist" """ EMAILING """ # email server