__filename__ = "webapp_question.py" __author__ = "Bob Mottram" __license__ = "AGPL3+" __version__ = "1.4.0" __maintainer__ = "Bob Mottram" __email__ = "bob@libreserver.org" __status__ = "Production" __module_group__ = "Web Interface" import os from question import is_question from utils import remove_id_ending from utils import acct_dir from utils import text_in_file def insert_question(base_dir: str, translate: {}, nickname: str, domain: str, content: str, post_json_object: {}, page_number: int) -> str: """ Inserts question selection into a post """ if not is_question(post_json_object): return content if len(post_json_object['object']['oneOf']) == 0: return content message_id = remove_id_ending(post_json_object['id']) if '#' in message_id: message_id = message_id.split('#', 1)[0] page_number_str = '' if page_number: page_number_str = '?page=' + str(page_number) votes_filename = \ acct_dir(base_dir, nickname, domain) + '/questions.txt' show_question_results = False if os.path.isfile(votes_filename): if text_in_file(message_id, votes_filename): show_question_results = True if not show_question_results: # show the question options content += '
\n' + \
'
\n' + \
' ' + \
' \n' + \
'