From 43353c426dba9f33bee112f667aaecffb3af53aa Mon Sep 17 00:00:00 2001 From: Theo Pascoli Date: Thu, 28 Nov 2024 18:09:29 +0100 Subject: [PATCH] feat: change model logic for update endpoint --- antarest/study/business/link_management.py | 4 ++-- antarest/study/business/model/link_model.py | 4 ++-- antarest/study/service.py | 4 ++-- antarest/study/web/study_data_blueprint.py | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/antarest/study/business/link_management.py b/antarest/study/business/link_management.py index 7314934692..777ce3cd9e 100644 --- a/antarest/study/business/link_management.py +++ b/antarest/study/business/link_management.py @@ -18,7 +18,7 @@ from antarest.core.exceptions import ConfigFileNotFound, LinkNotFound, LinkValidationError from antarest.core.model import JSON from antarest.study.business.all_optional_meta import all_optional_model, camel_case_model -from antarest.study.business.model.link_model import LinkBaseDto, LinkDTO, LinkInternal +from antarest.study.business.model.link_model import LinkBaseDTO, LinkDTO, LinkInternal from antarest.study.business.utils import execute_or_add_commands from antarest.study.model import RawStudy, Study from antarest.study.storage.rawstudy.model.filesystem.config.links import LinkProperties @@ -79,7 +79,7 @@ def create_link(self, study: Study, link_creation_dto: LinkDTO) -> LinkDTO: return link_creation_dto - def update_link(self, study: RawStudy, area_from: str, area_to: str, link_update_dto: LinkBaseDto) -> LinkDTO: + def update_link(self, study: RawStudy, area_from: str, area_to: str, link_update_dto: LinkBaseDTO) -> LinkDTO: link_dto = LinkDTO(area1=area_from, area2=area_to, **link_update_dto.model_dump()) link = link_dto.to_internal(StudyVersion.parse(study.version)) diff --git a/antarest/study/business/model/link_model.py b/antarest/study/business/model/link_model.py index 9038270d32..977ce69ee3 100644 --- a/antarest/study/business/model/link_model.py +++ b/antarest/study/business/model/link_model.py @@ -36,7 +36,7 @@ ] -class LinkBaseDto(AntaresBaseModel): +class LinkBaseDTO(AntaresBaseModel): model_config = ConfigDict(alias_generator=to_camel_case, populate_by_name=True, extra="forbid") hurdles_cost: bool = False @@ -68,7 +68,7 @@ def validate_areas(self) -> t.Self: return self -class LinkDTO(Area, LinkBaseDto): +class LinkDTO(Area, LinkBaseDTO): def to_internal(self, version: StudyVersion) -> "LinkInternal": if version < STUDY_VERSION_8_2 and {"filter_synthesis", "filter_year_by_year"} & self.model_fields_set: raise LinkValidationError("Cannot specify a filter value for study's version earlier than v8.2") diff --git a/antarest/study/service.py b/antarest/study/service.py index f0d5074624..386173b788 100644 --- a/antarest/study/service.py +++ b/antarest/study/service.py @@ -89,7 +89,7 @@ from antarest.study.business.general_management import GeneralManager from antarest.study.business.link_management import LinkManager from antarest.study.business.matrix_management import MatrixManager, MatrixManagerError -from antarest.study.business.model.link_model import LinkBaseDto, LinkDTO +from antarest.study.business.model.link_model import LinkBaseDTO, LinkDTO from antarest.study.business.optimization_management import OptimizationManager from antarest.study.business.playlist_management import PlaylistManager from antarest.study.business.scenario_builder_management import ScenarioBuilderManager @@ -1910,7 +1910,7 @@ def update_link( uuid: str, area_from: str, area_to: str, - link_update_dto: LinkBaseDto, + link_update_dto: LinkBaseDTO, params: RequestParameters, ) -> LinkDTO: study = self.get_study(uuid) diff --git a/antarest/study/web/study_data_blueprint.py b/antarest/study/web/study_data_blueprint.py index 1ea06a82c3..9f267df774 100644 --- a/antarest/study/web/study_data_blueprint.py +++ b/antarest/study/web/study_data_blueprint.py @@ -68,7 +68,7 @@ ) from antarest.study.business.district_manager import DistrictCreationDTO, DistrictInfoDTO, DistrictUpdateDTO from antarest.study.business.general_management import GeneralFormFields -from antarest.study.business.model.link_model import LinkBaseDto, LinkDTO +from antarest.study.business.model.link_model import LinkBaseDTO, LinkDTO from antarest.study.business.optimization_management import OptimizationFormFields from antarest.study.business.playlist_management import PlaylistColumns from antarest.study.business.scenario_builder_management import Rulesets, ScenarioType @@ -207,7 +207,7 @@ def update_link( uuid: str, area_from: str, area_to: str, - link_update_dto: LinkBaseDto, + link_update_dto: LinkBaseDTO, current_user: JWTUser = Depends(auth.get_current_user), ) -> t.Any: logger.info(