T024: add function_type and group start/end dates to function groups UI
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
"""add_function_type_and_group_dates
|
||||
|
||||
Revision ID: cfe638817921
|
||||
Revises: f5772dd5cd55
|
||||
Create Date: 2026-05-31 21:17:13.064051
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'cfe638817921'
|
||||
down_revision: Union[str, None] = 'f5772dd5cd55'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('project_function_groups', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('start_date', sa.DateTime(timezone=True), nullable=True))
|
||||
batch_op.add_column(sa.Column('end_date', sa.DateTime(timezone=True), nullable=True))
|
||||
|
||||
with op.batch_alter_table('project_functions', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('function_type', sa.String(length=50), nullable=False))
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('project_functions', schema=None) as batch_op:
|
||||
batch_op.drop_column('function_type')
|
||||
|
||||
with op.batch_alter_table('project_function_groups', schema=None) as batch_op:
|
||||
batch_op.drop_column('end_date')
|
||||
batch_op.drop_column('start_date')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
@@ -108,6 +108,8 @@ class ProjectFunctionGroup(Base):
|
||||
String(36), ForeignKey("projects.id", ondelete="CASCADE"), nullable=False
|
||||
)
|
||||
sort_order: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
|
||||
start_date: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
|
||||
end_date: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
|
||||
|
||||
# Relationships
|
||||
project: Mapped["Project"] = relationship(
|
||||
@@ -135,6 +137,7 @@ class ProjectFunction(Base):
|
||||
ForeignKey("project_function_groups.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
)
|
||||
function_type: Mapped[str] = mapped_column(String(50), nullable=False, default='crew')
|
||||
quantity: Mapped[float] = mapped_column(Float, nullable=False, default=1.0)
|
||||
daily_costs: Mapped[float] = mapped_column(Float, nullable=False, default=0.0)
|
||||
total_costs: Mapped[float] = mapped_column(Float, nullable=False, default=0.0)
|
||||
|
||||
@@ -103,12 +103,16 @@ class ProjectFunctionGroupCreateRequest(BaseModel):
|
||||
"""Request body for creating a function group."""
|
||||
name: str = Field(..., max_length=255)
|
||||
sort_order: int = 0
|
||||
start_date: datetime | None = None
|
||||
end_date: datetime | None = None
|
||||
|
||||
|
||||
class ProjectFunctionGroupUpdateRequest(BaseModel):
|
||||
"""Request body for updating a function group."""
|
||||
name: str | None = Field(None, max_length=255)
|
||||
sort_order: int | None = None
|
||||
start_date: datetime | None = None
|
||||
end_date: datetime | None = None
|
||||
|
||||
|
||||
class ProjectFunctionGroupResponse(BaseModel):
|
||||
@@ -117,6 +121,8 @@ class ProjectFunctionGroupResponse(BaseModel):
|
||||
name: str
|
||||
project_id: str
|
||||
sort_order: int = 0
|
||||
start_date: datetime | None = None
|
||||
end_date: datetime | None = None
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
@@ -134,6 +140,7 @@ class ProjectFunctionGroupListResponse(BaseModel):
|
||||
class ProjectFunctionCreateRequest(BaseModel):
|
||||
"""Request body for creating a project function."""
|
||||
name: str = Field(..., max_length=255)
|
||||
function_type: str = "crew"
|
||||
quantity: float = 1.0
|
||||
daily_costs: float = 0.0
|
||||
total_costs: float = 0.0
|
||||
@@ -143,6 +150,7 @@ class ProjectFunctionCreateRequest(BaseModel):
|
||||
class ProjectFunctionUpdateRequest(BaseModel):
|
||||
"""Request body for updating a project function."""
|
||||
name: str | None = Field(None, max_length=255)
|
||||
function_type: str | None = None
|
||||
quantity: float | None = None
|
||||
daily_costs: float | None = None
|
||||
total_costs: float | None = None
|
||||
@@ -154,6 +162,7 @@ class ProjectFunctionResponse(BaseModel):
|
||||
id: str
|
||||
name: str
|
||||
function_group_id: str
|
||||
function_type: str = "crew"
|
||||
quantity: float = 1.0
|
||||
daily_costs: float = 0.0
|
||||
total_costs: float = 0.0
|
||||
|
||||
Reference in New Issue
Block a user