Skip to content
Snippets Groups Projects
Commit 8738345d authored by Nathan Hertz's avatar Nathan Hertz
Browse files

Went back on my decision to use JSON-formatted strings instead of Python

dicts for request bodies; dicts play nicer with the front end, so I
reversed the changes I made before and changed everything to expect a
dict, not a string
parent 4d76178e
No related branches found
No related tags found
1 merge request!96WS-31: Submit capability request view
This commit is part of merge request !96. Comments created here will be created in the context of that merge request.
......@@ -120,22 +120,19 @@ class Capability(Base, CapabilityIF):
self.requests.append(request)
return request
def to_dict(self) -> Dict[str, str]:
return {
"name": self.name,
"max_jobs": self.max_jobs,
"steps": str(self.steps),
"enabled": self.enabled,
}
def __str__(self) -> str:
return (
f"Capability: {self.name}, max concurrent jobs of {self.max_jobs}"
f"\nSequence: {self.steps}"
)
def __json__(self) -> str:
return json.dumps(self.to_dict())
def __json__(self) -> Dict[str, str]:
return {
"name": self.name,
"max_jobs": self.max_jobs,
"steps": str(self.steps),
"enabled": self.enabled,
}
class CapabilityRequest(Base, CapabilityRequestIF):
......@@ -162,15 +159,13 @@ class CapabilityRequest(Base, CapabilityRequestIF):
def __str__(self):
return f"CapabilityRequest object: {self.__dict__}"
def __json__(self) -> str:
return json.dumps(
{
"id": self.id,
"capability_name": self.capability_name,
"state": self.state,
"parameters": self.parameters,
}
)
def __json__(self) -> Dict[str, str]:
return {
"id": self.id,
"capability_name": self.capability_name,
"state": self.state,
"parameters": self.parameters,
}
class CapabilityVersion(Base, CapabilityVersionIF):
......@@ -222,7 +217,7 @@ class CapabilityExecution(Base, CapabilityExecutionIF):
),
)
def __json__(self, request: CapabilityRequest) -> dict:
def __json__(self) -> dict:
return dict(
id=self.id,
state=self.state,
......
from __future__ import annotations
from typing import List
from typing import Dict, List
from workspaces.capability.helpers_interfaces import CapabilityStepIF, ParameterIF
from workspaces.products.schema_interfaces import FutureProductIF
......@@ -27,7 +27,7 @@ class CapabilityRequestIF:
future_products: str
versions: List[CapabilityVersionIF]
def __json__(self) -> str:
def __json__(self) -> Dict[str, str]:
raise NotImplementedError
......@@ -48,5 +48,5 @@ class CapabilityExecutionIF:
capability: CapabilityIF
capability_request: CapabilityRequestIF
def __json__(self, request: CapabilityRequestIF) -> dict:
def __json__(self) -> Dict[str, str]:
raise NotImplementedError
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment