031708ad8f
Backend : - Migration 006 : colonne urls JSONB nullable sur notes.items - Modèle NoteItem : champ urls list[dict] - Schémas : NoteUrl (label + url avec validation http/https), NoteCreate/NoteUpdate/NoteResponse exposent urls Frontend : - api/notes.ts : interface NoteUrl + champ urls sur Note/NoteCreate - NoteForm : section "Liens" avec ajout (libellé + URL), suppression, validation http/https, confirmation par Enter - NotesPage : badge compteur liens dans metaLine (semi/collapsed), section liens cliquables dans le mode expanded v0.5.13 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
42 lines
2.1 KiB
Python
42 lines
2.1 KiB
Python
import uuid
|
|
from datetime import datetime
|
|
from decimal import Decimal
|
|
from sqlalchemy import String, Text, TIMESTAMP, Numeric, ForeignKey, text
|
|
from sqlalchemy.dialects.postgresql import UUID, ARRAY, JSONB
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
from app.core.database import Base
|
|
|
|
|
|
class NoteItem(Base):
|
|
__tablename__ = "items"
|
|
__table_args__ = {"schema": "notes"}
|
|
|
|
id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
title: Mapped[str | None] = mapped_column(String(255))
|
|
content: Mapped[str] = mapped_column(Text, nullable=False)
|
|
category: Mapped[str | None] = mapped_column(String(50))
|
|
tags: Mapped[list[str]] = mapped_column(ARRAY(String(50)), server_default=text("'{}'::varchar[]"))
|
|
gps_lat: Mapped[Decimal | None] = mapped_column(Numeric(10, 7))
|
|
gps_lon: Mapped[Decimal | None] = mapped_column(Numeric(10, 7))
|
|
urls: Mapped[list[dict] | None] = mapped_column(JSONB, nullable=True)
|
|
metadata_: Mapped[dict | None] = mapped_column("metadata", JSONB)
|
|
created_at: Mapped[datetime] = mapped_column(TIMESTAMP(timezone=True), server_default=text("now()"))
|
|
owner_id: Mapped[uuid.UUID | None] = mapped_column(UUID(as_uuid=True))
|
|
|
|
attachments: Mapped[list["NoteAttachment"]] = relationship("NoteAttachment", back_populates="note", cascade="all, delete-orphan")
|
|
|
|
|
|
class NoteAttachment(Base):
|
|
__tablename__ = "attachments"
|
|
__table_args__ = {"schema": "notes"}
|
|
|
|
id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
note_id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), ForeignKey("notes.items.id", ondelete="CASCADE"), nullable=False)
|
|
file_path: Mapped[str | None] = mapped_column(String(255))
|
|
thumbnail_path: Mapped[str | None] = mapped_column(String(255))
|
|
file_type: Mapped[str | None] = mapped_column(String(20))
|
|
original_name: Mapped[str | None] = mapped_column(String(255))
|
|
created_at: Mapped[datetime] = mapped_column(TIMESTAMP(timezone=True), server_default=text("now()"))
|
|
|
|
note: Mapped["NoteItem"] = relationship("NoteItem", back_populates="attachments")
|