コード例 #1
0
def wikiEdit(u: str, pn: str):
    """ Edit a wiki page
    @param u = user id
    @param pn = page name
    """
    npn = mark.normaliseTagWpn(pn)  # normalised page name
    wp = wikidb.getWikiPage(u, npn, create=True)
    wf = WikiForm(source=wp.source)
    if request.method == 'POST':
        wf = wf.populateFromRequest(request)
        wp.source = wf.source
        wp.save()
        return redirect(form("/wiki/{u}/{pn}", u=u, pn=pn))
    #//if

    tem = jinjaEnv.get_template("wikiEdit.html")
    h = tem.render(
        userName=htmlEsc(u),
        pn=htmlEsc(pn),
        wp=wp,
        wf=wf,
        exists=bool(wp),
        canAlter=True,
        nav=wikiPageNav(u, npn),
    )
    return h
コード例 #2
0
ファイル: front.py プロジェクト: cabalamat/vr2
def front():
    tem = jinjaEnv.get_template("front.html")
    h = tem.render(
        adminSiteExists=config.CREATE_ADMIN_SITE,
        adminSitePrefix=config.ADMIN_SITE_PREFIX,
    )
    return h
コード例 #3
0
ファイル: foo.py プロジェクト: cabalamat/frambozenapp
def foo(id):
    if id == 'NEW':
        doc = Foo()
    else:
        doc = Foo.getDoc(id)
    msg = ""

    if request.method == 'POST':
        doc = doc.populateFromRequest(request)
        if request.form.get('delete', "0") == "1":
            # delete the foo
            doc.delete()
            return redirect("/foos", code=302)
        else:
            if doc.isValid():
                doc.save()
                msg = "Saved document"
            #//if
    #//if

    tem = jinjaEnv.get_template("foo.html")
    h = tem.render(
        doc=doc,
        id=id,
        msg=ht.goodMessageBox(msg),
    )
    return h
コード例 #4
0
def messList():
    """ recent messages in message list view """
    lf = MessListFormatter()

    tem = jinjaEnv.get_template("messList.html")
    h = tem.render(lf=lf, )
    return h
コード例 #5
0
def http403(msg=""):
    """
    @param msg::str = contains text as an optional error message.
    return a response containing an HTTP 403 (forbidden) message
    """
    tem = jinjaEnv.get_template("403.html")
    h = tem.render(msg=ht.errorBox(msg), )
    return (h, 403)
コード例 #6
0
ファイル: region.py プロジェクト: cabalamat/vr2
def region(id):
    r = Region.getDoc(id)
    tem = jinjaEnv.get_template("region.html")
    h = tem.render(
        id=id,
        r=r,
    )
    return h
コード例 #7
0
def popularTags():
    count = models.Tag.count()
    pag = paginate.Paginator(count)
    tem = jinjaEnv.get_template("popularTags.html")
    h = tem.render(
        table = popularTagsTable(pag),
        pag = pag,
    )
    return h
コード例 #8
0
def controlPanel():

    if request.method == 'POST':
        models.Answer.delete_many({})  # delete all answers
    #//if
    numAns = models.Answer.count()

    tem = jinjaEnv.get_template("controlPanel.html")
    h = tem.render(numAns=numAns, )
    return h
コード例 #9
0
def tag(t): 
    lf = TagFormatter(t)
    tem = jinjaEnv.get_template("tag.html")
    
    h = tem.render(
        t = t,
        lf = lf,
        qh = htmlEsc(repr(lf.q)),
    )
    return h
コード例 #10
0
def thread(id):
    m = models.Message.getDoc(id)

    tem = jinjaEnv.get_template("thread.html")
    h = tem.render(
        m=m,
        id=id,
        msh=threadFromH(m),
    )
    return h
コード例 #11
0
def mess(id):
    m = models.Message.getDoc(id)

    tem = jinjaEnv.get_template("mess.html")
    h = tem.render(
        m=m,
        id=id,
        ms=m.viewH(),
    )
    return h
コード例 #12
0
ファイル: foo.py プロジェクト: cabalamat/frambozenapp
def foos():
    count = Foo.count()
    pag = paginate.Paginator(count)
    tem = jinjaEnv.get_template("foos.html")
    h = tem.render(
        count=count,
        pag=pag,
        table=foosTable(pag),
    )
    return h
コード例 #13
0
def followerMess(id):
    user = User.getDoc(id)
    lf = FollowerFormatter(id)
    tem = jinjaEnv.get_template("followerMess.html")

    h = tem.render(
        id=id,
        user=user,
        lf=lf,
    )
    return h
