-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(link): add update endpoint for link #2175
Changes from 176 commits
3663b60
d9bac0e
55a245b
23027df
4150708
caa9cb8
b491c80
130d76c
2d2027b
5cc7cea
f3a9464
0cf0ff5
d6ecfb1
e3e2158
2c37fff
e03678a
2f17d71
22e2eda
26cdb3a
76188de
9dff527
cac1349
d9716e3
0a540b1
40cb85b
0d17337
827fef2
1e7004f
3eb93dd
a04fbe2
ca0898f
30cf961
6a79ad6
b6c0053
a047c30
60c0c52
d520b83
40c42d0
0c002d9
26d382e
c7728db
779dc39
6ff5520
3853e45
05e4ddf
647dfbd
39f81f6
e057c4b
1355def
c07e789
8b4ad08
18f2d77
b6359ff
ede7b3e
3a6a7c8
fcace50
0f4d6e0
d81eda0
ece5f0e
a4d0cd7
4d5c8ea
06faa3e
7bd5059
5ca372c
c4772db
833a742
213a1b4
d4c0830
a56337c
fe6b602
aec9e97
7a842d6
77f3195
b429307
716e8ad
7ac2915
da97885
650bc59
1543472
b219b0f
a0c400d
229167a
2bdaa94
70de778
b40ccf2
506043d
a7e4d21
d96779f
9e4ebfc
f7468cf
f7ef6c6
4852a43
4a8ebd6
3e361b3
90fcc21
419975e
117887e
fe34e97
a11c7c7
6d0814b
eb366de
dea6710
0ff40b9
b8a52e4
4ef3682
65f1a8f
53bf23c
870dbaf
78ea2ae
a0c864d
a272fd4
3f4cb36
99c7d63
d6a5d14
13f5a60
be9450e
72f79e2
e611ad0
03570f5
482ceca
c33c195
c41b98b
e7b9b72
4ccf715
c96644b
3f67891
38a1eb0
a9e64a5
5a1d565
2b50f1a
42e7ca7
a5d827f
3bf3651
e5c7bc6
0a23a8c
c474e35
53ec94a
3e73279
443105b
40e190c
b790b0a
7a77cb6
8d2d34c
f795199
2d07e21
b6f317e
e6c3a3e
913178e
78481bd
738683f
f93ad5f
f0717ee
204d67b
8a7a8e4
eefd391
12493cd
1fc139e
0095873
abf0bbf
cf23fc1
a7d46c8
92357e7
d31e7ab
658d249
2d3d49c
c5be5ee
38f980e
0b121d4
0cd2034
f12c921
8d669c2
306f85b
d4b4716
cb303b5
729ecee
c9077e9
841ea41
43353c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
|
||
from antares.study.version import StudyVersion | ||
from pydantic import ConfigDict, Field, model_validator | ||
from pydantic.json_schema import SkipJsonSchema | ||
|
||
from antarest.core.exceptions import LinkValidationError | ||
from antarest.core.serialization import AntaresBaseModel | ||
|
@@ -44,11 +45,18 @@ class Area(AntaresBaseModel): | |
def validate_areas(self) -> t.Self: | ||
if self.area1 == self.area2: | ||
raise LinkValidationError(f"Cannot create a link that goes from and to the same single area: {self.area1}") | ||
area_from, area_to = sorted([self.area1, self.area2]) | ||
self.area1 = area_from | ||
self.area2 = area_to | ||
return self | ||
|
||
|
||
class LinkDTO(Area): | ||
model_config = ConfigDict(alias_generator=to_camel_case, populate_by_name=True, extra="forbid") | ||
model_config = ConfigDict( | ||
alias_generator=to_camel_case, | ||
populate_by_name=True, | ||
extra="forbid", | ||
) | ||
|
||
hurdles_cost: bool = False | ||
loop_flow: bool = False | ||
|
@@ -78,6 +86,11 @@ def to_internal(self, version: StudyVersion) -> "LinkInternal": | |
return LinkInternal(**data) | ||
|
||
|
||
class LinkDtoForUpdate(LinkDTO): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could be DTO instead of Dto to fit with existing class |
||
area1: SkipJsonSchema[str] = Field("a", exclude=True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Weird way to do it. Why did you introduce fields There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After testing this allows user to specfiy area1 and area2 inside the body and they we'll be ignored. I don't think we want that. I'd prefer you introduce a class that just has the base attributes and make LinkDTO inherit from this :/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed it |
||
area2: SkipJsonSchema[str] = Field("b", exclude=True) | ||
|
||
|
||
class LinkInternal(AntaresBaseModel): | ||
model_config = ConfigDict(alias_generator=to_kebab_case, populate_by_name=True, extra="forbid") | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be in one line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed