31 lines
953 B
Python
31 lines
953 B
Python
"""Abstract persistence API for administrator-managed fixed questions."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from abc import ABC, abstractmethod
|
|
from typing import Any
|
|
|
|
|
|
class FixedQuestionStore(ABC):
|
|
"""Global fixed-question configuration shared by every account."""
|
|
|
|
@abstractmethod
|
|
async def list_questions(self) -> list[dict[str, Any]]:
|
|
"""Return every configured question in display order."""
|
|
raise NotImplementedError
|
|
|
|
@abstractmethod
|
|
async def find_enabled(self, question: str) -> dict[str, Any] | None:
|
|
"""Return the enabled row whose question exactly equals ``question``."""
|
|
raise NotImplementedError
|
|
|
|
@abstractmethod
|
|
async def replace_all(
|
|
self,
|
|
rows: list[dict[str, Any]],
|
|
*,
|
|
updated_by: str | None = None,
|
|
) -> list[dict[str, Any]]:
|
|
"""Atomically replace the complete fixed-question configuration."""
|
|
raise NotImplementedError
|