feat(rules): project rule + topic suppressions
Lets a project mute individual rules or whole topics from rulebooks it subscribes to, without unsubscribing the rulebook. Two new association tables (migration 0060), 4 MCP tools (suppress/unsuppress × rule/topic), 4 REST endpoints, and an inline "× skip" affordance plus collapsed "Suppressed (N)" section in the project's Rules tab. get_applicable_rules now emits suppressed_rules and suppressed_topics (detail objects with rulebook/topic context, not just IDs) so the UI can render the suppressed list without a follow-up lookup. The main rules projection grew topic_id and rulebook_id columns for the per-row suppress affordance. Project deletion cascades the suppression rows via hard DELETE — they are pure associations with no soft-delete column, and restoring a deleted project should start fresh, not inherit stale mutes. Project-scoped rules (Rule.project_id) are deliberately not suppressible — delete them with delete_rule instead. Implements plan-task #187. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -241,6 +241,54 @@ async def get_project_rules(project_id: int):
|
||||
return jsonify(result)
|
||||
|
||||
|
||||
@rulebooks_bp.post("/projects/<int:project_id>/suppressions/rules/<int:rule_id>")
|
||||
@login_required
|
||||
async def suppress_project_rule(project_id: int, rule_id: int):
|
||||
try:
|
||||
await rulebooks_svc.suppress_rule_for_project(
|
||||
project_id=project_id, rule_id=rule_id, user_id=_uid(),
|
||||
)
|
||||
except ValueError as exc:
|
||||
return jsonify({"error": str(exc)}), 404
|
||||
return "", 204
|
||||
|
||||
|
||||
@rulebooks_bp.delete("/projects/<int:project_id>/suppressions/rules/<int:rule_id>")
|
||||
@login_required
|
||||
async def unsuppress_project_rule(project_id: int, rule_id: int):
|
||||
try:
|
||||
await rulebooks_svc.unsuppress_rule_for_project(
|
||||
project_id=project_id, rule_id=rule_id, user_id=_uid(),
|
||||
)
|
||||
except ValueError as exc:
|
||||
return jsonify({"error": str(exc)}), 404
|
||||
return "", 204
|
||||
|
||||
|
||||
@rulebooks_bp.post("/projects/<int:project_id>/suppressions/topics/<int:topic_id>")
|
||||
@login_required
|
||||
async def suppress_project_topic(project_id: int, topic_id: int):
|
||||
try:
|
||||
await rulebooks_svc.suppress_topic_for_project(
|
||||
project_id=project_id, topic_id=topic_id, user_id=_uid(),
|
||||
)
|
||||
except ValueError as exc:
|
||||
return jsonify({"error": str(exc)}), 404
|
||||
return "", 204
|
||||
|
||||
|
||||
@rulebooks_bp.delete("/projects/<int:project_id>/suppressions/topics/<int:topic_id>")
|
||||
@login_required
|
||||
async def unsuppress_project_topic(project_id: int, topic_id: int):
|
||||
try:
|
||||
await rulebooks_svc.unsuppress_topic_for_project(
|
||||
project_id=project_id, topic_id=topic_id, user_id=_uid(),
|
||||
)
|
||||
except ValueError as exc:
|
||||
return jsonify({"error": str(exc)}), 404
|
||||
return "", 204
|
||||
|
||||
|
||||
@rulebooks_bp.post("/projects/<int:project_id>/rules")
|
||||
@login_required
|
||||
async def create_project_rule(project_id: int):
|
||||
|
||||
Reference in New Issue
Block a user