同步更新:重构路由、服务模块,更新前端构建
This commit is contained in:
26
services/browse_types.py
Normal file
26
services/browse_types.py
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
BROWSE_TYPE_SHOULD_READ = "应读"
|
||||
BROWSE_TYPE_PRE_REG_UNREAD = "注册前未读"
|
||||
|
||||
_BROWSE_TYPES_ALLOWED_INPUT = {BROWSE_TYPE_SHOULD_READ, BROWSE_TYPE_PRE_REG_UNREAD}
|
||||
|
||||
|
||||
def normalize_browse_type(value, default: str = BROWSE_TYPE_SHOULD_READ) -> str:
|
||||
text = str(value or "").strip()
|
||||
if text == BROWSE_TYPE_PRE_REG_UNREAD:
|
||||
return BROWSE_TYPE_PRE_REG_UNREAD
|
||||
if text == BROWSE_TYPE_SHOULD_READ:
|
||||
return BROWSE_TYPE_SHOULD_READ
|
||||
return default
|
||||
|
||||
|
||||
def validate_browse_type(value, default: str = BROWSE_TYPE_SHOULD_READ):
|
||||
text = str(value if value is not None else default).strip()
|
||||
if text not in _BROWSE_TYPES_ALLOWED_INPUT:
|
||||
return None
|
||||
return normalize_browse_type(text, default=default)
|
||||
|
||||
Reference in New Issue
Block a user