stapel-tasks 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. stapel_tasks-0.1.1/LICENSE +21 -0
  2. stapel_tasks-0.1.1/PKG-INFO +112 -0
  3. stapel_tasks-0.1.1/README.md +78 -0
  4. stapel_tasks-0.1.1/__init__.py +41 -0
  5. stapel_tasks-0.1.1/actions.py +24 -0
  6. stapel_tasks-0.1.1/admin.py +45 -0
  7. stapel_tasks-0.1.1/apps.py +33 -0
  8. stapel_tasks-0.1.1/checks.py +87 -0
  9. stapel_tasks-0.1.1/conf.py +53 -0
  10. stapel_tasks-0.1.1/conftest.py +132 -0
  11. stapel_tasks-0.1.1/dto.py +337 -0
  12. stapel_tasks-0.1.1/errors.py +55 -0
  13. stapel_tasks-0.1.1/features.py +107 -0
  14. stapel_tasks-0.1.1/functions.py +161 -0
  15. stapel_tasks-0.1.1/gdpr.py +66 -0
  16. stapel_tasks-0.1.1/migrations/0001_initial.py +148 -0
  17. stapel_tasks-0.1.1/migrations/__init__.py +0 -0
  18. stapel_tasks-0.1.1/models.py +287 -0
  19. stapel_tasks-0.1.1/policy.py +96 -0
  20. stapel_tasks-0.1.1/positioning.py +59 -0
  21. stapel_tasks-0.1.1/presets.py +94 -0
  22. stapel_tasks-0.1.1/py.typed +0 -0
  23. stapel_tasks-0.1.1/pyproject.toml +74 -0
  24. stapel_tasks-0.1.1/schemas/consumes/user.deleted.json +14 -0
  25. stapel_tasks-0.1.1/schemas/emits/task.archived.json +13 -0
  26. stapel_tasks-0.1.1/schemas/emits/task.assigned.json +15 -0
  27. stapel_tasks-0.1.1/schemas/emits/task.checklist_item_changed.json +15 -0
  28. stapel_tasks-0.1.1/schemas/emits/task.comment_added.json +14 -0
  29. stapel_tasks-0.1.1/schemas/emits/task.completed.json +15 -0
  30. stapel_tasks-0.1.1/schemas/emits/task.created.json +20 -0
  31. stapel_tasks-0.1.1/schemas/emits/task.moved.json +17 -0
  32. stapel_tasks-0.1.1/schemas/emits/task.updated.json +14 -0
  33. stapel_tasks-0.1.1/schemas/functions/tasks.comment.json +13 -0
  34. stapel_tasks-0.1.1/schemas/functions/tasks.create.json +27 -0
  35. stapel_tasks-0.1.1/schemas/functions/tasks.get.json +11 -0
  36. stapel_tasks-0.1.1/schemas/functions/tasks.list_board.json +16 -0
  37. stapel_tasks-0.1.1/schemas/functions/tasks.move.json +14 -0
  38. stapel_tasks-0.1.1/scope.py +61 -0
  39. stapel_tasks-0.1.1/serializers.py +111 -0
  40. stapel_tasks-0.1.1/services.py +583 -0
  41. stapel_tasks-0.1.1/setup.cfg +4 -0
  42. stapel_tasks-0.1.1/stapel_tasks.egg-info/PKG-INFO +112 -0
  43. stapel_tasks-0.1.1/stapel_tasks.egg-info/SOURCES.txt +93 -0
  44. stapel_tasks-0.1.1/stapel_tasks.egg-info/dependency_links.txt +1 -0
  45. stapel_tasks-0.1.1/stapel_tasks.egg-info/requires.txt +9 -0
  46. stapel_tasks-0.1.1/stapel_tasks.egg-info/top_level.txt +1 -0
  47. stapel_tasks-0.1.1/tests/test_api.py +191 -0
  48. stapel_tasks-0.1.1/tests/test_checks.py +33 -0
  49. stapel_tasks-0.1.1/tests/test_comm.py +86 -0
  50. stapel_tasks-0.1.1/tests/test_features.py +40 -0
  51. stapel_tasks-0.1.1/tests/test_gdpr.py +45 -0
  52. stapel_tasks-0.1.1/tests/test_positioning.py +53 -0
  53. stapel_tasks-0.1.1/tests/test_public_api.py +44 -0
  54. stapel_tasks-0.1.1/tests/test_seams.py +108 -0
  55. stapel_tasks-0.1.1/tests/test_services.py +168 -0
  56. stapel_tasks-0.1.1/urls.py +73 -0
  57. stapel_tasks-0.1.1/views.py +681 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Stapel contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,112 @@
