- Custom Fields (FEAT-001): - CustomField and TaskCustomValue models with formula support - CRUD API for custom field management - Formula engine for calculated fields - Frontend: CustomFieldEditor, CustomFieldInput, ProjectSettings page - Task list API now includes custom_values - KanbanBoard displays custom field values - Gantt View (FEAT-003): - TaskDependency model with FS/SS/FF/SF dependency types - Dependency CRUD API with cycle detection - start_date field added to tasks - GanttChart component with Frappe Gantt integration - Dependency type selector in UI - Calendar View (FEAT-004): - CalendarView component with FullCalendar integration - Date range filtering API for tasks - Drag-and-drop date updates - View mode switching in Tasks page - File Encryption (FEAT-010): - AES-256-GCM encryption service - EncryptionKey model with key rotation support - Admin API for key management - Encrypted upload/download for confidential projects - Migrations: 011 (custom fields), 012 (encryption keys), 013 (task dependencies) - Updated issues.md with completion status 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
89 lines
2.3 KiB
Python
89 lines
2.3 KiB
Python
from pydantic import BaseModel, Field, field_validator
|
|
from typing import Optional, List, Any, Dict
|
|
from datetime import datetime
|
|
from enum import Enum
|
|
|
|
|
|
class FieldType(str, Enum):
|
|
TEXT = "text"
|
|
NUMBER = "number"
|
|
DROPDOWN = "dropdown"
|
|
DATE = "date"
|
|
PERSON = "person"
|
|
FORMULA = "formula"
|
|
|
|
|
|
class CustomFieldBase(BaseModel):
|
|
name: str = Field(..., min_length=1, max_length=100)
|
|
field_type: FieldType
|
|
options: Optional[List[str]] = None # For dropdown type
|
|
formula: Optional[str] = None # For formula type
|
|
is_required: bool = False
|
|
|
|
@field_validator('options')
|
|
@classmethod
|
|
def validate_options(cls, v, info):
|
|
field_type = info.data.get('field_type')
|
|
if field_type == FieldType.DROPDOWN:
|
|
if not v or len(v) == 0:
|
|
raise ValueError('Dropdown fields must have at least one option')
|
|
if len(v) > 50:
|
|
raise ValueError('Dropdown fields can have at most 50 options')
|
|
return v
|
|
|
|
@field_validator('formula')
|
|
@classmethod
|
|
def validate_formula(cls, v, info):
|
|
field_type = info.data.get('field_type')
|
|
if field_type == FieldType.FORMULA and not v:
|
|
raise ValueError('Formula fields must have a formula expression')
|
|
return v
|
|
|
|
|
|
class CustomFieldCreate(CustomFieldBase):
|
|
pass
|
|
|
|
|
|
class CustomFieldUpdate(BaseModel):
|
|
name: Optional[str] = Field(None, min_length=1, max_length=100)
|
|
options: Optional[List[str]] = None
|
|
formula: Optional[str] = None
|
|
is_required: Optional[bool] = None
|
|
|
|
|
|
class CustomFieldResponse(CustomFieldBase):
|
|
id: str
|
|
project_id: str
|
|
position: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class CustomFieldListResponse(BaseModel):
|
|
fields: List[CustomFieldResponse]
|
|
total: int
|
|
|
|
|
|
# Task custom value schemas
|
|
class CustomValueInput(BaseModel):
|
|
field_id: str
|
|
value: Optional[Any] = None # Can be string, number, date string, or user id
|
|
|
|
|
|
class CustomValueResponse(BaseModel):
|
|
field_id: str
|
|
field_name: str
|
|
field_type: FieldType
|
|
value: Optional[Any] = None
|
|
display_value: Optional[str] = None # Formatted for display
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class TaskCustomValuesUpdate(BaseModel):
|
|
custom_values: List[CustomValueInput]
|