generated from uw-ssec/project-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add checklists models and populate (#182)
- Loading branch information
Showing
15 changed files
with
279 additions
and
152 deletions.
There are no files selected for viewing
3 changes: 2 additions & 1 deletion
3
src/support_sphere_py/src/support_sphere/models/enums/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
from support_sphere.models.enums.app_permissions import AppPermissions | ||
from support_sphere.models.enums.app_roles import AppRoles | ||
from support_sphere.models.enums.operational_status import OperationalStatus | ||
from support_sphere.models.enums.priority import Priority | ||
|
||
|
||
__all__ = ['AppPermissions', 'AppRoles', 'OperationalStatus'] | ||
__all__ = ['AppPermissions', 'AppRoles', 'OperationalStatus', Priority] |
11 changes: 11 additions & 0 deletions
11
src/support_sphere_py/src/support_sphere/models/enums/priority.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from enum import Enum | ||
|
||
|
||
class Priority(Enum): | ||
LOW = ("low", "Low Priority") | ||
MEDIUM = ("medium", "Medium Priority") | ||
HIGH = ("high", "High Priority") | ||
|
||
def __init__(self, priority, description): | ||
self.priority = priority | ||
self.description = description |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/support_sphere_py/src/support_sphere/models/public/checklist.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import uuid | ||
import datetime | ||
from typing import Optional | ||
from sqlalchemy import Enum | ||
|
||
from support_sphere.models.base import BasePublicSchemaModel | ||
from support_sphere.models.enums import Priority | ||
from sqlmodel import Field, Relationship | ||
|
||
|
||
class Checklist(BasePublicSchemaModel, table=True): | ||
""" | ||
Represents a checklist entity in the 'public' schema under the 'checklists' table. | ||
This table defines different types of checklists, including the associated frequency. | ||
Attributes | ||
---------- | ||
id : uuid | ||
The unique identifier for the checklist. | ||
recurring_type_id : uuid | ||
The foreign key referring to the frequency. | ||
title : str | ||
The title of the checklist. | ||
description : str, optional | ||
A detailed description of the checklist. | ||
current_version : int | ||
The current version of this checklist. | ||
updated_at : datetime | ||
The timestamp for the last update of this checklist. | ||
frequency : Frequency, optional | ||
A relationship to the `Frequency` model. | ||
user_checklists : list[UserChecklists] | ||
A list of `UserChecklist` entities associated with this checklist. | ||
""" | ||
|
||
__tablename__ = "checklists" | ||
|
||
id: uuid.UUID = Field(default_factory=uuid.uuid4, primary_key=True) | ||
title: str | None = Field(nullable=False) | ||
description: str | None = Field(nullable=True) | ||
notes: str | None = Field(nullable=True) | ||
updated_at: datetime.datetime = Field( | ||
default_factory=lambda: datetime.datetime.now(datetime.UTC), | ||
nullable=False | ||
) | ||
priority: Priority = Field(default=Priority.LOW, sa_type=Enum(Priority, name="priority"), nullable=False) | ||
frequency_id: uuid.UUID | None = Field(foreign_key="public.frequency.id", nullable=True) | ||
|
||
frequency: Optional["Frequency"] = Relationship(back_populates="checklists", cascade_delete=False) | ||
user_checklists: list["UserChecklists"] = Relationship(back_populates="checklists", cascade_delete=False) | ||
checklist_steps_orders: list["ChecklistStepsOrder"] = Relationship(back_populates="checklists", cascade_delete=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/support_sphere_py/src/support_sphere/models/public/checklist_steps_state.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import uuid | ||
from typing import Optional | ||
import datetime | ||
|
||
from support_sphere.models.base import BasePublicSchemaModel | ||
from sqlmodel import Field, Relationship | ||
|
||
|
||
class ChecklistStepsState(BasePublicSchemaModel, table=True): | ||
""" | ||
Represents a template for checklist steps in the 'public' schema under the 'checklist_steps_templates' table. | ||
Attributes | ||
---------- | ||
id : uuid | ||
The unique identifier for the checklist step template. | ||
title : str | ||
The title of the checklist step template. | ||
description : str, optional | ||
A detailed description of the checklist step template. | ||
checklist_steps_order : ChecklistStepsOrder, optional | ||
A relationship to the `ChecklistStepsOrder` model, which defines the order of these steps within a checklist. | ||
""" | ||
__tablename__ = "checklist_steps_states" | ||
|
||
id: uuid.UUID = Field(default_factory=uuid.uuid4, primary_key=True) | ||
checklist_steps_order_id: uuid.UUID = Field(foreign_key="public.checklist_steps_orders.id", nullable=False) | ||
user_profile_id: uuid.UUID = Field(foreign_key="public.user_profiles.id", nullable=False) | ||
is_completed: bool = Field(default=False, nullable=False) | ||
|
||
checklist_steps_order: "ChecklistStepsOrder" = Relationship(cascade_delete=False) | ||
user_profile: Optional["UserProfile"] = Relationship(back_populates="checklist_steps_state", cascade_delete=False) |
49 changes: 0 additions & 49 deletions
49
src/support_sphere_py/src/support_sphere/models/public/checklist_type.py
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
src/support_sphere_py/src/support_sphere/models/public/frequency.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import uuid | ||
from typing import Optional | ||
|
||
from support_sphere.models.base import BasePublicSchemaModel | ||
from sqlmodel import Field, Relationship | ||
|
||
|
||
class Frequency(BasePublicSchemaModel, table=True): | ||
""" | ||
Represents a frequency in the 'public' schema under the 'checklist_frequency' table. | ||
Attributes | ||
---------- | ||
id : uuid | ||
The unique identifier for the frequency. | ||
name : str | ||
num_days : int | ||
The number of days between recurrences. | ||
checklists: list[Checklists] | ||
A relationship to the `Checklist` model, representing the checklists that can have this frequency. | ||
""" | ||
|
||
__tablename__ = "frequency" | ||
|
||
id: uuid.UUID | None = Field(default_factory=uuid.uuid4, primary_key=True) | ||
name: str | None = Field(nullable=False) | ||
num_days: int | None = Field(nullable=False) | ||
|
||
checklists: list["Checklist"] = Relationship(back_populates="frequency", cascade_delete=False) |
29 changes: 0 additions & 29 deletions
29
src/support_sphere_py/src/support_sphere/models/public/recurring_type.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.