Skip to content

Commit

Permalink
99luftballoons
Browse files Browse the repository at this point in the history
  • Loading branch information
duboyal committed Apr 4, 2024
1 parent bc83a8e commit 71210d3
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions src/cript/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,23 @@ def api_prefix(self):
def api_version(self):
return self._api_version

def save(self, new_node: PrimaryBaseNode) -> None:
# NOTE: Needed to make it node agnostic
# _no_condense_uuid is either active or not
def save(self, new_node):
self._internal_save(new_node, _no_condense_uuid=True)
print("GET_ALI_HERE")
quit()
self._internal_save(new_node, _no_condense_uuid=False)

def _internal_save(self, new_node: PrimaryBaseNode, _no_condense_uuid: bool) -> None:
print("_no_condense_uuid")
print(_no_condense_uuid)

data = new_node.get_json(_no_condense_uuid=_no_condense_uuid).json

print("data")
print(data)
print("----------\\------------\n")

node_class_name = new_node.node_type.capitalize()
NodeClass = getattr(PrimaryNodes, node_class_name)

Expand All @@ -439,13 +454,20 @@ def save(self, new_node: PrimaryBaseNode) -> None:
# or else its a patch handled by previous node

if new_node.node_type.lower() == "project":
data = new_node.get_json().json
data = new_node.get_json(_no_condense_uuid=_no_condense_uuid).json

print("---- data -----")
print(data)
print("---- data end -----")
# if _no_condense_uuid is true do a POST if its false do a patch,
# but wouldnt we then just find the existing node above in the generator?
response = self._capsule_request(url_path="/project/", method="POST", data=data)
if response.status_code in [200, 201]:
return # Return here, since we successfully Posting
else: # debug
else: # debug for now
print("GET HERE ALI")
raise APIError
res = response.json()
raise Exception(f"APIError {res}")

old_project, old_uuid_map = load_nodes_from_json(nodes_json=old_node_json, _use_uuid_cache={})

Expand Down Expand Up @@ -500,7 +522,7 @@ def save(self, new_node: PrimaryBaseNode) -> None:
unlink_payload = {"uuid": str(uuid_)}
self._capsule_request(url_path=url_path, method="DELETE", data=json.dumps(unlink_payload))

################################################################################
################################################################################

def save_old(self, project: Project) -> None:
"""
Expand Down Expand Up @@ -533,7 +555,7 @@ def save_old(self, project: Project) -> None:
pass
raise exc from exc

def _internal_save(self, node, save_values: Optional[_InternalSaveValues] = None) -> _InternalSaveValues:
def _internal_save_old(self, node, save_values: Optional[_InternalSaveValues] = None) -> _InternalSaveValues:
"""
Internal helper function that handles the saving of different nodes (not just project).
Expand Down

0 comments on commit 71210d3

Please sign in to comment.