Show total moderator votes on newswire items

main
Bob Mottram 2020-10-06 20:46:22 +01:00
parent 20d3a93be8
commit adc6cd9317
2 changed files with 26 additions and 5 deletions

View File

@ -79,7 +79,7 @@ def xml2StrToDict(xmlStr: str) -> {}:
try: try:
publishedDate = \ publishedDate = \
datetime.strptime(pubDate, "%a, %d %b %Y %H:%M:%S %z") datetime.strptime(pubDate, "%a, %d %b %Y %H:%M:%S %z")
result[str(publishedDate)] = [title, link, ['votes:0']] result[str(publishedDate)] = [title, link, []]
parsed = True parsed = True
except BaseException: except BaseException:
pass pass
@ -232,8 +232,7 @@ def addAccountBlogsToNewswire(baseDir: str, nickname: str, domain: str,
published = published.replace('Z', '+00:00') published = published.replace('Z', '+00:00')
newswire[published] = \ newswire[published] = \
[postJsonObject['object']['summary'], [postJsonObject['object']['summary'],
postJsonObject['object']['url'], postJsonObject['object']['url'], []]
['votes:0']]
ctr += 1 ctr += 1
if ctr >= maxBlogsPerAccount: if ctr >= maxBlogsPerAccount:

View File

@ -5347,8 +5347,19 @@ def htmlNewswire(newswire: str, nickname: str, moderator: bool) -> str:
dateStrLink = dateStr.replace(' ', 'T') dateStrLink = dateStr.replace(' ', 'T')
dateStrLink = dateStrLink.replace('+00:00', '') dateStrLink = dateStrLink.replace('+00:00', '')
if 'vote:' + nickname in item[2]: if 'vote:' + nickname in item[2]:
totalVotesStr = ''
if moderator:
# count the total votes for this item
totalVotes = 0
for line in item[2]:
if '[vote:' in line:
totalVotes += 1
if totalVotes > 0:
totalVotesStr = ' +' + str(totalVotes)
htmlStr += '<p class="newswireItemApproved">' + \ htmlStr += '<p class="newswireItemApproved">' + \
'<a href="' + item[1] + '">' + item[0] + '</a>' '<a href="' + item[1] + '">' + item[0] + '</a>' + \
totalVotesStr
if moderator: if moderator:
htmlStr += \ htmlStr += \
' ' + \ ' ' + \
@ -5360,8 +5371,19 @@ def htmlNewswire(newswire: str, nickname: str, moderator: bool) -> str:
htmlStr += ' <label class="newswireDateApproved">' htmlStr += ' <label class="newswireDateApproved">'
htmlStr += dateStr.replace('+00:00', '') + '</label></p>' htmlStr += dateStr.replace('+00:00', '') + '</label></p>'
else: else:
totalVotesStr = ''
if moderator:
# count the total votes for this item
totalVotes = 0
for line in item[2]:
if '[vote:' in line:
totalVotes += 1
if totalVotes > 0:
totalVotesStr = ' +' + str(totalVotes)
htmlStr += '<p class="newswireItem">' + \ htmlStr += '<p class="newswireItem">' + \
'<a href="' + item[1] + '">' + item[0] + '</a>' '<a href="' + item[1] + '">' + item[0] + '</a>' + \
totalVotesStr
if moderator: if moderator:
htmlStr += \ htmlStr += \
' ' + \ ' ' + \