feat: Phase 2C — notes & todos
- New models: SiteNote, SiteTodo (site_notes, site_todos tables) - New schemas: NoteOut, TodoOut with creator/done-by name enrichment - New router: /api/notes/ — full CRUD for notes and todos - Notes: create, list (pinned first), update (body + pin), delete - Todos: create, list (undone high-priority first), toggle done, edit, delete - Marking done records done_at + done_by_id; unchecking clears both - Migrations: CREATE TABLE IF NOT EXISTS for both tables (additive, safe) - NotesPage.jsx: two-column layout — notes left, todos right - Notes: inline click-to-edit, pin toggle, Ctrl+Enter to save, pinned section on top - Todos: inline edit, high-priority flag, completed collapse toggle - /notes route added to App.jsx - NotebookPen sidebar entry between Διαχείριση and Ρυθμίσεις Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
37
local_backend/models/notes.py
Normal file
37
local_backend/models/notes.py
Normal file
@@ -0,0 +1,37 @@
|
||||
from sqlalchemy import Column, Integer, String, Boolean, DateTime, Text, ForeignKey
|
||||
from sqlalchemy.orm import relationship
|
||||
from datetime import datetime, timezone
|
||||
from database import Base
|
||||
|
||||
|
||||
def _utcnow():
|
||||
return datetime.now(timezone.utc)
|
||||
|
||||
|
||||
class SiteNote(Base):
|
||||
__tablename__ = "site_notes"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
body = Column(Text, nullable=False)
|
||||
created_by_id = Column(Integer, ForeignKey("users.id"), nullable=False)
|
||||
created_at = Column(DateTime(timezone=True), default=_utcnow)
|
||||
updated_at = Column(DateTime(timezone=True), default=_utcnow, onupdate=_utcnow)
|
||||
is_pinned = Column(Boolean, default=False, nullable=False)
|
||||
|
||||
created_by = relationship("User", foreign_keys=[created_by_id])
|
||||
|
||||
|
||||
class SiteTodo(Base):
|
||||
__tablename__ = "site_todos"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
body = Column(Text, nullable=False)
|
||||
is_done = Column(Boolean, default=False, nullable=False)
|
||||
done_at = Column(DateTime(timezone=True), nullable=True)
|
||||
done_by_id = Column(Integer, ForeignKey("users.id"), nullable=True)
|
||||
created_by_id = Column(Integer, ForeignKey("users.id"), nullable=False)
|
||||
created_at = Column(DateTime(timezone=True), default=_utcnow)
|
||||
priority = Column(String, default="normal", nullable=False) # "normal" | "high"
|
||||
|
||||
created_by = relationship("User", foreign_keys=[created_by_id])
|
||||
done_by = relationship("User", foreign_keys=[done_by_id])
|
||||
Reference in New Issue
Block a user