def get_settings_keyboard(poll): """Get the options menu for this poll.""" buttons = [] locale = poll.user.locale # Anonymization if not poll.anonymous: text = i18n.t('keyboard.anonymize', locale=locale) payload = f'{CallbackType.settings_anonymization_confirmation.value}:{poll.id}:0' buttons.append([InlineKeyboardButton(text=text, callback_data=payload)]) # Change language language_text = i18n.t('keyboard.change_language', locale=locale) language_payload = f'{CallbackType.settings_open_language_picker.value}:{poll.id}:0' buttons.append([InlineKeyboardButton(text=language_text, callback_data=language_payload)]) # Open due date datepicker new_option_text = i18n.t('keyboard.due_date', locale=locale) new_option_payload = f'{CallbackType.settings_open_due_date_datepicker.value}:{poll.id}:0' buttons.append([InlineKeyboardButton(text=new_option_text, callback_data=new_option_payload)]) if poll.has_date_option(): # Show percentage option date_format_text = '📅 yyyy-mm-dd date format' if poll.european_date_format else '📅 dd.mm.yyyy date format' date_format_payload = f'{CallbackType.settings_toggle_date_format.value}:{poll.id}:0' buttons.append([InlineKeyboardButton(text=date_format_text, callback_data=date_format_payload)]) # Sorting sub menu sorting_text = i18n.t('keyboard.sorting', locale=locale) sorting_payload = f'{CallbackType.settings_show_sorting.value}:{poll.id}:0' buttons.append([InlineKeyboardButton(text=sorting_text, callback_data=sorting_payload)]) if poll.results_visible: # Show percentage option percentage_text = i18n.t('keyboard.hide_percentage', locale=locale) if poll.show_percentage: percentage_text = i18n.t('keyboard.show_percentage', locale=locale) percentage_payload = f'{CallbackType.settings_toggle_percentage.value}:{poll.id}:0' buttons.append([InlineKeyboardButton(text=percentage_text, callback_data=percentage_payload)]) # New option button new_option_text = i18n.t('keyboard.new_option', locale=locale) new_option_payload = f'{CallbackType.settings_new_option.value}:{poll.id}:0' buttons.append([InlineKeyboardButton(text=new_option_text, callback_data=new_option_payload)]) # Remove options button new_option_text = i18n.t('keyboard.remove_option', locale=locale) new_option_payload = f'{CallbackType.settings_show_remove_option_menu.value}:{poll.id}:0' buttons.append([InlineKeyboardButton(text=new_option_text, callback_data=new_option_payload)]) # Allow user options button allow_new_option_text = i18n.t('keyboard.allow_user_options', locale=locale) if poll.allow_new_options: allow_new_option_text = i18n.t('keyboard.forbid_user_options', locale=locale) allow_new_option_payload = f'{CallbackType.settings_toggle_allow_new_options.value}:{poll.id}:0' buttons.append([InlineKeyboardButton(text=allow_new_option_text, callback_data=allow_new_option_payload)]) # Back button buttons.append([get_back_to_management_button(poll)]) return InlineKeyboardMarkup(buttons)
def get_anonymization_confirmation_keyboard(poll): """Get the confirmation keyboard for poll deletion.""" locale = poll.user.locale payload = f'{CallbackType.settings_anonymization.value}:{poll.id}:0' buttons = [ [InlineKeyboardButton(i18n.t('keyboard.permanently_anonymize', locale=locale), callback_data=payload)], [get_back_to_management_button(poll)], ] return InlineKeyboardMarkup(buttons)
def get_settings_keyboard(poll): """Get the options menu for this poll.""" buttons = [] locale = poll.user.locale # Anonymization if not poll.anonymous: text = i18n.t('keyboard.anonymize', locale=locale) payload = f'{CallbackType.settings_anonymization_confirmation.value}:{poll.id}:0' buttons.append([InlineKeyboardButton(text=text, callback_data=payload)]) # Change language language_text = i18n.t('keyboard.change_language', locale=locale) language_payload = f'{CallbackType.settings_open_language_picker.value}:{poll.id}:0' buttons.append([InlineKeyboardButton(text=language_text, callback_data=language_payload)]) # Open due date datepicker new_option_text = i18n.t('keyboard.due_date', locale=locale) new_option_payload = f'{CallbackType.settings_open_due_date_datepicker.value}:{poll.id}:0' buttons.append([InlineKeyboardButton(text=new_option_text, callback_data=new_option_payload)]) # Sorting sub menu styling_text = i18n.t('keyboard.styling', locale=locale) styling_payload = f'{CallbackType.settings_show_styling.value}:{poll.id}:0' buttons.append([InlineKeyboardButton(text=styling_text, callback_data=styling_payload)]) # New option button new_option_text = i18n.t('keyboard.new_option', locale=locale) new_option_payload = f'{CallbackType.settings_new_option.value}:{poll.id}:0' buttons.append([InlineKeyboardButton(text=new_option_text, callback_data=new_option_payload)]) # Remove options button new_option_text = i18n.t('keyboard.remove_option', locale=locale) new_option_payload = f'{CallbackType.settings_show_remove_option_menu.value}:{poll.id}:0' buttons.append([InlineKeyboardButton(text=new_option_text, callback_data=new_option_payload)]) # Allow user options button allow_new_option_text = i18n.t('keyboard.allow_user_options', locale=locale) if poll.allow_new_options: allow_new_option_text = i18n.t('keyboard.forbid_user_options', locale=locale) allow_new_option_payload = f'{CallbackType.settings_toggle_allow_new_options.value}:{poll.id}:0' buttons.append([InlineKeyboardButton(text=allow_new_option_text, callback_data=allow_new_option_payload)]) # Back button buttons.append([get_back_to_management_button(poll)]) return InlineKeyboardMarkup(buttons)