@@ -93,7 +93,7 @@ def update_mviewer_config(id) -> Response:
93
93
# get config as class model data
94
94
config_data = config .as_data ()
95
95
# clean preview space if not empty
96
- clean_preview (current_app , config_data .id )
96
+ clean_preview (current_app , config_data .url )
97
97
98
98
current_config = current_app .register .read_json (config_data .id )
99
99
@@ -139,7 +139,7 @@ def publish_mviewer_config(id) -> Response:
139
139
if not publish_dir or not path .exists (publish_dir ):
140
140
return BadRequest ("Publish directory does not exists !" )
141
141
142
- workspace = path .join (current_app .config ["EXPORT_CONF_FOLDER" ], id )
142
+ workspace = path .join (current_app .config ["EXPORT_CONF_FOLDER" ], current_user . organisation , id )
143
143
144
144
if not path .exists (workspace ):
145
145
return BadRequest ("Application does not exists !" )
@@ -197,7 +197,7 @@ def delete_config_workspace(id = None) -> Response:
197
197
raise BadRequest ("Empty list : no value to delete !" )
198
198
199
199
logger .debug ("START DELETE CONFIG : %s" % id )
200
- workspace = path .join (current_app .config ["EXPORT_CONF_FOLDER" ], id )
200
+ workspace = path .join (current_app .config ["EXPORT_CONF_FOLDER" ], current_user . organisation , id )
201
201
# update json
202
202
config = current_app .register .read_json (id )
203
203
if not config or not path .exists (workspace ):
@@ -233,7 +233,8 @@ def get_all_app_versions(id) -> Response:
233
233
if not config :
234
234
raise BadRequest ("This config doesn't exists !" )
235
235
config = config [0 ]
236
- workspace = path .join (current_app .config ["EXPORT_CONF_FOLDER" ], config ["id" ])
236
+ org = current_user .organisation if current_user else current_app .config ["DEFAULT_ORG" ]
237
+ workspace = path .join (current_app .config ["EXPORT_CONF_FOLDER" ], org , config ["id" ])
237
238
git = Git_manager (workspace )
238
239
versions = git .get_versions ()
239
240
return jsonify ({"versions" : versions , "config" : config })
@@ -258,13 +259,13 @@ def switch_app_version(id, version="1") -> Response:
258
259
if not config :
259
260
raise BadRequest ("This config doesn't exists !" )
260
261
config = config [0 ]
261
- workspace = path .join (current_app .config ["EXPORT_CONF_FOLDER" ], config ["id" ])
262
+ workspace = path .join (current_app .config ["EXPORT_CONF_FOLDER" ], current_user . organisation , config ["id" ])
262
263
git = Git_manager (workspace )
263
264
git .switch_version (version , as_new )
264
265
# Update register
265
266
current_app .register .update_from_id (config ["id" ])
266
267
# clean previews
267
- clean_preview (current_app , config ["id " ])
268
+ clean_preview (current_app , config ["url " ])
268
269
return (
269
270
jsonify (
270
271
{
@@ -293,14 +294,14 @@ def preview_app_version(id, version) -> Response:
293
294
# create preview space
294
295
config = config [0 ]
295
296
init_preview (current_app , config ["id" ])
296
- workspace = path .join (current_app .config ["EXPORT_CONF_FOLDER" ], config ["id" ])
297
+ workspace = path .join (current_app .config ["EXPORT_CONF_FOLDER" ], current_user . organisation , config ["id" ])
297
298
git = Git_manager (workspace )
298
299
git .switch_version (version , False )
299
300
# copy past file to preview folder
300
301
app_config = current_app .config
301
302
src_file = app_config ["EXPORT_CONF_FOLDER" ] + config ["url" ]
302
303
preview_file = path .join (config ["id" ], "preview" , "%s.xml" % version )
303
- path_preview_file = path .join (app_config ["EXPORT_CONF_FOLDER" ], preview_file )
304
+ path_preview_file = path .join (app_config ["EXPORT_CONF_FOLDER" ], config [ "organisation" ], preview_file )
304
305
copyfile (src_file , path_preview_file )
305
306
# restor branch
306
307
git .repo .git .checkout ("master" )
@@ -309,7 +310,7 @@ def preview_app_version(id, version) -> Response:
309
310
jsonify (
310
311
{
311
312
"success" : True ,
312
- "file" : path .join (app_config ["CONF_PATH_FROM_MVIEWER" ], preview_file ),
313
+ "file" : path .join (app_config ["CONF_PATH_FROM_MVIEWER" ], config [ "organisation" ], preview_file ),
313
314
}
314
315
),
315
316
200 ,
@@ -336,8 +337,8 @@ def preview_uncommited_app(id) -> Response:
336
337
# get file name and path
337
338
file_name = uuid .uuid1 ()
338
339
preview_file = path .join (id , "preview" , "%s.xml" % file_name )
339
- system_path = path .join (app_config ["EXPORT_CONF_FOLDER" ], preview_file )
340
-
340
+ system_path = path .join (app_config ["EXPORT_CONF_FOLDER" ], current_user . organisation , preview_file )
341
+ clean_preview ( current_app , path . join ( current_user . organisation , id ))
341
342
# store file to preview folder
342
343
with open (system_path , "w" ) as file :
343
344
file .write (xml )
@@ -347,7 +348,7 @@ def preview_uncommited_app(id) -> Response:
347
348
jsonify (
348
349
{
349
350
"success" : True ,
350
- "file" : path .join (app_config ["CONF_PATH_FROM_MVIEWER" ], preview_file ),
351
+ "file" : path .join (app_config ["CONF_PATH_FROM_MVIEWER" ], current_user . organisation , preview_file ),
351
352
}
352
353
),
353
354
200 ,
0 commit comments