main
Bob Mottram 2020-10-08 18:05:01 +01:00
parent 68758e95f5
commit c5ecdaf5c3
1 changed files with 32 additions and 24 deletions

View File

@ -5367,6 +5367,30 @@ def getLeftColumnContent(baseDir: str, nickname: str, domainFull: str,
return htmlStr return htmlStr
def votesOnNewswireItem(status: []) -> int:
"""Returns the number of votes on a newswire item
"""
totalVotes = 0
for line in status:
if 'vote:' in line:
totalVotes += 1
return totalVotes
def votesIndicator(totalVotes: int, positiveVoting: bool) -> str:
"""Returns an indicator of the number of votes on a newswire item
"""
if totalVotes <= 0:
return ''
totalVotesStr = ' '
for v in range(totalVotes):
if positiveVoting:
totalVotesStr += ''
else:
totalVotesStr += ''
return totalVotesStr
def htmlNewswire(newswire: str, nickname: str, moderator: bool, def htmlNewswire(newswire: str, nickname: str, moderator: bool,
translate: {}, positiveVoting: bool) -> str: translate: {}, positiveVoting: bool) -> str:
"""Converts a newswire dict into html """Converts a newswire dict into html
@ -5377,19 +5401,11 @@ def htmlNewswire(newswire: str, nickname: str, moderator: bool,
dateStrLink = dateStrLink.replace('+00:00', '') dateStrLink = dateStrLink.replace('+00:00', '')
if 'vote:' + nickname in item[2]: if 'vote:' + nickname in item[2]:
totalVotesStr = '' totalVotesStr = ''
if moderator:
# count the total votes for this item
totalVotes = 0 totalVotes = 0
for line in item[2]: if moderator:
if 'vote:' in line: totalVotes = votesOnNewswireItem(item[2])
totalVotes += 1 totalVotesStr = \
if totalVotes > 0: votesIndicator(totalVotes, positiveVoting)
totalVotesStr = ' '
for v in range(totalVotes):
if positiveVoting:
totalVotesStr += ''
else:
totalVotesStr += ''
htmlStr += '<p class="newswireItemApproved">' + \ htmlStr += '<p class="newswireItemApproved">' + \
'<a href="' + item[1] + '">' + item[0] + '</a>' + \ '<a href="' + item[1] + '">' + item[0] + '</a>' + \
@ -5407,21 +5423,13 @@ def htmlNewswire(newswire: str, nickname: str, moderator: bool,
htmlStr += dateStr.replace('+00:00', '') + '</label></p>' htmlStr += dateStr.replace('+00:00', '') + '</label></p>'
else: else:
totalVotesStr = '' totalVotesStr = ''
if moderator:
# count the total votes for this item
totalVotes = 0 totalVotes = 0
for line in item[2]: if moderator:
if 'vote:' in line: totalVotes = votesOnNewswireItem(item[2])
totalVotes += 1
# show a number of ticks or crosses for how many # show a number of ticks or crosses for how many
# votes for or against # votes for or against
if totalVotes > 0: totalVotesStr = \
totalVotesStr = ' ' votesIndicator(totalVotes, positiveVoting)
for v in range(totalVotes):
if positiveVoting:
totalVotesStr += ''
else:
totalVotesStr += ''
htmlStr += '<p class="newswireItem">' + \ htmlStr += '<p class="newswireItem">' + \
'<a href="' + item[1] + '">' + item[0] + '</a>' + \ '<a href="' + item[1] + '">' + item[0] + '</a>' + \