1
+ Metadata-Version: 2.4
2
+ Name: stapel-tasks
3
+ Version: 0.1.1
4
+ Summary: Generic tasks and kanban boards for the Stapel framework
5
+ Author: Stapel
6
+ License: MIT
7
+ Project-URL: Homepage, https://stapel.dev
8
+ Project-URL: Repository, https://github.com/usestapel/stapel-tasks
9
+ Project-URL: Documentation, https://github.com/usestapel/stapel-tasks/blob/main/MODULE.md
10
+ Project-URL: Changelog, https://github.com/usestapel/stapel-tasks/blob/main/CHANGELOG.md
11
+ Project-URL: Issues, https://github.com/usestapel/stapel-tasks/issues
12
+ Keywords: django,stapel,tasks,kanban,boards,workflow
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Framework :: Django
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3 :: Only
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.11
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: stapel-core<0.9,>=0.8
27
+ Requires-Dist: djangorestframework>=3.14
28
+ Requires-Dist: drf-spectacular>=0.27
29
+ Provides-Extra: attributes
30
+ Requires-Dist: stapel-attributes<0.4,>=0.3; extra == "attributes"
31
+ Provides-Extra: all
32
+ Requires-Dist: stapel-attributes<0.4,>=0.3; extra == "all"
33
+ Dynamic: license-file
34
+
35
+ # stapel-tasks
36
+
37
+ Generic tasks and kanban boards for the [Stapel framework](https://github.com/usestapel) —
38
+ composable Django apps that deploy as a monolith or as microservices without
39
+ changing module code.
40
+
41
+ A **generic task domain** — Board / Column / Task / ChecklistItem /
42
+ TaskComment, a REST surface, a full outbox event surface, and custom fields
43
+ via stapel-attributes. It is useful to any project by itself (a team runs a
44
+ board by hand), and it is the substrate an orchestrator *projects* onto: an
45
+ external state machine drives cards through opaque `origin_*` handles and the
46
+ `MOVE_POLICY` seam — the module knows nothing about the machine.
47
+
48
+ ## Install
49
+
50
+ ```bash
51
+ pip install stapel-tasks # core
52
+ pip install "stapel-tasks[attributes]" # + typed custom-field validation
53
+ ```
54
+
55
+ ```python
56
+ INSTALLED_APPS = [
57
+ # ...
58
+ "stapel_tasks",
59
+ ]
60
+
61
+ # urls.py
62
+ path("tasks/", include("stapel_tasks.urls"))
63
+ ```
64
+
65
+ > **Requires** a stapel-core whose background `taskstore` app uses the label
66
+ > `stapel_taskstore` — this module owns the Django label `stapel_tasks`. See
67
+ > MODULE.md.
68
+
69
+ ## Concepts
70
+
71
+ - **Board** — an ordered set of columns and the cards on them. Owns the
72
+ custom-field *schema* (`feature_defs`) and optional workflow `settings`.
73
+ - **Column** — a status. Its `key` is the card's status; its `category`
74
+ (`backlog/active/review/waiting/done`) is the fixed machine semantic.
75
+ - **Task (card)** — status = its column; order within the column is a
76
+ fractional `position` (drag-and-drop moves write one row). Custom-field
77
+ values live in `features`; a projecting system writes `origin_meta`.
78
+ - **Move** — drag-and-drop is a `move` validated by `MOVE_POLICY`:
79
+ `allow` / `deny(reason_key)` / `defer` (the managed-card path).
80
+
81
+ ```python
82
+ from stapel_tasks import services
83
+
84
+ board = services.create_board(name="Team", preset="simple")
85
+ card = services.create_task(board=board, title="Ship it")
86
+ services.move_task(card, to_column=board.columns.get(key="done")) # emits task.completed
87
+ ```
88
+
89
+ ## comm surface
90
+
91
+ | Kind | Name | Purpose |
92
+ |---|---|---|
93
+ | Emit | `task.created` / `task.updated` / `task.moved` / `task.assigned` / `task.completed` / `task.comment_added` / `task.checklist_item_changed` / `task.archived` | Card lifecycle facts (via the outbox) |
94
+ | Consume | `user.deleted` | GDPR anonymization |
95
+ | Function | `tasks.get` / `tasks.list_board` / `tasks.create` / `tasks.move` / `tasks.comment` | Machine interface / MCP-tool candidates |
96
+
97
+ ## Settings (`STAPEL_TASKS`)
98
+
99
+ | Key | Default | What it customizes |
100
+ |---|---|---|
101
+ | `SCOPE_PROVIDER` | single global scope, allow-all | Tenancy resolution/filtering + permissions |
102
+ | `MOVE_POLICY` | allow any move (honours `transitions`) | Drag-and-drop authorization |
103
+ | `BOARD_PRESETS` | `{}` (merged over built-in `simple`) | Board-shape presets |
104
+ | `STORE_UNKNOWN_FEATURES` | `True` | Keep raw custom fields when attributes is absent |
105
+ | `DEFAULT_PAGE_SIZE` | `100` | Card-list page size |
106
+
107
+ See **MODULE.md** for the full seam map (providers, registries, serializer
108
+ seams, comm tables, anti-patterns, override-vs-upstream).
109
+
110
+ ## License
111
+
112
+ MIT
@@ -0,0 +1,78 @@
1
+ # stapel-tasks
2
+
3
+ Generic tasks and kanban boards for the [Stapel framework](https://github.com/usestapel) —
4
+ composable Django apps that deploy as a monolith or as microservices without
5
+ changing module code.
6
+
7
+ A **generic task domain** — Board / Column / Task / ChecklistItem /
8
+ TaskComment, a REST surface, a full outbox event surface, and custom fields
9
+ via stapel-attributes. It is useful to any project by itself (a team runs a
10
+ board by hand), and it is the substrate an orchestrator *projects* onto: an
11
+ external state machine drives cards through opaque `origin_*` handles and the
12
+ `MOVE_POLICY` seam — the module knows nothing about the machine.
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ pip install stapel-tasks # core
18
+ pip install "stapel-tasks[attributes]" # + typed custom-field validation
19
+ ```
20
+
21
+ ```python
22
+ INSTALLED_APPS = [
23
+ # ...
24
+ "stapel_tasks",
25
+ ]
26
+
27
+ # urls.py
28
+ path("tasks/", include("stapel_tasks.urls"))
29
+ ```
30
+
31
+ > **Requires** a stapel-core whose background `taskstore` app uses the label
32
+ > `stapel_taskstore` — this module owns the Django label `stapel_tasks`. See
33
+ > MODULE.md.
34
+
35
+ ## Concepts
36
+
37
+ - **Board** — an ordered set of columns and the cards on them. Owns the
38
+ custom-field *schema* (`feature_defs`) and optional workflow `settings`.
39
+ - **Column** — a status. Its `key` is the card's status; its `category`
40
+ (`backlog/active/review/waiting/done`) is the fixed machine semantic.
41
+ - **Task (card)** — status = its column; order within the column is a
42
+ fractional `position` (drag-and-drop moves write one row). Custom-field
43
+ values live in `features`; a projecting system writes `origin_meta`.
44
+ - **Move** — drag-and-drop is a `move` validated by `MOVE_POLICY`:
45
+ `allow` / `deny(reason_key)` / `defer` (the managed-card path).
46
+
47
+ ```python
48
+ from stapel_tasks import services
49
+
50
+ board = services.create_board(name="Team", preset="simple")
51
+ card = services.create_task(board=board, title="Ship it")
52
+ services.move_task(card, to_column=board.columns.get(key="done")) # emits task.completed
53
+ ```
54
+
55
+ ## comm surface
56
+
57
+ | Kind | Name | Purpose |
58
+ |---|---|---|
59
+ | Emit | `task.created` / `task.updated` / `task.moved` / `task.assigned` / `task.completed` / `task.comment_added` / `task.checklist_item_changed` / `task.archived` | Card lifecycle facts (via the outbox) |
60
+ | Consume | `user.deleted` | GDPR anonymization |
61
+ | Function | `tasks.get` / `tasks.list_board` / `tasks.create` / `tasks.move` / `tasks.comment` | Machine interface / MCP-tool candidates |
62
+
63
+ ## Settings (`STAPEL_TASKS`)
64
+
65
+ | Key | Default | What it customizes |
66
+ |---|---|---|
67
+ | `SCOPE_PROVIDER` | single global scope, allow-all | Tenancy resolution/filtering + permissions |
68
+ | `MOVE_POLICY` | allow any move (honours `transitions`) | Drag-and-drop authorization |
69
+ | `BOARD_PRESETS` | `{}` (merged over built-in `simple`) | Board-shape presets |
70
+ | `STORE_UNKNOWN_FEATURES` | `True` | Keep raw custom fields when attributes is absent |
71
+ | `DEFAULT_PAGE_SIZE` | `100` | Card-list page size |
72
+
73
+ See **MODULE.md** for the full seam map (providers, registries, serializer
74
+ seams, comm tables, anti-patterns, override-vs-upstream).
75
+
76
+ ## License
77
+
78
+ MIT
@@ -0,0 +1,41 @@
1
+ """stapel-tasks — Generic tasks and kanban boards for the Stapel framework.
2
+
3
+ A *generic* task domain: Board / Column / Task / ChecklistItem / TaskComment,
4
+ a REST surface, a workflow-as-data-lite model (columns carry a fixed
5
+ ``category`` enum), custom fields via stapel-attributes (a soft seam that
6
+ works without it), and a full event surface through the transactional outbox.
7
+
8
+ The module deliberately knows nothing about any orchestrator / pipeline FSM.
9
+ External state machines *project* into it through the opaque
10
+ ``origin_type``/``origin_ref``/``origin_meta`` handles and the ``MOVE_POLICY``
11
+ seam — see MODULE.md §"Projection seam".
12
+
13
+ Public API (lazily exported, PEP 562 — importing this package never pulls in
14
+ Django or requires configured settings):
15
+
16
+ - ``tasks_settings`` — resolved app settings (``stapel_tasks.conf``).
17
+ """
18
+
19
+ __all__ = [
20
+ "tasks_settings",
21
+ ]
22
+
23
+ # name -> submodule that defines it. Resolution is deferred until first
24
+ # attribute access so that `import stapel_tasks` stays Django-free.
25
+ _LAZY_EXPORTS = {
26
+ "tasks_settings": ".conf",
27
+ }
28
+
29
+
30
+ def __getattr__(name):
31
+ if name in _LAZY_EXPORTS:
32
+ from importlib import import_module
33
+
34
+ value = getattr(import_module(_LAZY_EXPORTS[name], __name__), name)
35
+ globals()[name] = value # cache for subsequent lookups
36
+ return value
37
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
38
+
39
+
40
+ def __dir__():
41
+ return sorted(set(globals()) | set(__all__))
@@ -0,0 +1,24 @@
1
+ """Action subscriptions of stapel-tasks.
2
+
3
+ Handlers must be idempotent: delivery is at-least-once (outbox retries,
4
+ broker redelivery). Consumes contracts live in ``schemas/consumes/``.
5
+ """
6
+ import logging
7
+
8
+ from stapel_core.comm import on_action
9
+
10
+ logger = logging.getLogger(__name__)
11
+
12
+
13
+ @on_action("user.deleted")
14
+ def handle_user_deleted(event):
15
+ """Erase this module's PII when an account deletion is executed: drop the
16
+ user's card assignments and anonymize the cards/comments they authored."""
17
+ from .gdpr import TasksGDPRProvider
18
+
19
+ user_id = event.payload.get("user_id")
20
+ if not user_id:
21
+ logger.error("user.deleted event without user_id: %s", event.event_id)
22
+ return
23
+ TasksGDPRProvider().delete(user_id)
24
+ logger.info("tasks data anonymized for deleted user %s", user_id)
@@ -0,0 +1,45 @@
1
+ """Admin registrations for stapel-tasks (observability; kept minimal)."""
2
+ from django.contrib import admin
3
+
4
+ from .models import Board, ChecklistItem, Column, Task, TaskComment
5
+
6
+
7
+ class ColumnInline(admin.TabularInline):
8
+ model = Column
9
+ extra = 0
10
+ fields = ("key", "name", "category", "order", "wip_limit")
11
+
12
+
13
+ @admin.register(Board)
14
+ class BoardAdmin(admin.ModelAdmin):
15
+ list_display = ("name", "workspace_id", "is_archived", "created_at")
16
+ list_filter = ("is_archived",)
17
+ search_fields = ("name", "slug")
18
+ inlines = [ColumnInline]
19
+
20
+
21
+ @admin.register(Task)
22
+ class TaskAdmin(admin.ModelAdmin):
23
+ list_display = (
24
+ "title",
25
+ "board",
26
+ "column",
27
+ "origin_type",
28
+ "is_archived",
29
+ "created_at",
30
+ )
31
+ list_filter = ("origin_type", "is_archived")
32
+ search_fields = ("title", "origin_ref")
33
+ raw_id_fields = ("board", "column", "creator", "parent")
34
+
35
+
36
+ @admin.register(ChecklistItem)
37
+ class ChecklistItemAdmin(admin.ModelAdmin):
38
+ list_display = ("text", "task", "state", "order")
39
+ list_filter = ("state",)
40
+
41
+
42
+ @admin.register(TaskComment)
43
+ class TaskCommentAdmin(admin.ModelAdmin):
44
+ list_display = ("task", "author", "is_deleted", "created_at")
45
+ list_filter = ("is_deleted",)
@@ -0,0 +1,33 @@
1
+ from django.apps import AppConfig
2
+
3
+
4
+ class TasksConfig(AppConfig):
5
+ # Canonical Django label for the generic task domain. stapel-core's
6
+ # background-task persistence app (``stapel_core.django.taskstore``)
7
+ # historically claimed the label ``stapel_tasks`` too — the two are
8
+ # unrelated ("comm Task" = async background function vs. this user-facing
9
+ # task/kanban domain). Core renames its taskstore label to
10
+ # ``stapel_taskstore`` so this module can own ``stapel_tasks`` (see
11
+ # MODULE.md §"stapel-core requirement").
12
+ name = "stapel_tasks"
13
+ label = "stapel_tasks"
14
+ verbose_name = "Tasks and kanban boards"
15
+ default_auto_field = "django.db.models.BigAutoField"
16
+
17
+ def ready(self):
18
+ # Import-time side effects: comm functions/actions, system checks,
19
+ # error-key registration, and the built-in board presets. Each lives
20
+ # in its own module.
21
+ from . import actions # noqa: F401
22
+ from . import checks # noqa: F401
23
+ from . import errors # noqa: F401
24
+ from . import functions # noqa: F401
25
+ from . import presets # noqa: F401
26
+
27
+ # GDPR: register the per-app data handler (monolith in-process mode).
28
+ from stapel_core.gdpr import gdpr_registry
29
+
30
+ from .gdpr import TasksGDPRProvider
31
+
32
+ if not any(p.section == "tasks" for p in gdpr_registry.providers):
33
+ gdpr_registry.register(TasksGDPRProvider())
@@ -0,0 +1,87 @@
1
+ """Django system checks for stapel-tasks configuration.
2
+
3
+ Policy (docs/library-standard.md §3.7): E-level for configuration the
4
+ service cannot run with; W-level for entries that only degrade lazily.
5
+
6
+ - SCOPE_PROVIDER unimportable / not a ScopeProvider -> E (every request
7
+ needs it to resolve/filter scope and check permissions).
8
+ - MOVE_POLICY unimportable / not a MovePolicy -> E (every move needs it).
9
+ - BOARD_PRESETS entries must be callable or None -> E (board creation from a
10
+ broken preset would crash).
11
+ """
12
+ from django.core import checks
13
+
14
+
15
+ @checks.register(checks.Tags.compatibility)
16
+ def check_scope_provider(app_configs, **kwargs):
17
+ from .conf import tasks_settings
18
+ from .scope import ScopeProvider
19
+
20
+ try:
21
+ provider = tasks_settings.SCOPE_PROVIDER
22
+ except Exception as exc:
23
+ return [
24
+ checks.Error(
25
+ f"STAPEL_TASKS['SCOPE_PROVIDER'] could not be imported: {exc}",
26
+ id="stapel_tasks.E001",
27
+ )
28
+ ]
29
+ target = provider if isinstance(provider, type) else type(provider)
30
+ if not issubclass(target, ScopeProvider):
31
+ return [
32
+ checks.Error(
33
+ "STAPEL_TASKS['SCOPE_PROVIDER'] must be a ScopeProvider subclass",
34
+ id="stapel_tasks.E002",
35
+ )
36
+ ]
37
+ return []
38
+
39
+
40
+ @checks.register(checks.Tags.compatibility)
41
+ def check_move_policy(app_configs, **kwargs):
42
+ from .conf import tasks_settings
43
+ from .policy import MovePolicy
44
+
45
+ try:
46
+ policy = tasks_settings.MOVE_POLICY
47
+ except Exception as exc:
48
+ return [
49
+ checks.Error(
50
+ f"STAPEL_TASKS['MOVE_POLICY'] could not be imported: {exc}",
51
+ id="stapel_tasks.E003",
52
+ )
53
+ ]
54
+ target = policy if isinstance(policy, type) else type(policy)
55
+ if not issubclass(target, MovePolicy):
56
+ return [
57
+ checks.Error(
58
+ "STAPEL_TASKS['MOVE_POLICY'] must be a MovePolicy subclass",
59
+ id="stapel_tasks.E004",
60
+ )
61
+ ]
62
+ return []
63
+
64
+
65
+ @checks.register(checks.Tags.compatibility)
66
+ def check_board_presets(app_configs, **kwargs):
67
+ from .conf import tasks_settings
68
+
69
+ presets = tasks_settings.BOARD_PRESETS
70
+ if not isinstance(presets, dict):
71
+ return [
72
+ checks.Error(
73
+ "STAPEL_TASKS['BOARD_PRESETS'] must be a dict of "
74
+ "{key: callable|None}.",
75
+ id="stapel_tasks.E005",
76
+ )
77
+ ]
78
+ bad = [k for k, v in presets.items() if v is not None and not callable(v)]
79
+ if bad:
80
+ return [
81
+ checks.Error(
82
+ f"STAPEL_TASKS['BOARD_PRESETS'] values must be callable or None; "
83
+ f"offending keys: {bad}",
84
+ id="stapel_tasks.E006",
85
+ )
86
+ ]
87
+ return []
@@ -0,0 +1,53 @@
1
+ """Settings namespace for stapel-tasks.
2
+
3
+ All configuration is read through ``tasks_settings`` (lazily, at call time)
4
+ — never via module-level ``os.getenv`` (values would freeze at import).
5
+ Resolution order per key: ``settings.STAPEL_TASKS`` dict -> flat Django
6
+ setting of the same name -> environment variable -> default below.
7
+
8
+ Dotted-path keys listed in ``import_strings`` are resolved with
9
+ ``import_string`` — the fork-free escape hatch for swappable behavior.
10
+
11
+ The extension seams (see MODULE.md):
12
+
13
+ - ``SCOPE_PROVIDER`` — resolves the opaque ``workspace_id`` from a request,
14
+ filters querysets by it, and answers permission questions
15
+ (viewer/member/admin). The default is a single-global-scope allow-all
16
+ provider; a workspaces-aware host swaps it. The library never interprets
17
+ the scope itself.
18
+ - ``MOVE_POLICY`` — decides whether a card may move from one column to
19
+ another (drag-and-drop / ``tasks.move``): ``allow`` / ``deny(reason_key)``
20
+ / ``defer``. ``defer`` is the managed-card path — the move is accepted for
21
+ processing but not applied (an external orchestrator will move it). The
22
+ default allows any move.
23
+ - ``BOARD_PRESETS`` — board-shape presets merged OVER the built-ins
24
+ (``simple``). A value is a callable ``() -> list[ColumnSpec]``; ``None``
25
+ removes a built-in. Register at runtime with ``register_board_preset``.
26
+ - ``STORE_UNKNOWN_FEATURES`` — when stapel-attributes is not installed (or a
27
+ board declares no ``feature_defs``), whether the feature seam stores the
28
+ submitted custom-field DTO verbatim (``True``) or drops it (``False``).
29
+ """
30
+ from stapel_core.conf import AppSettings
31
+
32
+ tasks_settings = AppSettings(
33
+ "STAPEL_TASKS",
34
+ defaults={
35
+ # Dotted path to a ScopeProvider (resolve/filter/permission seam).
36
+ # The default is a no-op single global scope that allows everything.
37
+ "SCOPE_PROVIDER": "stapel_tasks.scope.DefaultScopeProvider",
38
+ # Dotted path to a MovePolicy. The default allows any move.
39
+ "MOVE_POLICY": "stapel_tasks.policy.AllowAllMovePolicy",
40
+ # Board presets merged OVER presets.BUILTIN_PRESETS. A value is a
41
+ # zero-arg callable returning a list of ColumnSpec; None removes a
42
+ # built-in.
43
+ "BOARD_PRESETS": {},
44
+ # Default page size for the paginated board/task listing.
45
+ "DEFAULT_PAGE_SIZE": 100,
46
+ # When attributes is absent, keep the raw custom-field DTO on the
47
+ # card (soft seam) rather than dropping it.
48
+ "STORE_UNKNOWN_FEATURES": True,
49
+ },
50
+ import_strings=("SCOPE_PROVIDER", "MOVE_POLICY"),
51
+ )
52
+
53
+ __all__ = ["tasks_settings"]
@@ -0,0 +1,132 @@
1
+ def pytest_configure(config):
2
+ from django.conf import settings
3
+
4
+ if not settings.configured:
5
+ settings.configure(
6
+ SECRET_KEY="test-secret-key-not-for-production",
7
+ INSTALLED_APPS=[
8
+ "django.contrib.contenttypes",
9
+ "django.contrib.auth",
10
+ "django.contrib.sessions",
11
+ "django.contrib.admin",
12
+ "django.contrib.messages",
13
+ "stapel_core.django.users",
14
+ "rest_framework",
15
+ "stapel_tasks",
16
+ ],
17
+ # NOTE: stapel_core.django.taskstore is deliberately NOT installed.
18
+ # It historically claimed the Django label `stapel_tasks` (an
19
+ # unrelated background-task persistence app); this module owns that
20
+ # label. See MODULE.md §"stapel-core requirement".
21
+ AUTH_USER_MODEL="users.User",
22
+ DATABASES={
23
+ "default": {
24
+ "ENGINE": "django.db.backends.sqlite3",
25
+ "NAME": ":memory:",
26
+ }
27
+ },
28
+ DEFAULT_AUTO_FIELD="django.db.models.BigAutoField",
29
+ USE_TZ=True,
30
+ ROOT_URLCONF="stapel_tasks.tests.urls",
31
+ CACHES={
32
+ "default": {
33
+ "BACKEND": "django.core.cache.backends.locmem.LocMemCache",
34
+ }
35
+ },
36
+ # Synchronous in-process comm with schema validation ON, so the
37
+ # committed contracts in schemas/ are enforced by the tests.
38
+ STAPEL_BUS_BACKEND="stapel_core.bus.backends.memory.MemoryBus",
39
+ STAPEL_COMM={
40
+ "OUTBOX_ENABLED": False,
41
+ "ACTION_TRANSPORT": "inprocess",
42
+ "VALIDATE_SCHEMAS": True,
43
+ },
44
+ MIGRATION_MODULES={
45
+ "users": None,
46
+ "stapel_tasks": None,
47
+ },
48
+ )
49
+ import django
50
+
51
+ django.setup()
52
+
53
+ from stapel_core.comm.schemas import autoload_schemas
54
+
55
+ autoload_schemas()
56
+
57
+
58
+ import pytest # noqa: E402
59
+
60
+
61
+ @pytest.fixture
62
+ def api_client():
63
+ from rest_framework.test import APIClient
64
+
65
+ return APIClient()
66
+
67
+
68
+ @pytest.fixture
69
+ def user(db):
70
+ from django.contrib.auth import get_user_model
71
+
72
+ return get_user_model().objects.create_user(
73
+ username="alice", email="alice@example.com", password="x"
74
+ )
75
+
76
+
77
+ @pytest.fixture
78
+ def other_user(db):
79
+ from django.contrib.auth import get_user_model
80
+
81
+ return get_user_model().objects.create_user(
82
+ username="bob", email="bob@example.com", password="x"
83
+ )
84
+
85
+
86
+ @pytest.fixture
87
+ def auth_client(api_client, user):
88
+ api_client.force_authenticate(user=user)
89
+ return api_client
90
+
91
+
92
+ @pytest.fixture(autouse=True)
93
+ def _reset_board_presets():
94
+ """Keep the board preset registry clean between tests."""
95
+ from stapel_tasks.presets import reset_presets
96
+
97
+ reset_presets()
98
+ yield
99
+ reset_presets()
100
+
101
+
102
+ @pytest.fixture
103
+ def captured_events():
104
+ """Subscribe to task emits (in-process) and collect Event envelopes.
105
+ Delivery is synchronous with OUTBOX disabled, so the list is populated by
106
+ the time emit() returns."""
107
+ from stapel_core.comm import action_registry, subscribe_action
108
+
109
+ collected = []
110
+
111
+ def _handler(event):
112
+ collected.append(event)
113
+
114
+ names = [
115
+ "task.created",
116
+ "task.updated",
117
+ "task.moved",
118
+ "task.assigned",
119
+ "task.completed",
120
+ "task.comment_added",
121
+ "task.checklist_item_changed",
122
+ "task.archived",
123
+ ]
124
+ for name in names:
125
+ subscribe_action(name, _handler)
126
+ try:
127
+ yield collected
128
+ finally:
129
+ for name in names:
130
+ handlers = action_registry._subscribers.get(name, [])
131
+ if _handler in handlers:
132
+ handlers.remove(_handler)