Exemplo n.º 1
0
def ArticlePaticular(request):  #文章详情
    articleID = request.GET.get("id")
    allInformation = if_is_None(
        models.Article.objects.get(articleid=articleID), "0")
    resultDic = {}
    if allInformation != "0":
        title = allInformation.title
        authorid = if_is_None(allInformation.authorid, "0")
        author = "暂缺"
        if authorid != "0":
            author = if_is_None(authorid.name, "暂缺")
        authorID = if_is_None(authorid.authorid, "0")
        webName = if_is_None(allInformation.websiteid.websitename, "暂缺")
        webUrl = if_is_None(allInformation.websiteid.websiteurl, "暂缺")
        postTime = if_is_None(allInformation.posttime, "未知")
        content = if_is_None(allInformation.content, "暂缺")
        content = content.replace("\ue5f1\u3000", "\n")
        likeNum = str(if_is_None(allInformation.likenumber, "0"))
        scanNum = str(if_is_None(allInformation.scannumber, "0"))
        resultDic = {
            "title": title,
            "author": author,
            "webName": webName,
            "webUrl": webUrl,
            "postTime": postTime,
            "content": content,
            "likeNum": likeNum,
            "scanNum": scanNum,
            "articleID": articleID,
            "authorID": authorID
        }
        print(resultDic)
    return render(request, 'background/ArticlePaticular.html', resultDic)
Exemplo n.º 2
0
def getAuthor_ArticleList(request):
    authorID = request.GET.get("id")
    name = models.Author.objects.get(authorid=authorID).name
    results = models.Article.objects.filter(authorid=authorID)
    dataList = []
    for result in results:
        articleID = result.articleid
        posttime = if_is_None(result.posttime, "未知")
        title = result.title
        content = result.content
        if (len(content) >= 140):
            content = content[:140] + "..."
        content = content.replace("\u3000", "")
        scannumber = str(if_is_None(result.scannumber, 0))
        commentnumber = str(if_is_None(result.commentnumber, 0))
        collectnumber = str(if_is_None(result.collectnumber, 0))
        dataList.append({
            "articleID": articleID,
            "name": name,
            "posttime": posttime,
            "title": title,
            "content": content,
            "scanNum": scannumber,
            "commentNum": commentnumber,
            "collectNum": collectnumber
        })
        print(dataList)
    data = {"data": dataList}
    return HttpResponse(json.dumps(data))
Exemplo n.º 3
0
def getArticleList(request):
    dataList = []
    results = models.Article.objects.filter()
    for result in results:
        articleId = result.articleid
        authorId = if_is_None(result.authorid)
        authorName = "暂缺"
        title = if_is_None(result.title)
        readed = if_is_None(result.scannumber, 0)  #数据类型为int
        if (readed >= 100):
            heat = "超热"
        else:
            heat = "不热"
        webName = if_is_None(result.websiteid.websitename)
        webType = webType_to_strType(
            if_is_None(result.websiteid.websitetypeid, "0"))
        if (authorId != ""):
            authorName = authorId.name
        dataList.append({
            "id": articleId,
            "title": title,
            "web": webName,
            "author": authorName,
            "type": webType,
            "readed": str(readed),
            "heat": heat
        })
    res = {"data": dataList}
    return HttpResponse(json.dumps(res))
Exemplo n.º 4
0
def getAuthors(request):
    dataList = []
    results = models.Author.objects.filter()
    for result in results:
        try:
            authorID = result.authorid
            name = if_is_None(result.name)
            fansNumber = str(result.fansnumber)
            web = "暂缺"
            filesNumber = models.Article.objects.filter(
                authorid=authorID).count()
            if result.websiteid != None:
                web = if_is_None(result.websiteid.websitename)
            dic = {
                "authorId": authorID,
                "name": name,
                "filesNumber": filesNumber,
                "fansNumber": fansNumber,
                "web": web
            }
            dataList.append(dic)
        except:
            print(authorID + " was wrong")
    data = {"data": dataList}
    return HttpResponse(json.dumps(data))
Exemplo n.º 5
0
def ArticlesOfAuthor(request):  #作者详情
    authorId = request.GET.get("id")
    result = models.Author.objects.get(authorid=authorId)
    authorID = result.authorid
    name = if_is_None(result.name)
    sex = if_is_None(result.sex, "未知")
    age = str(if_is_None(result.age, "暂缺"))
    fansNumber = str(if_is_None(result.fansnumber, 0))
    address = if_is_None(result.address, "暂缺")
    filesNumber = models.Article.objects.filter(authorid=authorID).count()
    web = "暂缺"
    if result.websiteid != None:
        web = if_is_None(result.websiteid.websitename)
    introduction = if_is_None(result.introduction, "暂缺")
    focusNum = str(if_is_None(result.focusnumber, 0))
    data = {
        "authorId": authorID,
        "authorName": name,
        "filesNumber": filesNumber,
        "fansNumber": fansNumber,
        "web": web,
        "sex": sex,
        "age": age,
        "address": address,
        "introduction": introduction,
        "focusNum": focusNum
    }
    return render(request, 'background/ArticlesOfAuthor.html', data)
Exemplo n.º 6
0
def ArticlePaticularComments(request):
    articleID = request.GET.get("id")
    comments = if_is_None(
        models.ArticleComment.objects.filter(articleid=articleID))
    resultList = []
    for comment in comments:
        if comment.fathercommentid == None:
            commentID = comment.article_commentid
            commenterID = comment.authorid
            commenterName = "暂缺"
            if commenterID != None:
                commenterName = commenterID.name
            commentTime = if_is_None(comment.commenttime, "暂缺")
            content = comment.content
            content = content.replace("\ue5f1", "")
            resultList.append({
                "commentID": commentID,
                "commenterID": commenterID,
                "commenterName": commenterName,
                "commentTime": commentTime,
                "contentt": content
            })
    result = {"data": resultList}
    return HttpResponse(json.dumps(result))