0.5.5 documentation
This commit is contained in:
@@ -8,22 +8,66 @@ from django.conf import settings
|
||||
from GeneralApp.funcs import get_inter_http_respose
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.urls import reverse
|
||||
from collections import OrderedDict
|
||||
|
||||
|
||||
def get_tree_arts(art, arts):
|
||||
|
||||
docs_tree = OrderedDict()
|
||||
docs_tree.update({
|
||||
art_item.name: {
|
||||
'url': art_item.url,
|
||||
'id': art_item.id,
|
||||
'children': get_tree_arts(art_item, arts),
|
||||
} for art_item in arts.filter(parent=art)
|
||||
})
|
||||
return docs_tree
|
||||
|
||||
|
||||
# def get_tree_arts(art, arts):
|
||||
#
|
||||
# docs_tree = OrderedDict()
|
||||
# docs_tree.update({
|
||||
# art['name']: {
|
||||
# 'url': art['url'],
|
||||
# 'id': art['id'],
|
||||
# 'children': get_tree_arts(art, DocArt.objects.filter(parent=art)),
|
||||
# } for art in arts.filter(parent=None)
|
||||
# })
|
||||
# return docs_tree
|
||||
|
||||
|
||||
def DocsView(request, version=None, art_url=None):
|
||||
art = None
|
||||
kwargs = {}
|
||||
|
||||
if art_url:
|
||||
kwargs['url'] = art_url
|
||||
if art_url and version:
|
||||
kwargs = {
|
||||
'url': art_url,
|
||||
'versions__url': version,
|
||||
}
|
||||
try:
|
||||
art = DocArt.objects.get(**kwargs)
|
||||
Dict = {'cur_article': art}
|
||||
|
||||
try:
|
||||
vers_obj = DocVersion.objects.get(url=version)
|
||||
except DocVersion.DoesNotExist:
|
||||
raise Http404
|
||||
|
||||
arts = DocArt.objects.filter(enable=True, versions=vers_obj).order_by('order')
|
||||
doc_tree = get_tree_arts(None, arts)
|
||||
|
||||
|
||||
Dict = {
|
||||
'cur_article': art,
|
||||
'cur_version': vers_obj,
|
||||
'doc_tree': doc_tree
|
||||
}
|
||||
t = loader.get_template('pages/p_documentation.html')
|
||||
return get_inter_http_respose(t, Dict, request)
|
||||
except DocArt.DoesNotExist:
|
||||
raise Http404
|
||||
|
||||
|
||||
|
||||
if version:
|
||||
try:
|
||||
vers_obj = DocVersion.objects.get(url=version)
|
||||
|
||||
Reference in New Issue
Block a user