Skip to content

Commit

Permalink
feat: change model logic for update endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoPascoli committed Nov 28, 2024
1 parent 841ea41 commit 43353c4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions antarest/study/business/link_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions antarest/study/business/model/link_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions antarest/study/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions antarest/study/web/study_data_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 43353c4

Please sign in to comment.