Files
TimeTracker/app/schemas/task_schema.py
T
Dries Peeters b4486a627f fix: CI tests, code quality, and duplicate DB indexes
- Webhook models: remove duplicate index definitions so db.create_all()
  no longer raises 'index already exists' (columns already have index=True)
- ImportService: fix circular import by late-importing ClientService,
  ProjectService, TimeTrackingService in __init__
- reports: fix F823 by renaming unpack variable _ to _entry_count to avoid
  shadowing gettext _ in export_task_excel()
- Code quality: add .flake8 with extend-ignore so flake8 CI passes;
  simplify pyproject.toml isort config (drop unsupported options)
- Format: run black and isort on app/
- tests: restore minimal app fixture in test_import_export_models
2026-03-15 10:51:52 +01:00

53 lines
2.0 KiB
Python

"""
Schemas for task serialization and validation.
"""
from marshmallow import Schema, fields, validate
from app.constants import TaskStatus
class TaskSchema(Schema):
"""Schema for task serialization"""
id = fields.Int(dump_only=True)
name = fields.Str(required=True, validate=validate.Length(max=200))
description = fields.Str(allow_none=True)
project_id = fields.Int(required=True)
assignee_id = fields.Int(allow_none=True)
status = fields.Str(validate=validate.OneOf([s.value for s in TaskStatus]))
priority = fields.Str(validate=validate.OneOf(["low", "medium", "high", "urgent"]))
due_date = fields.Date(allow_none=True)
tags = fields.Str(allow_none=True)
created_by = fields.Int(required=True)
created_at = fields.DateTime(dump_only=True)
updated_at = fields.DateTime(dump_only=True)
# Nested fields
project = fields.Nested("ProjectSchema", dump_only=True, allow_none=True)
assignee = fields.Nested("UserSchema", dump_only=True, allow_none=True)
class TaskCreateSchema(Schema):
"""Schema for creating a task"""
name = fields.Str(required=True, validate=validate.Length(min=1, max=200))
description = fields.Str(allow_none=True)
project_id = fields.Int(required=True)
assignee_id = fields.Int(allow_none=True)
priority = fields.Str(missing="medium", validate=validate.OneOf(["low", "medium", "high", "urgent"]))
due_date = fields.Date(allow_none=True)
tags = fields.Str(allow_none=True)
class TaskUpdateSchema(Schema):
"""Schema for updating a task"""
name = fields.Str(allow_none=True, validate=validate.Length(min=1, max=200))
description = fields.Str(allow_none=True)
assignee_id = fields.Int(allow_none=True)
status = fields.Str(allow_none=True, validate=validate.OneOf([s.value for s in TaskStatus]))
priority = fields.Str(allow_none=True, validate=validate.OneOf(["low", "medium", "high", "urgent"]))
due_date = fields.Date(allow_none=True)
tags = fields.Str(allow_none=True)