Backend: - Alembic migration 0025: groups, group_memberships, project_shares, note_shares, notifications tables - models: Group, GroupMembership, ProjectShare, NoteShare, Notification - services/access.py: permission resolution (viewer/editor/admin/owner) - services/groups.py + routes/groups.py: full group CRUD + membership - services/sharing.py + routes/shares.py: project/note sharing API - services/notifications.py: in-app notification create/list/mark-read - routes/in_app_notifications.py: GET/POST notification endpoints - routes/users.py: user search endpoint - services/projects.py + services/notes.py: *_for_user variants - routes updated to use *_for_user on get/list; adds permission field - app.py: register all new blueprints Frontend: - api/client.ts: ShareEntry, GroupEntry, NotificationEntry types + helpers - stores/notifications.ts: Pinia store with polling - NotificationBell.vue: bell icon + badge + dropdown toggle + 60s poll - NotificationsPanel.vue: unread notification list with mark-all-read - ShareDialog.vue: teleport modal for sharing projects/notes with users/groups - SharedWithMeView.vue: /shared route listing shared projects and notes - AppHeader: NotificationBell, Shared nav link - ProjectView, NoteViewerView, TaskViewerView: Share button + ShareDialog - SettingsView: Groups admin tab with create/delete groups + member mgmt - router: /shared route Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
80 lines
2.8 KiB
Python
80 lines
2.8 KiB
Python
from sqlalchemy import CheckConstraint, ForeignKey, Integer, Text
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from fabledassistant.models import Base
|
|
from fabledassistant.models.base import TimestampMixin
|
|
|
|
|
|
class ProjectShare(Base, TimestampMixin):
|
|
__tablename__ = "project_shares"
|
|
__table_args__ = (
|
|
CheckConstraint(
|
|
"(shared_with_user_id IS NOT NULL) != (shared_with_group_id IS NOT NULL)",
|
|
name="ck_ps_exclusive_target",
|
|
),
|
|
)
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
|
project_id: Mapped[int] = mapped_column(
|
|
Integer, ForeignKey("projects.id", ondelete="CASCADE"), nullable=False
|
|
)
|
|
shared_with_user_id: Mapped[int | None] = mapped_column(
|
|
Integer, ForeignKey("users.id", ondelete="CASCADE")
|
|
)
|
|
shared_with_group_id: Mapped[int | None] = mapped_column(
|
|
Integer, ForeignKey("groups.id", ondelete="CASCADE")
|
|
)
|
|
permission: Mapped[str] = mapped_column(Text, nullable=False)
|
|
invited_by: Mapped[int] = mapped_column(
|
|
Integer, ForeignKey("users.id"), nullable=False
|
|
)
|
|
|
|
def to_dict(self) -> dict:
|
|
return {
|
|
"id": self.id,
|
|
"project_id": self.project_id,
|
|
"shared_with_user_id": self.shared_with_user_id,
|
|
"shared_with_group_id": self.shared_with_group_id,
|
|
"permission": self.permission,
|
|
"invited_by": self.invited_by,
|
|
"created_at": self.created_at.isoformat(),
|
|
"updated_at": self.updated_at.isoformat(),
|
|
}
|
|
|
|
|
|
class NoteShare(Base, TimestampMixin):
|
|
__tablename__ = "note_shares"
|
|
__table_args__ = (
|
|
CheckConstraint(
|
|
"(shared_with_user_id IS NOT NULL) != (shared_with_group_id IS NOT NULL)",
|
|
name="ck_ns_exclusive_target",
|
|
),
|
|
)
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
|
note_id: Mapped[int] = mapped_column(
|
|
Integer, ForeignKey("notes.id", ondelete="CASCADE"), nullable=False
|
|
)
|
|
shared_with_user_id: Mapped[int | None] = mapped_column(
|
|
Integer, ForeignKey("users.id", ondelete="CASCADE")
|
|
)
|
|
shared_with_group_id: Mapped[int | None] = mapped_column(
|
|
Integer, ForeignKey("groups.id", ondelete="CASCADE")
|
|
)
|
|
permission: Mapped[str] = mapped_column(Text, nullable=False)
|
|
invited_by: Mapped[int] = mapped_column(
|
|
Integer, ForeignKey("users.id"), nullable=False
|
|
)
|
|
|
|
def to_dict(self) -> dict:
|
|
return {
|
|
"id": self.id,
|
|
"note_id": self.note_id,
|
|
"shared_with_user_id": self.shared_with_user_id,
|
|
"shared_with_group_id": self.shared_with_group_id,
|
|
"permission": self.permission,
|
|
"invited_by": self.invited_by,
|
|
"created_at": self.created_at.isoformat(),
|
|
"updated_at": self.updated_at.isoformat(),
|
|
}
|