feat(tasks): ответственный, пресеты, свимлейны, утренний дайджест на почту
wiki-sync / Publish docs/wiki to Gitea wiki (push) Successful in 28s
wiki-sync / Publish docs/wiki to Gitea wiki (push) Successful in 28s
- radicale: X-RESPONSIBLE/-NAME/-EMAIL, set_responsible; починена правка задач, у которых имя файла ≠ UID (кэш перечитывается при 404, _resource_url помнит href) - board: просрочка после 18:00 МСК, пресеты resp=, группировка по ответственному - tasktracker: правило «вне бэклога только с ответственным», set_responsible - UI доски: бейдж/поповер ответственного, пресеты, переключатель «По ответственным» - контакты: is_employee (звёздочка, пресет «Сотрудники»), 9 сотрудников отмечены, Жигульский/Ферулёв/Чикуров созданы заготовками - scripts/backfill_responsible.py: владелец проставлен 73 задачам - scripts/tasks_digest.py + cron 08:00 daily: письмо с разделами, himalaya -a hermes - tests: test_task_responsible.py (15), test_tasks_digest.py (6) - openspec changes task-responsible и tasks-digest заархивированы
This commit is contained in:
+53
-12
@@ -198,7 +198,9 @@ def create_task(summary: str, description: str = "", due_str: str | None = None,
|
||||
|
||||
|
||||
def _resource_url(uid: str) -> str:
|
||||
"""URL ресурса задачи: сначала href из последнего REPORT (истинный путь)."""
|
||||
"""URL ресурса задачи: сначала ранее найденный href, затем из REPORT."""
|
||||
if uid in _RESOLVED:
|
||||
return _RESOLVED[uid]
|
||||
key = f"{TASKS_COLLECTION}:VTODO"
|
||||
for item in (_CACHE.get(key) or {}).get("items") or []:
|
||||
if item.get("uid") == uid and item.get("href"):
|
||||
@@ -236,21 +238,35 @@ def get_task(uid: str) -> dict[str, Any] | None:
|
||||
|
||||
|
||||
def _load_for_update(uid: str) -> tuple[str, str] | dict:
|
||||
"""GET задачи → (body, etag) для последующего PUT с If-Match. При ошибке — {'error': ...}."""
|
||||
try:
|
||||
"""GET задачи → (body, etag) для последующего PUT с If-Match. При ошибке — {'error': ...}.
|
||||
|
||||
Кэш списка сбрасывается после каждой записи (`_put_for_update`), поэтому при
|
||||
404 кэш перечитывается один раз: иначе задача, у которой имя файла не
|
||||
совпадает с UID (все задачи из писем), становится «нередактируемой».
|
||||
"""
|
||||
key = f"{TASKS_COLLECTION}:VTODO"
|
||||
|
||||
def _try_get() -> tuple[httpx.Response | None, str]:
|
||||
with httpx.Client(auth=(RADICALE_USER, _password()), timeout=5.0) as c:
|
||||
r, url = None, ""
|
||||
response, url = None, ""
|
||||
for candidate in _lookup_urls(uid):
|
||||
r = c.get(candidate)
|
||||
if r.status_code != 404:
|
||||
response = c.get(candidate)
|
||||
if response.status_code != 404:
|
||||
url = candidate
|
||||
break
|
||||
if r is None or r.status_code == 404:
|
||||
return {"error": "Task not found"}
|
||||
r.raise_for_status()
|
||||
# запомнить фактический ресурс, чтобы PUT шёл туда же
|
||||
_RESOLVED[uid] = url
|
||||
return r.text, r.headers.get("etag", "").strip()
|
||||
return response, url
|
||||
|
||||
try:
|
||||
r, url = _try_get()
|
||||
if r is not None and r.status_code == 404:
|
||||
_CACHE.pop(key, None)
|
||||
_fetch_items(TASKS_COLLECTION, "VTODO")
|
||||
r, url = _try_get()
|
||||
if r is None or r.status_code == 404:
|
||||
return {"error": "Task not found"}
|
||||
r.raise_for_status()
|
||||
_RESOLVED[uid] = url
|
||||
return r.text, r.headers.get("etag", "").strip()
|
||||
except Exception as e:
|
||||
return {"error": str(e)}
|
||||
|
||||
@@ -359,6 +375,9 @@ def _parse_vtodo(data: str, etag: str) -> dict[str, Any]:
|
||||
"completed": complete, "status": status, "priority": priority,
|
||||
"description": description,
|
||||
"x_status": props.get("X-STATUS", "").strip().lower(),
|
||||
"responsible": props.get("X-RESPONSIBLE", "").strip(),
|
||||
"responsible_name": _unescape(props.get("X-RESPONSIBLE-NAME", "")).strip(),
|
||||
"responsible_email": _unescape(props.get("X-RESPONSIBLE-EMAIL", "")).strip(),
|
||||
"from_value": from_value,
|
||||
"tags": tags,
|
||||
"due_raw": due or "",
|
||||
@@ -445,6 +464,28 @@ def set_task_state(uid: str, x_status: str, status: str,
|
||||
return _put_for_update(uid, new_body, etag)
|
||||
|
||||
|
||||
def set_responsible(uid: str, contact_id: str | None, name: str = "",
|
||||
email: str = "") -> dict:
|
||||
"""Записать ответственного: X-RESPONSIBLE (id контакта) + имя и адрес копией.
|
||||
|
||||
Пустой contact_id — свойства удаляются (задача без ответственного).
|
||||
"""
|
||||
loaded = _load_for_update(uid)
|
||||
if isinstance(loaded, dict):
|
||||
return loaded
|
||||
body, etag = loaded
|
||||
contact_id = (contact_id or "").strip()
|
||||
if contact_id:
|
||||
new_body = _set_prop(body, "X-RESPONSIBLE", _esc(contact_id))
|
||||
new_body = _set_prop(new_body, "X-RESPONSIBLE-NAME", _esc(name or ""))
|
||||
new_body = _set_prop(new_body, "X-RESPONSIBLE-EMAIL", _esc(email or ""))
|
||||
else:
|
||||
new_body = _del_prop(body, "X-RESPONSIBLE")
|
||||
new_body = _del_prop(new_body, "X-RESPONSIBLE-NAME")
|
||||
new_body = _del_prop(new_body, "X-RESPONSIBLE-EMAIL")
|
||||
return _put_for_update(uid, new_body, etag)
|
||||
|
||||
|
||||
def set_tags(uid: str, tags: list[str]) -> dict:
|
||||
"""Заменить набор тегов объекта (CATEGORIES); пустой список — свойство удаляется."""
|
||||
loaded = _load_for_update(uid)
|
||||
|
||||
Reference in New Issue
Block a user