mirror of
https://github.com/cssgunc/compass.git
synced 2025-04-06 20:50:17 -04:00
resource, resource_tag to/from models and programtype enum
This commit is contained in:
parent
f96beee4b2
commit
9cd703d29f
0
backend/entities/programtype_enum.py
Normal file
0
backend/entities/programtype_enum.py
Normal file
|
@ -33,6 +33,36 @@ class ResourceEntity(EntityBase):
|
|||
#relationships
|
||||
resourceTags: Mapped[list["ResourceTagEntity"]] = relationship(back_populates="resource", cascade="all,delete")
|
||||
|
||||
@classmethod
|
||||
def from_model(cls, model: user_model) -> Self:
|
||||
"""
|
||||
Create a UserEntity from a User model.
|
||||
|
||||
Args:
|
||||
model (User): The model to create the entity from.
|
||||
|
||||
Returns:
|
||||
Self: The entity (not yet persisted).
|
||||
"""
|
||||
|
||||
return cls (
|
||||
id = model.id
|
||||
created_at = model.created_at
|
||||
name = model.name
|
||||
summary = model.summary
|
||||
link = model.link
|
||||
program = model.program
|
||||
)
|
||||
|
||||
def to_model(self) -> user_model:
|
||||
return user_model (
|
||||
id = self.id
|
||||
created_at = self.created_at
|
||||
name = self.name
|
||||
summary = self.summary
|
||||
link = self.link
|
||||
program = self.program
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user