加入「拾味」:影评 / 读书随感

- 新增 reflections 应用:Work / WorkImage / Reflection 及迁移
- 条目分类(电影/书籍/其他),图片墙与随感时间线
- 浏览公开;新建、上传、写随感复用拾匣密码解锁
- 抽出 cabinet/access.py 共享解锁状态
- 首页新增「拾味」入口
This commit is contained in:
2026-11-21 07:20:21 +08:00
parent 48178fad50
commit d9c58d4866
19 changed files with 1884 additions and 34 deletions
+31
View File
@@ -0,0 +1,31 @@
"""站点写操作的共用解锁状态(目前由拾匣与拾味共用)。"""
import time
from django.conf import settings
UNLOCK_SESSION_KEY = "cabinet_unlocked_at"
def unlock_minutes():
return max(1, int(getattr(settings, "CABINET_UNLOCK_MINUTES", 120)))
def _stamp(request):
try:
return float(request.session.get(UNLOCK_SESSION_KEY) or 0)
except (TypeError, ValueError):
return 0.0
def is_unlocked(request):
stamp = _stamp(request)
return bool(stamp) and (time.time() - stamp) < unlock_minutes() * 60
def minutes_left(request):
stamp = _stamp(request)
if not stamp:
return 0
left = unlock_minutes() * 60 - (time.time() - stamp)
return max(0, int(left // 60))