コード例 #14
0
def userList():
    """ list all users """
    count = User.count()
    pag = paginate.Paginator(count)
    tem = jinjaEnv.get_template("userList.html")
    h = tem.render(
        count=count,
        pag=pag,
        table=userListTableH(pag),
    )
    return h
コード例 #15
0
def askq():
    dpr("in askq()")
    if request.method == 'POST':
        pass
    #//if

    tem = jinjaEnv.get_template("askq.html")
    h = tem.render(
        qs=questlib.questionListH()  # get html-formatted list of questions
    )
    return h
コード例 #16
0
def polls():
    tem = jinjaEnv.get_template("polls.html")
    chartData, partyStrengths = pollChartData()
    partyLegend = getPartyLegend(partyStrengths)
    h = tem.render(
        table = pollTable(),
        chartData = json.dumps(chartData, 
            sort_keys=True, indent=4),
        chartOptions = json.dumps(pollChartOptions(), 
            sort_keys=True, indent=4),
        partyLegend = partyLegend,
    )
    return h
コード例 #17
0
def messSource(id):
    m = models.Message.getDoc(id)
    starredByH = ", ".join(u for u in m.starredBy_ids)

    tem = jinjaEnv.get_template("messSource.html")
    h = tem.render(
        m=m,
        id=id,
        ms=m.viewH(),
        messSource=htmlEsc(m.source),
        starredBy=starredByH,
    )
    return h
コード例 #18
0
def alerts_replies() -> str:
    """ alerts for replies to the current user's posts """
    cun = permission.currentUserName()
    q = {'user_id': cun, 'alertType': 'reply', 'live': True}
    if request.method == 'POST':
        models.Alert.col().update_many(q, {'$set': {'live': False}})
    #//for
    count = models.Alert.count(q)

    tem = jinjaEnv.get_template("alerts_replies.html")
    h = tem.render(tabLine=alertTabLine("replies"),
                   count=count,
                   messages=getMessages(q))
    return h
コード例 #19
0
def context(id):
    m = models.Message.getDoc(id)
    ms = m.context()
    msh = ("<p style='margin: 0px 0px 0px 20px;color:#666;'>"
           "<i class='fa fa-arrow-down fa-lg'></i></p>\n").join(m.viewH()
                                                                for m in ms)

    tem = jinjaEnv.get_template("context.html")
    h = tem.render(
        m=m,
        id=id,
        msh=msh,
    )
    return h
コード例 #20
0
def alerts_historic() -> str:
    """ the current user's current alerts """
    cun = permission.currentUserName()
    q = {'user_id': cun, 'live': False}
    count = models.Alert.count(q)
    pag = paginate.Paginator(count)

    tem = jinjaEnv.get_template("alerts_historic.html")
    h = tem.render(
        tabLine=alertTabLine("historic"),
        count=count,
        pag=pag,
        table=alertsTable(q, pag),
    )
    return h
コード例 #21
0
def article(art):
    mimeType = getMimeType(art)
    if mimeType:
        pan = getPan(art)
        data = open(pan).read()
        return Response(data, mimetype=mimeType)

    title, contents = getArticleBody(art)
    tem = jinjaEnv.get_template("article.html")
    h = tem.render(
        art=art,
        title=title,
        wikiText=contents,
    )
    return h
コード例 #22
0
def listFollowers(id):
    """ list of people who follow (id) """
    user = User.getDoc(id)
    count = models.AccountInfo.count({'following_ids': id})
    pag = paginate.Paginator(count)

    tem = jinjaEnv.get_template("listFollowers.html")
    h = tem.render(
        id=id,
        user=user,
        count=count,
        pag=pag,
        table=followersTableH(id, pag),
    )
    return h
コード例 #23
0
def alerts_stars() -> str:
    """ alerts for stars to the current user's posts """
    cun = permission.currentUserName()
    q = {'user_id': cun, 'alertType': 'star', 'live': True}
    if request.method == 'POST':
        models.Alert.col().update_many(q, {'$set': {'live': False}})
    #//for
    numStars = models.Alert.count(q)

    tem = jinjaEnv.get_template("alerts_stars.html")
    h = tem.render(
        tabLine=alertTabLine("stars"),
        numStars=numStars,
        messages=getStarredMessages(q),
    )
    return h
コード例 #24
0
def wikiIndex(u: str):
    """ display a list of all the pages in a wiki 
    @param u = user id
    """
    wps = wikidb.getWikiPages(u)
    wikiIndexH = ""
    for wp in wps:
        wikiIndexH += form("<br>{a}\n", a=wp.a())
    #//for

    tem = jinjaEnv.get_template("wikiIndex.html")
    h = tem.render(
        userName=htmlEsc(u),
        nav=wikiNav(u),
        wikiIndexH=wikiIndexH,
    )
    return h
コード例 #25
0
ファイル: demog.py プロジェクト: cabalamat/poliquiz
def demographics():
    ud = models.getUserDemographics(currentUserName())
    msg = ""
        
    if request.method=='POST':
        ud = ud.populateFromRequest(request)
        if ud.isValid():
            ud.save()
            msg = "Saved user demographics"
    #//if    
    
    tem = jinjaEnv.get_template("demographics.html")
    h = tem.render(
        ud = ud,
        msg = ht.goodMessageBox(msg),
    )
    return h
コード例 #26
0
def listFollowing(id):
    """ list of people who follow (id) """
    user = User.getDoc(id)
    ai = models.getAccountInfo(id)
    count = len(ai.following_ids)
    pag = paginate.Paginator(count)

    tem = jinjaEnv.get_template("listFollowing.html")
    h = tem.render(
        id=id,
        user=user,
        ai=ai,
        count=count,
        pag=pag,
        table=followingTableH(ai, pag),
    )
    return h
コード例 #27
0
def wiki(u: str, pn: str):
    """ Display a wiki page
    @param u = user id
    @param pn = page name
    """
    npn = mark.normaliseTagWpn(pn)  # normalised page name
    wp = wikidb.getWikiPage(u, npn)

    tem = jinjaEnv.get_template("wikiPage.html")
    h = tem.render(
        userName=htmlEsc(u),
        pn=htmlEsc(pn),
        wp=wp,
        exists=bool(wp),
        canAlter=True,
        nav=wikiPageNav(u, npn),
    )
    return h
コード例 #28
0
def blog(id):
    user = User.getDoc(id)
    ai = models.getAccountInfo(id)
    lf = BlogFormatter(id)
    numPosts = models.Message.count({'author_id': id})
    numHeadPosts = models.Message.count({
        'author_id': id,
        'replyTo_id': {
            '$in': [None, '']
        },
    })
    numFollowing = len(ai.following_ids)
    numFollowers = models.AccountInfo.count({'following_ids': id})

    cun = currentUserName()
    if not cun:
        # not logged in, so no follow button
        followButton = ""
    else:
        if models.follows(cun, id):
            # follows, so unfollow button
            followButton = "unfollow"
        else:
            # doesn't currently follow, so follow button
            followButton = "follow"
    dpr("followButton=%r", followButton)

    tem = jinjaEnv.get_template("blog.html")
    h = tem.render(
        id=id,
        idJson=json.dumps(id),
        user=user,
        ai=ai,
        blogTitle=ai.asReadableH('title'),
        name=ai.asReadableH('realName'),
        bio=ai.bioHtml,
        numPosts=numPosts,
        numHeadPosts=numHeadPosts,
        numFollowing=numFollowing,
        numFollowers=numFollowers,
        followButton=followButton,
        lf=lf,
    )
    return h
コード例 #29
0
def wikiPage(u: str, folder: str, filename: str):
    """ return a wiki page. If it doesn't exist, return a placeholder.
    @param u = user name
    @param folder = the path to the page (not inculding filename)
    @param filename = the filename
    """
    wp = wikidb.getWikiPage(u, folder, filename)
    tem = jinjaEnv.get_template("wikiPage.html")
    canAlter = wikidb.canAlter(currentUserName(), u, folder, filename)
    h = tem.render(
        nav=wikiNavigation(u, folder, filename),
        userName=u,
        folder=folder,
        filename=filename,
        wp=wp,
        exists=bool(wp),
        canAlter=canAlter,
    )
    return h
コード例 #30
0
def answered(groupId):
    group = questionManager.getGroup(groupId)
    if not group:
        return permission.http403("Group does not exist")
    cun = currentUserName()
    ansQs = answeredQs(cun, group.questions)
    numQs = len(group.questions)
    numAns = len(ansQs)
    ansH = calcAnsH(cun, ansQs)

    tem = jinjaEnv.get_template("answered.html")
    h = tem.render(
        group=group,
        groupId=htmlEsc(group.id),
        groupTitle=htmlEsc(group.title),
        numQs=numQs,
        numAns=numAns,
        ansH=calcAnsH(cun, ansQs),
    )
    return h