03dd477899
Check Cross-Plugin Imports / check (push) Has been cancelled
- Scope-Deklarationen: tasks only_mine, kommunikation conversation_ids, wiki category_ids (NEUE contracts.py), report_generator template_ids, automation agent_ids (module_key agents), tags tag_ids, unified_search entity_types dynamisch aus Provider-Registry - Core-Beiträge: navigation default_route (Startseite) + dashboard widget_app_ids (Widget-TYP-Angebot, Layout bleibt Phase M) - Backend-Filter (additive UND): /tasks (only_mine), /comm/conversations, /wiki/articles+/categories (Subtree), /reports/print-templates, /agents, /tags, /search GET+POST (entity_types-Schnitt), /miniapps?host=dashboard - apply_entity_type_scope-Helper (requested ∧ scope) - Frontend: WorkspaceSwitcher default_route-Navigation, Sidebar workspace-menu_order-Sortierung, workspaceStore moduleMenuOrder() - Tests: 18/18 Deklarationen + 11/11 Filter (TDD), Frontend 2/2 + Store 18/18, tsc clean, Build OK - Regression 64 passed (4 Kombi-Failures = Suite-Isolation, solo-bewiesen); Checker 0; Ruff = Vorbestand (Stash-bewiesen)
120 lines
3.2 KiB
Python
120 lines
3.2 KiB
Python
"""Public contract for the tasks plugin.
|
|
|
|
Exposes only the symbols that other builtins plugins need.
|
|
Importers should use::
|
|
|
|
from app.plugins.builtins.contracts import get_contract
|
|
tasks = get_contract("tasks")
|
|
if tasks:
|
|
await tasks.create_task(db, tenant_id, user_id, data)
|
|
|
|
instead of importing from internal modules directly.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from sqlalchemy import or_, select
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from app.plugins.builtins.contracts import get_contract_registry
|
|
from app.plugins.builtins.tasks.models import Task
|
|
from app.plugins.builtins.tasks.services import (
|
|
assign_task,
|
|
create_task,
|
|
delete_task,
|
|
get_due_tasks,
|
|
get_task,
|
|
list_tasks,
|
|
update_task,
|
|
update_task_status,
|
|
)
|
|
|
|
|
|
class TasksContract:
|
|
"""Public API surface for the tasks plugin."""
|
|
|
|
contract_name = "tasks"
|
|
|
|
# ─── services ───
|
|
list_tasks = staticmethod(list_tasks)
|
|
get_task = staticmethod(get_task)
|
|
create_task = staticmethod(create_task)
|
|
update_task = staticmethod(update_task)
|
|
delete_task = staticmethod(delete_task)
|
|
assign_task = staticmethod(assign_task)
|
|
update_task_status = staticmethod(update_task_status)
|
|
get_due_tasks = staticmethod(get_due_tasks)
|
|
|
|
# ─── Workspace Scopes contribution (Phase N4) ───
|
|
|
|
@staticmethod
|
|
def workspace_scopes() -> list[dict]:
|
|
"""Scope-Dimensionen des tasks-Moduls: „nur meine" (Roadmap N4)."""
|
|
return [
|
|
{
|
|
"module_key": "tasks",
|
|
"dimensions": [
|
|
{
|
|
"key": "only_mine",
|
|
"label": "Nur meine Aufgaben",
|
|
"control": "toggle",
|
|
"options": [],
|
|
"value_source": None,
|
|
"default": False,
|
|
},
|
|
],
|
|
}
|
|
]
|
|
|
|
# ─── models (read-only for queries) ───
|
|
Task = Task
|
|
|
|
@staticmethod
|
|
async def dsar_collect(
|
|
db: AsyncSession, tenant_id: Any, user_id: Any
|
|
) -> dict[str, Any]:
|
|
"""GDPR Art. 15: collect tasks owned by or assigned to the user."""
|
|
tasks = (
|
|
await db.execute(
|
|
select(Task).where(
|
|
or_(Task.owner_id == user_id, Task.assigned_to == user_id),
|
|
Task.tenant_id == tenant_id,
|
|
Task.deleted_at.is_(None),
|
|
).limit(1000)
|
|
)
|
|
).scalars().all()
|
|
return {
|
|
"tasks": [
|
|
{
|
|
"id": str(t.id),
|
|
"title": t.title,
|
|
"status": t.status,
|
|
"priority": t.priority,
|
|
"due_date": t.due_date.isoformat() if t.due_date else None,
|
|
}
|
|
for t in tasks
|
|
]
|
|
}
|
|
|
|
|
|
# ─── self-registration ───
|
|
|
|
_contract = TasksContract()
|
|
get_contract_registry().register("tasks", _contract)
|
|
|
|
|
|
__all__ = [
|
|
"TasksContract",
|
|
"Task",
|
|
"list_tasks",
|
|
"get_task",
|
|
"create_task",
|
|
"update_task",
|
|
"delete_task",
|
|
"assign_task",
|
|
"update_task_status",
|
|
"get_due_tasks",
|
|
]
|