refactor(core): 文档系列目录查询收敛进 DocManager
core/views.py 的 GetSerieDirectory 分支改用 DocManager.GetSerie / 新增的 ListDocumentsBySerie,移除视图内局部 import 与裸 ORM;doc/manager.py 新增 ListDocumentsBySerie(DocSerieUUID) 查询集方法。 注:core/views.py 同时携带此前工作区已有的 Viper/Venom 子域登记(SUBDOMAIN_CONFIG 两条),随本文件一并提交。
This commit is contained in:
1 parent
d600315829
commit
ba0678a722
2 files changed
+12
-7
No files matched your search
@@ -64,6 +64,10 @@ SUBDOMAIN_CONFIG = {
|
||||
'unclear': {'dir': 'Unclear', 'root_is_index': True},
|
||||
'old2': {'dir': 'Olds/2', 'root_is_index': True, 'base': 'Olds/2/_base'},
|
||||
'old3': {'dir': 'Olds/3', 'root_is_index': True, 'base': 'Olds/3/_base'},
|
||||
# Viper 语言官网(Vue 产物在 TempLate/Viper;venom 由 Main.py STATIC_SITES 直接静态托管,
|
||||
# 此处登记仅为 dev server / 兜底一致)
|
||||
'viper': {'dir': 'Viper', 'root_is_index': True},
|
||||
'venom': {'dir': 'Venom', 'root_is_index': True},
|
||||
}
|
||||
|
||||
|
||||
@@ -175,13 +179,9 @@ def _doc_api(file_path):
|
||||
})
|
||||
|
||||
if action == 'GetSerieDirectory':
|
||||
from gvsds.apps.doc.models import CommunityDocument, CommunitySeries
|
||||
try:
|
||||
serie = CommunitySeries.objects.get(DocSerieUUID=uuid_bytes)
|
||||
except CommunitySeries.DoesNotExist:
|
||||
serie = None
|
||||
serie = DocManager.GetSerie(uuid_bytes)
|
||||
if serie is not None:
|
||||
docs = CommunityDocument.objects.filter(DocSerieUUID=uuid_bytes)
|
||||
docs = DocManager.ListDocumentsBySerie(uuid_bytes)
|
||||
chapters = [
|
||||
{
|
||||
'id': UUIDObj(d.DocUUID).str.replace('-', ''),
|
||||
@@ -201,7 +201,7 @@ def _doc_api(file_path):
|
||||
return JsonResponse({'error': 'not_found'}, status=404)
|
||||
chapters = []
|
||||
if doc.DocSerieUUID:
|
||||
serie_docs = CommunityDocument.objects.filter(DocSerieUUID=doc.DocSerieUUID)
|
||||
serie_docs = DocManager.ListDocumentsBySerie(doc.DocSerieUUID)
|
||||
chapters = [
|
||||
{
|
||||
'id': UUIDObj(d.DocUUID).str.replace('-', ''),
|
||||
|
||||
@@ -149,6 +149,11 @@ class DocManager:
|
||||
qs = qs.filter(DocSerieUUID=UUIDObj(DocSerieUUID).bytes)
|
||||
return qs
|
||||
|
||||
@staticmethod
|
||||
def ListDocumentsBySerie(DocSerieUUID):
|
||||
"""系列下的文档查询集(DocSerieUUID 支持 bytes/UUIDObj/str)"""
|
||||
return CommunityDocument.objects.filter(DocSerieUUID=UUIDObj(DocSerieUUID).bytes)
|
||||
|
||||
@staticmethod
|
||||
def QuerySeries(Keyword=''):
|
||||
"""系列查询集——按名称模糊过滤"""
|
||||
|
||||
Reference in new issue
Block a user