Skip to content

Commit cc962aa

Browse files
Merge branch 'master' into is7852/filter-autogenerated-api-keys
2 parents b377092 + 8d96382 commit cc962aa

File tree

4 files changed

+39
-20
lines changed

4 files changed

+39
-20
lines changed

services/static-webserver/client/source/class/osparc/data/model/Study.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -699,14 +699,12 @@ qx.Class.define("osparc.data.model.Study", {
699699
/**
700700
* Call patch Study, but the changes were already applied on the frontend
701701
* @param studyDiffs {Object} Diff Object coming from the JsonDiffPatch lib. Use only the keys, not the changes.
702-
* @param sourceStudy {Object} Study object that was used to apply the diffs on the frontend.
702+
* @param studySource {Object} Study object that was used to check the diffs on the frontend.
703703
*/
704-
patchStudyDelayed: function(studyDiffs, sourceStudy) {
704+
patchStudyDelayed: function(studyDiffs, studySource) {
705705
const promises = [];
706-
let workbenchDiffs = {};
707706
if ("workbench" in studyDiffs) {
708-
workbenchDiffs = studyDiffs["workbench"];
709-
promises.push(this.getWorkbench().patchWorkbenchDelayed(workbenchDiffs));
707+
promises.push(this.getWorkbench().patchWorkbenchDelayed(studyDiffs["workbench"], studySource["workbench"]));
710708
delete studyDiffs["workbench"];
711709
}
712710
const fieldKeys = Object.keys(studyDiffs);
@@ -731,7 +729,7 @@ qx.Class.define("osparc.data.model.Study", {
731729
}
732730
return Promise.all(promises)
733731
.then(() => {
734-
return sourceStudy;
732+
return studySource;
735733
});
736734
}
737735
}

services/static-webserver/client/source/class/osparc/data/model/Workbench.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -784,21 +784,26 @@ qx.Class.define("osparc.data.model.Workbench", {
784784
/**
785785
* Call patch Node, but the changes were already applied on the frontend
786786
* @param workbenchDiffs {Object} Diff Object coming from the JsonDiffPatch lib. Use only the keys, not the changes.
787+
* @param workbenchSource {Object} Workbench object that was used to check the diffs on the frontend.
787788
*/
788-
patchWorkbenchDelayed: function(workbenchDiffs) {
789+
patchWorkbenchDelayed: function(workbenchDiffs, workbenchSource) {
789790
const promises = [];
790791
Object.keys(workbenchDiffs).forEach(nodeId => {
791792
const node = this.getNode(nodeId);
792793
if (node === null) {
793794
// the node was removed
794795
return;
795796
}
797+
// use the node data that was used to check the diffs
798+
const nodeData = workbenchSource[nodeId];
799+
if (!nodeData) {
800+
// skip if nodeData is undefined or null
801+
return;
802+
}
796803

797-
const nodeData = node.serialize();
798804
let patchData = {};
799805
if (workbenchDiffs[nodeId] instanceof Array) {
800-
// if workbenchDiffs is an array means that the node was either added or removed
801-
// the node was added
806+
// if workbenchDiffs is an array means that the node was added
802807
patchData = nodeData;
803808
} else {
804809
// patch only what was changed

services/static-webserver/client/source/class/osparc/desktop/StudyEditor.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -858,20 +858,18 @@ qx.Class.define("osparc.desktop.StudyEditor", {
858858

859859
__getStudyDiffs: function() {
860860
const sourceStudy = this.getStudy().serialize();
861+
const studyDiffs = {
862+
sourceStudy,
863+
delta: {},
864+
}
861865
const delta = osparc.wrapper.JsonDiffPatch.getInstance().diff(this.__studyDataInBackend, sourceStudy);
862866
if (delta) {
863867
// lastChangeDate and creationDate should not be taken into account as data change
864868
delete delta["creationDate"];
865869
delete delta["lastChangeDate"];
866-
return {
867-
sourceStudy,
868-
delta,
869-
};
870+
studyDiffs.delta = delta;
870871
}
871-
return {
872-
sourceStudy,
873-
delta: {},
874-
};
872+
return studyDiffs;
875873
},
876874

877875
didStudyChange: function() {

services/web/server/src/simcore_service_webserver/projects/_crud_api_create.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
]
6363

6464

65-
log = logging.getLogger(__name__)
65+
_logger = logging.getLogger(__name__)
6666

6767
CopyFileCoro: TypeAlias = Coroutine[Any, Any, None]
6868
CopyProjectNodesCoro: TypeAlias = Coroutine[Any, Any, dict[NodeID, ProjectNodeCreate]]
@@ -285,6 +285,13 @@ async def create_project( # pylint: disable=too-many-arguments,too-many-branche
285285
286286
"""
287287
assert request.app # nosec
288+
_logger.info(
289+
"create_project for '%s' with %s %s %s",
290+
f"{user_id=}",
291+
f"{predefined_project=}",
292+
f"{product_name=}",
293+
f"{from_study=}",
294+
)
288295

289296
_projects_repository = ProjectDBAPI.get_from_app_context(request.app)
290297

@@ -459,6 +466,17 @@ async def create_project( # pylint: disable=too-many-arguments,too-many-branche
459466
for gid, access in workspace.access_rights.items()
460467
}
461468

469+
_project_product_name = await _projects_repository.get_project_product(
470+
project_uuid=new_project["uuid"]
471+
)
472+
assert (
473+
_project_product_name == product_name # nosec
474+
), "Project product name mismatch"
475+
if _project_product_name != product_name:
476+
raise web.HTTPBadRequest(
477+
text=f"Project product name mismatch {product_name=} {_project_product_name=}"
478+
)
479+
462480
data = ProjectGet.from_domain_model(new_project).model_dump(
463481
**RESPONSE_MODEL_POLICY
464482
)
@@ -488,7 +506,7 @@ async def create_project( # pylint: disable=too-many-arguments,too-many-branche
488506
raise web.HTTPNotFound(text=f"{exc}") from exc
489507

490508
except asyncio.CancelledError:
491-
log.warning(
509+
_logger.warning(
492510
"cancelled create_project for '%s'. Cleaning up",
493511
f"{user_id=}",
494512
)

0 commit comments

Comments
 (0)