[Feature] Implement legacy endpoints to enable copy via python client (#400)

Co-authored-by: Tim Lorsbach <tim@lorsba.ch>
Reviewed-on: enviPath/enviPy#400
This commit is contained in:
2026-05-28 01:41:28 +12:00
parent 674e10c7fa
commit c7c7e17e43
2 changed files with 75 additions and 21 deletions

View File

@ -4492,18 +4492,22 @@ class AdditionalInformation(models.Model):
return f"{self.scenario.url}/additional-information/{self.uuid}"
def get(self) -> "EnviPyModel":
@staticmethod
def from_dict(ai_type: str, ai_data: Dict[str, Any]):
from envipy_additional_information import registry
MAPPING = {c.__name__: c for c in registry.list_models().values()}
try:
inst = MAPPING[self.type](**self.data)
inst = MAPPING[ai_type](**ai_data)
except Exception as e:
print(f"Error loading {self.type}: {e}")
print(f"Error loading {ai_type}: {e}")
raise e
inst.__dict__["uuid"] = str(self.uuid)
return inst
def get(self) -> "EnviPyModel":
inst = AdditionalInformation.from_dict(self.type, self.data)
inst.__dict__["uuid"] = str(self.uuid)
return inst
def __str__(self) -> str: