Skip to content

Commit 93b11e9

Browse files
committed
EM Review fixes
1 parent d067cf3 commit 93b11e9

3 files changed

Lines changed: 21 additions & 18 deletions

File tree

File renamed without changes.

genesis_core/elements/dm/models.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@
3535
LOG = logging.getLogger(__name__)
3636

3737

38-
class Status(enum.Enum):
38+
class Status(str, enum.Enum):
3939
NEW = "NEW"
4040
IN_PROGRESS = "IN_PROGRESS"
4141
ACTIVE = "ACTIVE"
4242

4343

44-
class AlwaysActiveStatus(enum.Enum):
44+
class AlwaysActiveStatus(str, enum.Enum):
4545
ACTIVE = "ACTIVE"
4646

4747

48-
class InstallTypes(enum.Enum):
48+
class InstallTypes(str, enum.Enum):
4949
MANUAL = "MANUAL"
5050
AUTO_AS_DEPENDENCY = "AUTO_AS_DEPENDENCY"
5151

@@ -61,8 +61,8 @@ class Manifest(
6161
STATUS = AlwaysActiveStatus
6262

6363
status = properties.property(
64-
ra_types.Enum([s.value for s in Status]),
65-
default=STATUS.ACTIVE.value,
64+
ra_types.Enum([s for s in Status]),
65+
default=STATUS.ACTIVE,
6666
)
6767
version = properties.property(
6868
ra_types.String(min_length=5, max_length=64),
@@ -146,8 +146,8 @@ class Element(
146146
INSTALL_TYPES = InstallTypes
147147

148148
status = properties.property(
149-
ra_types.Enum([s.value for s in STATUSES]),
150-
default=STATUSES.NEW.value,
149+
ra_types.Enum([s for s in STATUSES]),
150+
default=STATUSES.NEW,
151151
)
152152

153153
version = properties.property(
@@ -156,8 +156,8 @@ class Element(
156156
)
157157

158158
install_type = properties.property(
159-
ra_types.Enum([s.value for s in INSTALL_TYPES]),
160-
default=INSTALL_TYPES.MANUAL.value,
159+
ra_types.Enum([s for s in INSTALL_TYPES]),
160+
default=INSTALL_TYPES.MANUAL,
161161
)
162162

163163
@property
@@ -210,11 +210,11 @@ class ElementIncorrectStatusesView(
210210
read_only=True,
211211
)
212212
api_status = properties.property(
213-
ra_types.Enum([s.value for s in Status]),
213+
ra_types.Enum([s for s in Status]),
214214
read_only=True,
215215
)
216216
actual_status = properties.property(
217-
ra_types.Enum([s.value for s in Status]),
217+
ra_types.Enum([s for s in Status]),
218218
read_only=True,
219219
)
220220

@@ -250,12 +250,12 @@ class Requirement(
250250
required=True,
251251
)
252252
from_version = properties.property(
253-
ra_types.String(min_length=5, max_length=64),
254-
required=True,
253+
ra_types.AllowNone(ra_types.String(min_length=5, max_length=64)),
254+
default=None,
255255
)
256256
to_version = properties.property(
257-
ra_types.String(min_length=5, max_length=64),
258-
required=True,
257+
ra_types.AllowNone(ra_types.String(min_length=5, max_length=64)),
258+
default=None,
259259
)
260260

261261

@@ -289,7 +289,7 @@ class Resource(
289289
)
290290
status = properties.property(
291291
ra_types.Enum(Status),
292-
default=Status.NEW.value,
292+
default=Status.NEW,
293293
)
294294
resource_link_prefix = properties.property(
295295
ra_types.String(min_length=1, max_length=256),
@@ -531,7 +531,7 @@ class ResourceIncorrectStatusesView(
531531

532532
def actualize_status(self, session):
533533
new_status = Status.NEW
534-
if self.actual_status == Status.ACTIVE.value:
534+
if self.actual_status == Status.ACTIVE:
535535
new_status = Status.ACTIVE
536536
elif self.actual_status is not None:
537537
new_status = Status.IN_PROGRESS

migrations/0018-add-elements-76bca4.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@ def upgrade(self, session):
115115
)
116116
),
117117
"created_at" TIMESTAMP(6) NOT NULL DEFAULT NOW(),
118-
"updated_at" TIMESTAMP(6) NOT NULL DEFAULT NOW()
118+
"updated_at" TIMESTAMP(6) NOT NULL DEFAULT NOW(),
119+
CONSTRAINT unique_em_elements_name_version_idx UNIQUE (
120+
name, version
121+
)
119122
);
120123
""",
121124
"""

0 commit comments

Comments
 (0)