__filename__ = "webapp_question.py" __author__ = "Bob Mottram" __license__ = "AGPL3+" __version__ = "1.1.0" __maintainer__ = "Bob Mottram" __email__ = "bob@freedombone.net" __status__ = "Production" import os from question import isQuestion from utils import removeIdEnding def insertQuestion(baseDir: str, translate: {}, nickname: str, domain: str, port: int, content: str, postJsonObject: {}, pageNumber: int) -> str: """ Inserts question selection into a post """ if not isQuestion(postJsonObject): return content if len(postJsonObject['object']['oneOf']) == 0: return content messageId = removeIdEnding(postJsonObject['id']) if '#' in messageId: messageId = messageId.split('#', 1)[0] pageNumberStr = '' if pageNumber: pageNumberStr = '?page=' + str(pageNumber) votesFilename = \ baseDir + '/accounts/' + nickname + '@' + domain + '/questions.txt' showQuestionResults = False if os.path.isfile(votesFilename): if messageId in open(votesFilename).read(): showQuestionResults = True if not showQuestionResults: # show the question options content += '
\n' content += \ '
\n' questionCtr += 1 content += '