-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexternKbCon.py
57 lines (50 loc) · 1.39 KB
/
externKbCon.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# std:
# n/a
# pip-ext:
# n/a
# pip-int:
import dotsi;
# loc:
import bu;
from appDef import app;
from constants import K;
import articleMod;
import categoryMod;
import utils;
import auth;
import bleachUp;
@app.get("/")
@app.get("/category/<categoryId>")
def get_kb_category (categoryId=""):
category = K.TOP_BLANK_CATEGORY; # assumption
if categoryId != "":
category = categoryMod.getCategory(categoryId);
assert category and category._id; # correction
subcategoryList = categoryMod.getCategoryList({
"parentId": categoryId,
});
articleList = articleMod.getArticleList({
"status": "published_externally",
"categoryId": categoryId,
});
return bu.render("extern-kb-category.html", **{
"category": category,
"subcategoryList": subcategoryList,
"articleList": articleList,
});
@app.get("/article/<articleId>")
def get_kb_article (articleId):
article = articleMod.getArticle({
"_id": articleId,
"status": "published_externally",
});
if not article:
raise bu.abort("Artile not found. " +
"It may have been moved or deleted." #+
);
# ==> Found externally published article.
return bu.render("extern-kb-article.html", **({
"article": article,
"bleachUp": bleachUp,
}));
# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx