예제 #1
0
def xFollow(id: str, status: str):
    """
    @param id = the followee user who the currently-logged-in user
        is following or unfollowing
    @param status = following status, 0=unfollow, 1=follow
    """
    makeFollowing = (status == "1")
    cun = currentUserName()
    dpr("id=%r status=%r cun=%r", id, status, cun)
    if not cun: return "{}"

    cu = User.getDoc(cun)
    if not cu: return "{}"
    followee = User.getDoc(id)
    if not followee: return "{}"

    ai = models.getAccountInfo(cun)
    followingSet = set(ai.following_ids)
    if makeFollowing:
        followingSet2 = followingSet | set([id])
    else:
        followingSet2 = followingSet - set([id])
    if followingSet2 != followingSet:
        ai.following_ids = list(followingSet2)
        ai.save()
    return "{}"
예제 #2
0
def account():
    page, keyword, so = request_get(request.args)
    accountList = getAccountList()
    if accountList:
        account_num = accountList[0]
    else:
        account_num = None
    paging, data_list = getAccountInfo(account_num, page=page, is_paging=True)
    return render_template('stock/account.html', **locals())
예제 #3
0
 def getFeedGenerator(self) -> FeedGenerator:
     """ return a feed generator for an RSS feed for this class
     """
     ai = models.getAccountInfo(self.id)
     fg = FeedGenerator()
     fg.title(ai.title or self.id)
     fg.author({'name': self.id})
     fg.link(href="%s/blog/%s" % (config.SITE_STUB, self.id))
     fg.description(ai.bioHtml)
     return fg
예제 #4
0
 def getAccountInfo(self, accountNum):
     isStockFinished = checkStockFinished()
     accountInfo = None
     if isStockFinished:
         accountInfo = models.getAccountInfo(accountNum)
     if accountInfo is None:
         accountInfo = self.kiwoom.getAccountInfo(accountNum)  # 예수금 상세현황 요청
         models.updateAccountInfo(accountInfo)
     self.logger.info('accountInfo: %s' % str(accountInfo))
     return accountInfo
예제 #5
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
예제 #6
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
예제 #7
0
def accountSettings():
    cun = currentUserName()
    dpr("id=%r cun=%r", id, cun)
    #if id != cun:
    #    return http403()
    user = User.getDoc(cun)
    ai = models.getAccountInfo(cun)
    msg = ""
        
    if request.method=='POST':
        ai = ai.populateFromRequest(request)
        ai.save()
        msg = "Saved account settings"
    #//if    
    
    tem = jinjaEnv.get_template("accountSettings.html")
    h = tem.render(
        user = user,
        ai = ai,
        msg = ht.goodMessageBox(msg),
    )
    return h
예제 #8
0
def userInfoLine(id: str) -> str:
    """ Return an HTML line (<tr>) for one user.
    """
    ai = models.getAccountInfo(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})

    h = form(
        """<tr>
    <td><a href='/blog/{user}'>@{user}</a></td> 
    <td style='text-align:right;'>{numPosts}</td> 
    <td style='text-align:right;'>{numHeadPosts}</td> 
    <td style='text-align:right;'>
        <a href='/listFollowing/{user}'>{numFollowing}</a> &nbsp;
        <a href='/followingMess/{user}'><i class='fa fa-eye'></i></a></td> 
    <td style='text-align:right;'>
        <a href='/listFollowers/{user}'>{numFollowers}</a> &nbsp;
        <a href='/followerMess/{user}'>
            <i class='fa fa-arrow-circle-left'></i></a></td>   
    <td>{realName}</td> 
    <td>{title}</td> 
</tr>""",
        user=id,
        numPosts=numPosts,
        numHeadPosts=numHeadPosts,
        numFollowing=numFollowing,
        numFollowers=numFollowers,
        realName=ai.asReadableH('realName'),
        title=ai.asReadableH('title'),
    )
    return h
예제 #9
0
 def __init__(self, id: str):
     super().__init__()
     self.id = id
     ai = models.getAccountInfo(id)
     self.q = {'author_id': {'$in': ai.following_ids}}